Bash script to simplify Sendy updates
Hello guys, Ben, hope everything is ok there.
I deal with 6 Sendy installations for customers that have purchased the license, and every time a new version is released, the manual updating task is time consuming. So, I wrote this bash script to automatically update the installation, and after a couple iterations and corrections, I now have it working as a breeze and without errors.
Although, since this require the cPanel account containing the script to be able to provide access to jailed shell, I really would love to avoid this and have it in the form of PHP script, or even better, bundled as a feature of Sendy itself Hopefully, someone can provide that.
In the meantime, here I share the script for those who may need something alike, or even to point out fixes or improvements.
For this script to work, you must run it as the user. If you use cPanel, then first allow jailed shell to that account, and by connecting via SSH, you will land on
/home/username, then create a blank
sendy.sh file, and assign execution permssions to it:
chmod +x sendy.sh.
Then paste the below code inside. Take into account:
- For CentOS 6.x replace
[license]with your actual license string.
#! /bin/sh cd ./public_html; wget https://sendy.co/download?license=[license] -O sendy.zip; unzip sendy.zip; cp .htaccess sendy/.htaccess; cp includes/config.php sendy/includes/config.php; cp -R sendy/* .; rm sendy -drf; rm sendy.zip -f; chmod -R ugo-x,u+rwX,go+rX,go-w ./;
Then save, and to execute simply run:
./sendy.sh. If everything went well, it should not throw any errors. After execution is completed, go to your browser and login to your Sendy installation and it will automatically update the database accordingly. Just try to perform these tasks in hours where no emails are being sent, or at least notify you customers to schedule the process with enough anticipation in order to avoid any kind of issues.
Please consider this script was coded under CentOS 7.5 with cPanel. Other environments may have distinct rules/paths and you should always make a trustworthy backup before trying this solution. In my personal case, it updated Sendy in just 2 seconds.
Hope it helps anybody interested in this solution. And of course I'm open to suggestions.
All the best,
Wow, nice script... thanks you !
Thank you, me too implemented this on my server...
Brilliant - thanks.
I added a little backup to /tmp/ and removed the uploads directory from the new update just in case. Change the /var/www/html to where ever your sendy install is.
Thanks for this bash script!
I concur with the idea of a php script! It would be great to have a magical update button somewhere in the Sendy interface.
I am sure a php script can be easily devised to make it painless.
I would use
curl -O -J -Lin case the sendy.co URL ever starts using redirects.
Having automated update would be wonderful.
If some of you are using translations (in my case fi_FI) you need to copy those over to the new version:
mkdir /var/www/html/my.domain/sendy/locale/fi_FI cp -R /var/www/html/my.domain/public_html/locale/fi_FI /var/www/html/my.domain/sendy/locale/ cp -R /var/www/html/my.domain/public_html/uploads/ /var/www/html/my.domain/sendy
--- pls replace /var/www/html/my.domain/ with your own path to Sendy
Hi guys! I'm using the code below and does anyone have any tips how can I check the health of sendy?
Hi Sendy users,
I just wanted to provide an update based on @marcelop's original post, that combines a couple of extras, some of which were explored/noted by subsequent commenters. For reference, I am using CPanel, and therefore, @marcelop's original post should be read before using the code I've included below.
In addition to being able to automatically download, unzip and install the latest Sendy package, I needed to be able to:
Backup the database
Backup the existing Sendy installation files (web root)
Store both files and database backups outside of the web root
Ensure that my
.htaccessfile was maintained after updating
Ensure that my
uploadsdirectory was maintained after updating
Ensure that my custom API directory
listswas maintained after updating
Further, I wanted to be able to use CURL to avoid potential issues should Sendy implement redirects on the updates page (as noted by (@savonaequipment) in the future.
In order to achieve this, I'm using the following
update-sendy.shwhich is executed from my
home/[username]directory with the command
N.B. I've commented the code heavily in the hope that this may help some noobs who might otherwise struggle to edit the file appropriately, in addition to declaring configuration vars at the top, to make editing a bit easier. It is cited in the comments, but please also note, that the
$BACKUP_DIRvar MUST be relative to the
$PUBLIC_PATHsince it is the directory in which we are working - hence the var being named
Thanks to everyone in this thread who's contributed to this!! I hope this helps someone out!
I will look at a PHP implementation of this at some point but a hectic schedule and heavy workload means this down and dirty version will suffice for the time being.