Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DmitryMiroshnichenko/48b966e70534acf30f41aa4a414c3f78 to your computer and use it in GitHub Desktop.
Save DmitryMiroshnichenko/48b966e70534acf30f41aa4a414c3f78 to your computer and use it in GitHub Desktop.
OpenVBX update from repo script
#! /bin/bash
#
# A script that will upgrade the version of OpenVBX that resides in the /OpenVBX
# directory, back-up the database, copy the current version for backup and replace
# it with the develop branch. The old version is not deleted.
#
# Used for testing, not approved for production!
# Does not take 3rd party plugins in to account.
# customize this for your install
DBHOST='***'
DBNM='***'
DBUSER='***'
DBPASS='***'
BACKUPDIR='/var/openvbx/backups'
INSTALLDIR='/var/www'
UPDATEDIR='/var/openvbx/update'
#echo "----------------"
#echo "cloning OpenVBX"
#cd $UPDATEDIR
#git clone https://bitbucket.org/247jobsitesteam/openvbx
#cd openvbx
#git checkout sync
echo "----------------"
echo "Checking repo changes"
cd $UPDATEDIR/openvbx
UPDATES_CHECK=`git pull | wc -l`
if [ X"$UPDATES_CHECK" = X"1" ];
then
echo "no changes found"
exit 0
else
echo "----------------"
echo "changes found. performing update"
echo "----------------"
echo "Turning off Apache"
apachectl stop
echo "----------------"
echo "backing up database"
mysqldump -u$DBUSER -p$DBPASS -h $DBHOST $DBNM > "$BACKUPDIR/openvbx-db.sql"
echo "----------------"
echo "backing up old installation"
rm -rf $BACKUPDIR/calls
cp -rf $INSTALLDIR/calls $BACKUPDIR
echo "----------------"
echo "updating"
cd $INSTALLDIR
rm -f index.html
cp -rf $UPDATEDIR/openvbx/OpenVBX/ calls
sed -i -e "s/# RewriteBase \/openvbx/RewriteBase \/calls/g" $INSTALLDIR/calls/.htaccess
chmod -Rf 0755 $INSTALLDIR/calls/audio-uploads
chmod -Rf 0755 $INSTALLDIR/calls/OpenVBX/config
# echo "----------------"
# echo "cleaning up temporary files"
# rm -Rf $UPDATEDIR/*
echo "----------------"
echo "upgrade successful"
echo "----------------"
echo "Turning on Apache"
apachectl start
echo "OpenVBX updated and ready to use"
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment