Upgrade Script for Linux ZIP file users

Topics brought up by the TimeTrex open source community.
Locked
Surpass
Posts: 11
Joined: Fri Sep 23, 2011 6:39 am

Upgrade Script for Linux ZIP file users

Post by Surpass »

Greetings,

I thought I would share my bash script I use to upgrade TimeTrex. It creates a dump of the database (Postgres) and zips up the TimeTex directory. The script is executed as: tt_upgrade.sh $URL (save below commands to a script file and make sure it is executable)

The $URL is the download location of the zip file.

I execute this script as root and it runs on CentOS 6. You will want to change the ownership name based on your web server user.

Enjoy!

Code: Select all

#!/bin/bash
TT_FILE=${1##*/}
TT_DIR=${TT_FILE%.*}
TT_VER=${TT_DIR##*_}
wget -O ~/"$TT_FILE" $1
unzip ~/"$TT_FILE"
tar cvzf ~/timetrex_$(date +%Y%m%d)_backup.tgz /opt/TimeTrex
pg_dump -U timetrex timetrex > ~/timetrex_db_$(date +%Y%m%d).pg
cd ~/"$TT_DIR"
tar cvzf ~/timetrex_${TT_VER}.tar.gz *
cd /opt/TimeTrex
tar xvzf ~/timetrex_${TT_VER}.tar.gz && chown -R apache:apache *
cp /opt/TimeTrex/timetrex.ini.php /opt/TimeTrex/timetrex.ini.php.bak
sed 's/installer_enabled\ \=\ FALSE/installer_enabled\ \=\ TRUE/' /opt/TimeTrex/timetrex.ini.php.bak > /opt/TimeTrex/timetrex.ini.php
read -p "Press [Enter] key to finish after visiting http://server.name/interface/install/install.php"
mv /opt/TimeTrex/timetrex.ini.php.bak /opt/TimeTrex/timetrex.ini.php
Locked