Upgrading playSMS

As of today the latest stable release is playSMS 1.4.3. This version is very important, it contains fixes to critical security vulnerability. If you have installed and currently running previous version such as playSMS 1.4.2 then you must upgrade it immediately.

Upgrading playSMS is about replacing all files and folders, and run an SQL DB upgrade. Upgrades in playSMS rarely deleting old files, more like modifying them so that you can just replace them with the new one, unless ofcourse specifically said otherwise.

This article is a guide for howto upgrade previous version of playSMS. You already have a working playSMS and its one-version behind the latest stable release, for example you have 1.4.2 installed and now released 1.4.3.

1. Installed playSMS

For example, your currently installed playSMS is playSMS 1.4.2 and running on Ubuntu Server 18.04.

For example, files and folders locations:

playSMS web path      : /var/www/html/playsms/
playSMS daemon binary : /usr/local/bin/playsmsd
playSMS daemon config : /etc/playsmsd.conf

And for example, the database detail:

MySQL username : playsmsdbuser
MySQL password : strongpasswordhere
MySQL database : playsms
MySQL hostname : localhost

You may have different locations and details. Throughout this article we will use example information details above, but in your own server you must use your own installation details.

You can get installation details by running:

playsmsd check

Or if your playsmsd and playsmsd.conf is not in the PATH, for example they are in your Home Directory, run this:

~/bin/playsmsd ~/etc/playsmsd.conf check

2. Make Backups

Before starting upgrade don\’t forget to backup installed version.

Prepare backup location, backup folder can be anything but I like to give label to it, in this case playsms-1.4.2-2005062200 meaning backup for playSMS version 1.4.2 at 6 May 2020 10pm. Let\’s prepare it:

mkdir -p ~/backup/playsms-1.4.2-2005062200
cd ~/backup/playsms-1.4.2-2005062200

Backup location is in ~/backup/playsms-1.4.2-2005062200

Backup playSMS files and folders:

cd ~/backup/playsms-1.4.2-2005062200
mkdir html
cp -rR /var/www/html/playsms html
ls -l html

Please note, assumed your playSMS web path is /var/www/html/playsms, see section 1 above.

Backup playsmsd:

cd ~/backup/playsms-1.4.2-2005062200
mkdir bin
cp /usr/local/bin/playsmsd bin
ls -l bin

Please note, assumed your playSMS daemon is in /usr/local/bin/playsmsd, see section 1 above.

Backup database dump:

cd ~/backup/playsms-1.4.2-2006062200
mkdir db
mysqldump -u playsmsdbuser -p playsms --add-drop-table > db/playsms.sql
ls -l db

See section 1 to get installation details (playSMS web path location etc) on our example in this article.

Inspect backup files and folders, make sure they are there in the backup folder. You may continue with upgrade only when you\’re certain that old installed version has been backup properly.

3. Getting New Version

Navigate to https://playsms.org/download and click link to download Official Version in SourceForge. Save it somewhere in the server, for example in ~/src/.

mkdir -p ~/src/
cd ~/src/
wget -c \"https://sourceforge.net/projects/playsms/files/playsms/Version%201.4.3/playsms-1.4.3.tar.gz/download\" -O playsms-1.4.3.tar.gz
ls -l playsms-1.4.3.tar.gz

Every release has file checksum so that you can verify whether what you have downloaded is exactly the same as the one available in the server.

cd ~/src
md5sum playsms-1.4.3.tar.gz

And compare the result with MD5 checksum in SourceForge page:

\"\"

If not match then re-download.

Ok, next is to extract the package:

cd ~/src
tar -zxf playsms-1.4.3.tar.gz
ls -l playsms-1.4.3

Your new playSMS source path is in ~/src/playsms-1.4.3

4. Let\’s Upgrade

4.1. Update Composer

Get composer and install/update composer packages:

cd ~/src/playsms-1.4.3
./getcomposer.sh

Example screenshot of running getcomposer.sh:

\"\"

If you saw any error then run ./getcomposer.sh again. Errors might happen because we are getting updates from the internet.

Your new playSMS source is ready to replace old version.

4.2. Replace Files and Folders

Go to new version\’s source path, replace all files and folders with the new version:

cd ~/src/playsms-1.4.3
cp -rR web/* /var/www/html/playsms/

Please note, assumed your playSMS web path is in /var/www/html/playsms/, see section 1 above. You must copy and replace correct playSMS files and folders.

Above cp command will copy all files and folders from new version (1.4.3) source path in sub-folder web and replace all files and folders on your current playSMS web path.

Other way to do this is by using mc and copy from left tab (new source path) to the right tab (the current playSMS web path), or vice versa. Select all files and folders from source root path and hit F5, select overwrite all files when asked.

Do This Too

Set ownership to non-root user but don\’t set to the web-server user. For example your normal user username is komodo (or add a new user) then set ownership of playSMS files and folders to user komodo, here is how:

chown komodo.komodo -R /var/www/html/playsms

Also set permissions to only owner can write them, here is how:

cd /var/www/html/playsms
find . -type d -exec chmod 755 {} \\;
find . -type f -exec chmod 644 {} \\;

4.3. Replace playSMS Daemon

Replace it:

cd ~/src/playsms-1.4.3
cp daemon/linux/bin/playsmsd.php /usr/local/bin/playsmsd
chmod +x /usr/local/bin/playsmsd

Note that in source folder playsmsd is actually a PHP file playsmsd.php

Do This Too

playsmsd is a script that is running all the time in the background, a daemon. It is important to not running this daemon as root. You must run playsmsd as non-root user.

Also check your crontab configuration if you set it up for playSMS and make sure that the cron is not running the script as root. Check crontab as root:

sudo crontab -e

4.4. Update Database

Attention

  • Files and folders can still be reinstalled when they\’re gone. But data in the database may not be.
  • Make sure to have backups, see section 2 above.

Find database upgrade SQL file in new version\’s source path:

cd ~/src/playsms-1.4.3
ls db | grep 1.4.3

You will found playsms-upgrade_1.4.2_to_1.4.3.sql in folder db.

Insert that SQL file to current playSMS database:

cd ~/src/playsms-1.4.3
mysql -u playsmsdbuser -p playsms < db/playsms-upgrade_1.4.2_to_1.4.3.sql

Above command will insert SQL commands inside SQL file to current playSMS database. It should be quiet, no error, but if you saw error then maybe theres customizations or you have done the upgrade, this command in particular, more than once.

Verify SQL inserts, login to MySQL console:

mysql -u playsmsdbuser -p playsms

On MySQL console, run this:

select registry_value from playsms_tblRegistry where registry_key=\'playsms_version\'

registry_value should reveal value the new version of playSMS, in this example article it must display 1.4.3

5. Closing

playSMS upgrade is done.

Discuss this article in playSMS Forum: