Automated Latest Fog SVN update script (1.0 and later) And other helpful productivity things
-
Hi friends,
So back in the times of fog 0.33b I posted a nifty script to help with automating the svn dev build update process. Since much has changed in the process since then I figure maybe someone else might find this rather helpful.
The script is attached and it is thoroughly commented. I’ll just post the contents without most the comments in the post too.Some prereqs for this script
Already have an existing working install/configuration of FOG 1.0 or later
sudo apt-get install subversion
mkdir /home/fog/fogInstalls
sudo apt-get install dos2unixA encrypted version of your sudo password, create one with this command
echo “your_super_secret_password” | openssl enc -des -a -e -pass pass:PASSWORD
Then just copy the output, including any “=” signs at the end of the string, into the later section of this script
Enter sudo mode and do some quick server maintenance update fun times
echo “$(echo yourOpensslEncryptedPassword | openssl enc -des -a -d -pass pass:PASSWORD)” | sudo -S apt-get update -y
sudo apt-get upgrade -yBackup stuff
sudo cp /opt/fog/service/etc/config.php /home/fog/fogInstalls # config file
sudo cp /etc/exports /home/fog/fogInstalls/exports # Exports file
sudo cp /var/www/html/fog/service/ipxe/bzImage /home/fog/fogInstalls # 64 bit kernel
sudo cp /var/www/html/fog/service/ipxe/bzImage32 /home/fog/fogInstalls # 32 bit kernel
sudo cp /var/www/html/fog/service/ipxe/bg.png /home/fog/fogInstalls # custom background
mysqldump -u root --all-databases --events > all-Databases-backup.sql # database backupMaintaining downloaded dev build folder structure
cd /home/fog/fogInstalls
time_stamp=$(date +%Y_%m_%d_%H_%M_%S)
mkdir ${time_stamp}
cd ${time_stamp}SVN download
sudo svn checkout [url]https://svn.code.sf.net/p/freeghost/code/trunk[/url]
sudo chown -R fog /home/fog/fogInstalls
sudo chgrp -R fog /home/fog/fogInstalls
sudo chmod -R 777 /home/fog/fogInstallsUpdate Fog
cd ${PWD}/trunk/bin
sudo yes | ${PWD}/installfog.sh
wget -O - --post-data=“confirm=yes” “[url]http://${FOGWEBIP}/commons/schemaupdater/index.php[/url]” 2>/dev/null#Optional - Fix webroot
sudo rm -rf /var/www/html/fog
sudo mv /var/www/fog /var/www/html/fogRestore backed up files
sudo dos2unix /home/fog/fogInstalls/.
sudo rm /opt/fog/service/etc/config.php
sudo cp /home/fog/fogInstalls/config.php /opt/fog/service/etc
sudo rm /home/fog/fogInstalls/bzImage && sudo rm /home/fog/fogInstalls/bzImage32
sudo cp /home/fog/fogInstalls/bzImage /var/www/html/fog/service/ipxe
sudo cp /home/fog/fogInstalls/bzImage32 /var/www/html/fog/service/ipxe
sudo cp /home/fog/fogInstalls/bg.png /var/www/html/fog/service/ipxe
sudo cp /tftpboot/undionly.kpxe /tftpboot/undionly.kpxe.original && mv /tftpboot/undionly.kpxe /tftpboot/undionly.0
sudo cp /tftpboot/undionly.0 /var/www/html/fog/service/ipxe/undionly.0Make sure Permissions are right on webroot and nfs images path
sudo chown -R fog /var/www/html/fog
sudo chgrp -R fog /var/www/html/fog
sudo chmod -R 775 /var/www/html/fog
sudo chown -R fog /images
sudo chgrp -R fog /images
sudo chmod -R 775 /imagesRestart/Refresh server services
sudo /etc/init.d/apache2 restart
sudo service mysql restartAlternatively, you could also just have it restart the server at this point with
sudo shutdown -r now
[url=“/_imported_xf_attachments/1/1757_fog_SVN_updater.zip?:”]fog_SVN_updater.zip[/url]
-
I’m also wondering if anyone has other helpful tricks they use on their fog server to make life easier.
For example another thing I do is make aliases for cd-ing into the fog dirs I use often, so I can just type cdfog to get to the webroot for example. I realize that you can also do this with global variables, but I’m a fan of aliases.In case you don’t know, to make the file for your fog user
sudo nano /home/fog/.bash_aliases
Note that you’ll need to restart your terminal/login session for the aliases to take effect.This is what my .bash_aliases looks like.
alias cdfog=‘cd /var/www/html/fog’
alias editDns=‘sudo nano /etc/dnsmasq.d/ltsp.conf’
alias editSmb=‘sudo nano /etc/samba/smb.cnf’
alias cdipxe=‘cd /var/www/html/fog/service/ipxe’
alias snapins=‘cd /opt/fog/snapins’ -
If I want to make changes to my init files I use this script a lot:
[CODE]#!/bin/shINIT=“init”
if [ ! -f ${INIT}.bak ]
then
echo “Backing up ${INIT}.xz”
mv ${INIT}.xz ${INIT}.bak
cp ${INIT}.bak ${INIT}.xz
fiif [ -f mnt/bin/fog ]
then
umount mnt
rmdir mnt
echo “Compressing ${INIT}.xz, please wait…”
xz -C crc32 -9 ${INIT}
else
xz -d ${INIT}.xz
mkdir -p mnt
mount -o loop ${INIT} mnt
echo “Mounted ${INIT}, have fun…”
fi[/CODE]