Differences

This shows you the differences between two versions of the page.

Link to this comparison view

rb:explodewiki [10/10/2013 15:21] (current)
Line 1: Line 1:
 +====== Deploy Wiki ======
 +
 +
 +  [root@server]#​ cat explodewiki.sh
 +  #!/bin/bash
 +  ​
 +  #Written Andrew Stringer 12 August 2011
 +  #This explodes the gzipped tar file of the wiki backup
 +  #and copies the contents to the webroot.
 +  #​Additionally it copies an invalid users file over the user
 +  #auth file to turn this into a read only copy.
 +  ​
 +  #ls-xxx01 is responsible for pushing this file, /​home/​yyyy/​xxxx/​pushwikitozzz.sh
 +  ​
 +  #turn on debugging, -x starts, +x stops
 +  set +x
 +  ​
 +  #set to 1 for testing, this forces sending mail, normally should be 0
 +  THRESHOLD=0
 +  #​EMAIL=user@xxx.com
 +  EMAIL=andrew.stringer@xxx.com
 +  TARLOCATION=/​home/​zzz/​wiki-stagingarea
 +  ARCHIVE=/​home/​zzz/​wiki-stagingarea/​archive
 +  WEBROOT=/​var/​www/​zzwiki
 +  ​
 +  TMPLOG=/​tmp/​explode.txt-$$
 +  DATE=`date +%b" "​%d"​ "%Y`
 +  DAY=`date +%a`
 +  ​
 +  ​
 +  echo "​Explode Wiki on zzz-ops01"​ > ${TMPLOG}
 +  echo "​========================="​ >> ${TMPLOG}
 +  echo ""​ >> ${TMPLOG}
 +  echo "From /​home/​zzzz/​wiki-staging/​explodewiki.sh on zzz-ops01"​ >> ${TMPLOG}
 +  echo ""​ >> ${TMPLOG};
 +  echo ""​ >> ${TMPLOG};
 +  ​
 +  echo "​Starting tar extract."​ >> ${TMPLOG}
 +  ​
 +  cd /​home/​zzzz/​wiki-stagingarea
 +  #tar -xvzf ${TARLOCATION}/​ww-wiki-backup-${DAY}.tar.gz
 +  DURATION=$(time (tar -xvzf ${TARLOCATION}/​ww-wiki-backup-${DAY}.tar.gz > /dev/null 2>&​1) 2>&​1)
 +  TARRESULT=$?​
 +  ​
 +  ​
 +  echo "​Explode return code is >​${TARRESULT}<,​ it took" >> ${TMPLOG}
 +  echo "​${DURATION}"​ >> ${TMPLOG}
 +  echo "" ​ >> ${TMPLOG}
 +  ​
 +  #move copy to Archive after untar.
 +  mv ${TARLOCATION}/​ww-wiki-backup-${DAY}.tar.gz $ARCHIVE
 +  ​
 +  #debug only
 +  #echo "ls -l /​home/​wworks/​wiki-stagingarea/​home/​scope/​wikibackup/​backup/"​
 +  #ls -l /​home/​wworks/​wiki-stagingarea/​home/​scope/​wikibackup/​backup/​
 +  ​
 +  #move backup contents to web server root
 +  ​
 +  echo "​Starting file copy and delete."​ >> ${TMPLOG}
 +  cp -rv /​home/​wworks/​wiki-stagingarea/​home/​scope/​wikibackup/​backup/​* ${WEBROOT}
 +  CPRESULT=$?
 +  echo "Copy Wiki result code is >​${CPRESULT}<"​ >> ${TMPLOG}
 +  ​
 +  rm -rf /​home/​wworks/​wiki-stagingarea/​home/​scope/​wikibackup/​backup/​*
 +  RMRESULT=$?
 +  echo "rm return code is >​${RMRESULT}<"​ >> ${TMPLOG}
 +  echo " " ​ >> ${TMPLOG}
 +  ​
 +  ​
 +  #Fix permissions in Gib copy to turn it in to a read only copy
 +  echo "​Copying dummy users file over real user" ​ >> ${TMPLOG}
 +  cp /​var/​www/​wiki/​users.auth.php /​var/​www/​giwiki/​conf/​users.auth.php
 +  CPUSERRESULT=$?​
 +  ​
 +  echo "User Fix return is >​${CPUSERRESULT}<"​ >> ${TMPLOG}
 +  echo " " ​ >> ${TMPLOG}
 +  ​
 +  ​
 +  #If any errors encountered,​ send email.
 +  if [ ${TARRESULT} != 0 ] || [ ${CPRESULT} != 0 ] || [ ${RMRESULT} != 0 ] || [ ${CPUSERRESULT} != 0 ]
 +          then
 +          THRESHOLD=1
 +  fi
 +  ​
 +  #Send mail
 +  if [ ${THRESHOLD} -eq 1 ]
 +          then
 +          /bin/mailx -s "GI Wiki extract or copy Problems."​ ${EMAIL} < ${TMPLOG}
 +  fi
 +  ​
 +  ​
 +  ​
 +  rm ${TMPLOG}
 +  exit ${THRESHOLD}
 +  ​
 +  ​
  

rb/explodewiki.txt ยท Last modified: 10/10/2013 15:21 (external edit)