Current time: 11-15-2024, 12:12 AM Hello There, Guest! (LoginRegister)


Post Reply 
nightly-update-script for Ubuntu
Author Message
lucasgirod Offline


Posts: 2
Joined: Jul 2009
Reputation: 0
Post: #1
nightly-update-script for Ubuntu
Attached you'll find a updated version of the automated nightly update script with added support for Ubuntu. Tested on jaunty.

#!/bin/bash
#
# ispcp-nightly-update
# Version: 0.0.5 - 03.05.2009
# License: GPL
# Author : ispcomm
# Credits: ispcp development team
#
# Variables
BACKUPDIR="/var/www/backup"
TRUNK_DIR="/usr/src/ispcp"
REBUILD_SITES="yes"
SAVE_DEFAULT_BACKUP="yes"
DISTRO_UPD="yes"


function msg_exit(){
echo $1;exit;
}
function Extract_vars(){
eval `cat ${TRUNK_DIR}/${MAKEFILE} | grep -E "(INST_PREF|SYSTEM_CONF)="| sed -e 's/$(INST_PREF)//g'`
for a in `cat ${SYSTEM_CONF}/ispcp.conf | grep -E "(CONF_DIR|GUI_ROOT_DIR|ROOT_DIR|BACKUP_FILE_DIR|CMD_HTTPD|CMD_NAMED|CMD_MTA|CMD_​ISPCPD|CMD_PFLOGSUM)"| sed -e 's/ //g'`
do
export $a
done
WWWDIR=`echo ${ROOT_DIR} | awk -F "/ispcp" '{print $1}'`
}

#download/update trunk no longer remove old trunk (thanks kilburn)
echo "#### DOWNLOAD TRUNK ####"
mkdir -p ${TRUNK_DIR}
svn checkout http://www.isp-control.net/ispcp_svn/trunk/ ${TRUNK_DIR}
cd ${TRUNK_DIR}

echo "#### SO determining ####"
if [ `lsb_release -i -s | tr -d "\n"` == "Ubuntu" ]; then
RELEASE=`lsb_release -c | awk '{print $2}' | tr -d "\n"`
case ${RELEASE} in
"jaunty") ;;
"intrepid") ;;
"hardy") ;;
"gutsy") ;;
"feisty") ;;
"edgy") ;;
* ) msg_exit "${RELEASE} is not suported";;
esac
MAKEFILE="Makefile.ubuntu"
Extract_vars
if [ $DISTRO_UPD == "yes" ] ; then
if [ -e ./docs/Ubuntu/ubuntu-packages-${RELEASE} ]; then
echo "#### SO UPDATE ####"
apt-get update;
apt-get -y dist-upgrade;
apt-get -y install `cat ./docs/Ubuntu/ubuntu-packages-${RELEASE}`;
fi
fi;
elif [ -e /etc/debian_version ]; then
RELEASE=`lsb_release -c | awk '{print $2}' | tr -d "\n"`
case ${RELEASE} in
"sarge") ;;
"etch") ;;
"lenny") ;;
"squeeze") ;;
* ) msg_exit "${RELEASE} is not suported";;
esac
MAKEFILE="Makefile"
Extract_vars
if [ $DISTRO_UPD == "yes" ] ; then
if [ -e ./docs/Debian/debian-packages-${RELEASE} ]; then
echo "#### SO UPDATE ####"
apt-get update;
apt-get -y dist-upgrade;
apt-get -y install `cat ./docs/Debian/debian-packages-${RELEASE}`;
fi
fi;
elif [ -e /etc/fedora-release ]; then
MAKEFILE="Makefile.fedora"
Extract_vars
if [ $DISTRO_UPD == "yes" ] ; then
msg_exit "Fedora is not suported yet"
yum -y install `cat ./docs/Fedora/fedora-packages`
cpan2rpm -i http://search.cpan.org/CPAN/authors/id/P....07.tar.gz
wget -P /tmp/core http://hany.sk/mirror/fedora/releases/7/...7.i386.rpm
rpm -i /tmp/core/perl-Net-LibIDN-0.09-3.fc7.i386.rpm
rm -f /tmp/core/perl-Net-LibIDN-0.09-3.fc7.i386.rpm
fi;
elif [ -e /etc/SuSE-release ]; then
MAKEFILE="Makefile.opensuse"
Extract_vars
if [ $DISTRO_UPD == "yes" ] ; then
yast -i `cat ./docs/OpenSuse/opensuse103-packages`
fi;
elif [ -e /etc/gentoo-release ]; then
MAKEFILE="Makefile.gentoo"
Extract_vars
if [ $DISTRO_UPD == "yes" ] ; then
emerge -uq `cat ./docs/Gentoo/gentoo-packages`
fi;
elif [ -e /etc/redhat-release ]; then
msg_exit "RedHat is not suported yet"
elif [ -e /etc/slackware-version ]; then
msg_exit "Slackware is not suported yet"
else
msg_exit "Unknown Linux ditribution: not suported"
fi

echo "#### BACKUP OLD FILES ####"
mkdir -p $BACKUPDIR
pushd $BACKUPDIR
if [ $SAVE_DEFAULT_BACKUP == "yes" ] ; then
mv -f $BACKUP_FILE_DIR .
fi

tar czpf "ispcp_backup-`date +'%Y-%m-%d %H-%M-%S'`.tar.gz" ${WWWDIR}/ispcp/
tar czpf "ispcp_backup-etc-`date +'%Y-%m-%d %H-%M-%S'`.tar.gz" ${SYSTEM_CONF}

echo "#### SAVEING SETTINGS ####"
cp -v ${WWWDIR}/ispcp/engine/ispcp-db-keys.pl .
cp -v ${WWWDIR}/ispcp/gui/include/ispcp-db-keys.php .
cp -v ${WWWDIR}/ispcp/gui/tools/pma/config.inc.php .
popd

echo "#### BUILDING ISPCP ####"
make -f ${MAKEFILE} clean
make -f ${MAKEFILE} install

echo "#### STOPING ISPCP DAEMON ####"
$CMD_ISPCPD stop

echo "#### SAVEING CUSTOM STAFF ####"
cp -TvR ${GUI_ROOT_DIR}/domain_default_page ${INST_PREF}${GUI_ROOT_DIR}/domain_default_page
cp -v ${GUI_ROOT_DIR}/themes/user_logos/* ${INST_PREF}${GUI_ROOT_DIR}/themes/user_logos/
cp -TvR ${GUI_ROOT_DIR}/errordocs ${INST_PREF}${GUI_ROOT_DIR}/errordocs

echo "#### REMOVE OLD ISPCP ####"
rm -fR $ROOT_DIR

echo "#### REMOVE .svn DIRECTORIES ####"
rm -fR `find ${INST_PREF} -type d -name '.svn'`

echo "#### UPDATE CURENT INSTALLATION ####"
pushd ${INST_PREF}${WWWDIR}
rm -fR `find ispcp/ -type d -name '.svn'`
cp -R ispcp/ $WWWDIR
cp -v ${INST_PREF}${CMD_PFLOGSUM} ${CMD_PFLOGSUM}
popd

echo "#### RESTORE SETTINGS ####"
pushd $BACKUPDIR
cp -v ispcp-db-keys.pl ${WWWDIR}/ispcp/engine/
cp -v ispcp-db-keys.pl ${WWWDIR}/ispcp/engine/messager/
cp -v ispcp-db-keys.php ${WWWDIR}/ispcp/gui/include/
cp -v config.inc.php ${WWWDIR}/ispcp/gui/tools/pma/

echo "#### RESTORE BACKUPS ####"
if [ $SAVE_DEFAULT_BACKUP == "yes" ] ; then
mv -f backups ${BACKUP_FILE_DIR}
fi
popd

echo "#### SETTING PERMISIONS ####"
pushd ${WWWDIR}/ispcp/engine/setup/
./set-engine-permissions.sh
./set-gui-permissions.sh
popd

echo "#### COPYING /parts DIRECTORIES ####"
bla=`find ${INST_PREF}/etc/ispcp -type d -name 'parts'`;
for x in $bla;
do
bla2=`echo ${x} | awk -F"${INST_PREF}|/parts" '{print $2}'`
cp -R $x $bla2
done
cp ${INST_PREF}${CONF_DIR}/apache/httpd.conf ${CONF_DIR}/apache/httpd.conf
cp ${INST_PREF}${CONF_DIR}/apache/working/ispcp.conf ${CONF_DIR}/apache/working/ispcp.conf

echo "#### REBUILDING SITES ####"
if [ $REBUILD_SITES == "yes" ] ; then
cat <<EOF | mysql -uroot -p'YOURPASSWORD' ispcp
UPDATE mail_users SET status='toadd' WHERE status='ok';
UPDATE domain SET domain_status = 'change' WHERE domain_status = 'ok';
UPDATE domain_aliasses SET alias_status = 'change' WHERE alias_status = 'ok';
UPDATE subdomain SET subdomain_status = 'change' WHERE subdomain_status = 'ok';
UPDATE subdomain_alias SET subdomain_alias_status = 'change' WHERE subdomain_alias_status = 'ok';
UPDATE htaccess SET status = 'change' WHERE status='ok';
UPDATE htaccess_groups SET status = 'change' WHERE status='ok';
UPDATE htaccess_users SET status = 'change' WHERE status='ok';
UPDATE server_ips SET ip_status = 'change' WHERE ip_status='ok';;
TRUNCATE TABLE login;
EOF
${ROOT_DIR}/engine/ispcp-rqst-mngr
fi

echo "#### Starting ispcp-daemon ####"
$CMD_ISPCPD start

echo "#### Deleting ispcp tmp Dir ####"
make clean

echo "#### Restarting Services ####"
$CMD_HTTPD restart
$CMD_NAMED restart
$CMD_MTA restart
(This post was last modified: 08-03-2009 10:03 PM by lucasgirod.)
08-03-2009 09:56 PM
Find all posts by this user Quote this message in a reply
BeNe Offline
Moderator
*****
Moderators

Posts: 5,899
Joined: Jan 2007
Reputation: 68
Post: #2
RE: nightly-update-script for Ubuntu
-> Moved to Snippets!
Maybe you can also add this to the Wiki ? So everybody can improve your script if need.

- Thanks for it.

Greez BeNe
08-03-2009 09:58 PM
Visit this user's website Find all posts by this user Quote this message in a reply
MasterTH Offline
Member
***

Posts: 570
Joined: Feb 2009
Reputation: 4
Post: #3
RE: nightly-update-script for Ubuntu
Great Work!!

After i run this script my antispam tool was deleted. Maybe you can integrate an check if some other folders are in the ispcp/gui as in the svn. then Backup the folders an move it back to the position after running the trunk-copy
10-16-2009 04:40 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)