How to Setup playSMS on the Raspberry Pi


In this guide, I’ll provide some of the information you’ll need in getting playSMS installed on a Ubuntu/Debian based distribution. In this case we’re setting this up on a Raspberry Pi.

https://www.youtube.com/watch?v=lbbYdYIx2aU

I recommend you watch the video for a better understanding of the command you’re running before just pasting this content without even thinking about it.

Run the below commands as the pi or default admin user you have on your Ubuntu system.

sudo curl -sSL https://packages.sury.org/php/README.txt | sudo bash -x       
sudo dmesg | grep ttyUSB
sudo apt-get install build-essential libusb-1.0-0 libusb-1.0-doc mc unzip mariadb-server apache2 usb-modeswitch php7.4 php7.4-cli php7.4-mysql php7.4-gd php7.4-curl php7.4-mbstring php7.4-xml php7.4-zip smstools software-properties-common apt-transport-https
sudo apt-get install ufw
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
sudo ufw enable
sudo ufw status
sudo systemctl start mariadb.service
sudo systemctl enable  mariadb.service
sudo systemctl start apache2.service
sudo systemctl enable apache2.service
sudo adduser komodo
sudo usermod -a -G sudo komodo 
sudo usermod -a -G www-data komodo
sudo usermod -a -G smsd komodo 
dpkg-reconfigure tzdata 
sudo dpkg-reconfigure tzdata  # Configure your Timezone with this command. 
sudo nano /etc/php/7.4/cli/php.ini  # Update the datetime variable to your timezone. 

Run these commands as the “Komodo” user. Use the video and attachments in this article for the necessary configuration files.

cd ~/ls
mkdir public_html log
sudo chmod 775 /home/komodo/ public_html/ log/ -R
sudo chown komodo.komodo -R /home/komodo
sudo chown www-data.komodo -R /home/komodo/log
ls -l /home/komodo
sudo nano  /etc/apache2/sites-available/sms.domain.org.conf
# Paste in the Apache Virtual Host Configuration now from the attached link in this article.
cd /etc/apache2/sites-available/
sudo a2dissite 000-default.conf 
sudo a2ensite sms.domain.org.conf 
sudo systemctl reload apach2
sudo systemctl reload apache2.service 
cd /home/komodo/public_html/
nano test.php   # Paste in some PHP Code into this file and then load up the Apache server in your web browser - Check the content renders. 
rm test.php 
cd ..
mkdir -p bin etc lib src
sudo chmod 775 bin etc lib src
cd /home/komodo
sudo touch log/audit.log log/playsms.log
sudo chmod 664 log/audit.log log/playsms.log
sudo chown www-data.komodo -R log ls -l log
sudo chown www-data:komodo -R log
ls -l log/
sudo mysqladmin create playsms
sudo mysql

# Run the attahced SQL Commands as listed in this guide. 

cd src/
sudo apt-get install git
git clone -b 1.4.5 https://github.com/antonraharja/playSMS
ls
playSMS/
ls
install.conf.dist install.conf.dist.bak
sudo mv install.conf.dist install.conf
sudo nano install.conf   # Update your install.conf according the playSMS directories - Refer to the video for help here. 
./install-playsms.sh 
ls
cd ../../etc/
ls
playsmsd.conf ../bin/
cd ..
ls
cd bin/
ls
./playsmsd playsmsd.conf status
./playsmsd playsmsd.conf stop
./playsmsd playsmsd.conf status
sudo nano /etc/systemd/system/playsms.service    # Refer to the attached configuration for this service. 
sudo systemctl daemon-reload
sudo systemctl enable playsms
sudo systemctl restart playsms
sudo service playsms enable
sudo service playsms status
./playsmsd status
cd public_html/
nano config.php  # Update the configuraiton according to your installation. (HTTPS / Log Level)
cd ..
sudo cp /etc/smsd.conf /etc/smsd.conf.bak
sudo service smstools stop
sudo rm /etc/smsd.conf
sudo nano /etc/smsd.conf     # Update with the attached configuration. 
cd /var/spool/
cd  sms/
mkdir gsm1
ls -lthra
sudo chown smsd:smsd gsm1/ -R
sudo service smstools start
tail /var/log/smstools/smsd.log
tail /var/log/smstools/smsd.log
sudo chmod 777 /var/spool/sms/ -R
sudo chown www-data:smsd /var/spool/sms/ -R
ls -lthra

# Follow the video and use this example installation code accordingly. 

Apache Virtual Hosts File

<VirtualHost *:80>
    ServerName sms.domain.org
    DocumentRoot /home/komodo/public_html
    ErrorLog /home/komodo/log/httpd-error.log
    CustomLog /home/komodo/log/httpd-accesss.log combined
    <Directory /home/komodo/public_html>
        AllowOverride FileInfo AuthConfig Limit Indexes
        Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
        Require method GET POST OPTIONS
        php_admin_value engine On
    </Directory>
</VirtualHost>

PlaySMS Daemon Service

[Unit]
Description=PlaySMS
After=mariadb.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/home/komodo/bin/playsmsd /home/komodo/bin/playsmsd.conf start
ExecStop=/home/komodo/bin/playsmsd /home/komodo/bin/playsmsd.conf stop
[Install]
WantedBy=multi-user.target

/etc/smsd.conf example configuration for a USB Modem

# Global configuration
devices = gsm1
#devices = gsm1, gsm2

loglevel = 7

# logfiles
stats = /var/log/smstools/smsd_stats
logfile = /var/log/smstools/smsd.log

# Default queue directory = /var/spool/sms
outgoing = /var/spool/sms/outgoing
checked = /var/spool/sms/checked
failed = /var/spool/sms/failed
incoming = /var/spool/sms/incoming
sent = /var/spool/sms/sent

# do not set report folder, let status report files saved in incoming
#report = /var/spool/sms/report

delaytime = 2
errorsleeptime = 10
blocktime = 180
autosplit = 3
#receive_before_send = yes

# Queue configurations

[queues]
gsm1 = /var/spool/sms/gsm1
#gsm2 = /var/spool/sms/gsm2
#modem2 = /var/spool/sms/modem2

# Modem configurations

# Modem name: modem1
# Modem type: Wavecom USB
[gsm1]
#init = AT+CNMI=2,2,0,1,0;+CMEE=1
memory_start = 0
device = /dev/ttyUSB0
baudrate = 115200
incoming = yes
report = yes
queues = gsm1

#[gsm2]
#memory_start=0
#device = /dev/ttyUSBx
#baudrate = 115200
#incoming = yes
#report = yes
#queues = gsm2

[default]
queues = gsm1