#!/bin/sh # web.sh--Wrapper for jpsdomain.org web site functions # $Id: web,v 1.0 2004/01/05 00:44:27 root Exp $ # $Log: web,v $ # Revision 1.0 2004/01/05 00:44:27 root # Initial Revision # # Use variables to hard coded paths to prevent Bad Things(tm). CAT='/bin/cat' CHOWN='/bin/chown' CVS='/usr/bin/cvs' ECHO='/bin/echo' GREP='/bin/grep' RSYNC='/usr/bin/rsync' SSH='/usr/bin/ssh' SU='/bin/su' QFIREWALL='/root/bin/query-firewall' QHPOT='/root/bin/query-honeypot' GENSITE='/home/Shared/Util/GenSite.pl' WWWPAGES='/home/Shared/1Files/HOME/FPWebs/www.pages' WWWLOCAL='/home/Shared/1Files/HOME/FPWebs/www' case "$1" in co | checkout) cd ${WWWPAGES} ${CVS} update ;; ci | checkin) # 'root' is not allowed to check in CVS files, so we use the data user... ${CHOWN} -R data.data ${WWWPAGES} # Make sure 'data' owns the files ${SU} -lc "cd ${WWWPAGES} && ${CVS} commit" data # 'su' to data and check in ;; status) ${ECHO} "Generating cvs status exceptions for ${WWWPAGES}:" cd ${WWWPAGES} ${CVS} status 2> /dev/nul | ${GREP} '^File: ' | ${GREP} -v 'Up-to-date' ;; stats) # Set HOME var so MySQL can find .my.cnf when run from cron, etc. HOME=/root ${ECHO} 'Generating firewall stats page...' ${QFIREWALL} > ${WWWPAGES}/infosec/firewall.page ${ECHO} 'Generating honeynet stats page...' ${QHPOT} > ${WWWPAGES}/infosec/honeypot.page # Could do any of these, but don't since this is really only called # once a week and a full 'generate' is aclled right after. # $0 generate # $0 genfile ${WWWPAGES}/infosec/firewall.page # $0 genfile ${WWWPAGES}/infosec/honeypot.page ;; up | upload) echo 'Uploading files...' ${RSYNC} -vrtl -e ${SSH} --rsync-path=/home/v/vossenjp/bin/rsync \ ${WWWLOCAL}/ vossenjp@unix5.netaxs.com:www ${ECHO} 'Resetting remote permissions...' ${SSH} vossenjp@unix5.netaxs.com 'bin/web-site-update.sh' ${ECHO} 'Finished.' ;; download) echo 'Downloading files...' ${RSYNC} -vrtl -e ${SSH} --rsync-path=/home/v/vossenjp/bin/rsync \ vossenjp@unix5.netaxs.com:www/ ${WWWLOCAL} ;; gen | generate) cd ${WWWPAGES} ${GENSITE} -l off -t ${WWWPAGES} -w ${WWWLOCAL} ;; genfile | genpage) if [ -z "$2" ]; then ${CAT} <<-EoN Usage: $0 genfile {relative path/file to generate} e.g. $0 genfile networking\time.page EoN exit 1 fi cd ${WWWPAGES} ${GENSITE} -l off -t ${WWWPAGES} -w ${WWWLOCAL} -i ${WWWPAGES}/$2 ;; genup) $0 generate $0 upload ;; all) $0 checkin $0 generate $0 upload ;; *) ${CAT} <<-EoN $Id: web,v 1.0 2004/01/05 00:44:27 root Exp $ Usage: $0 {co|ci|up|dowload|status|stats|gen|genfile|genup|all} Wrapper for jpsdomain.org web site functions co (checkout) = Really cvs update ci (checkin) = cvs commit status = cvs status exception report stats = Generare FW and HPOT stats pages up (upload) = Upload (rsync) the site download) = Download (rsync) the site (very rare) gen (generate) = Generate the site from tempates genfile {file} = Generate HTML for the specififed file genup = Generate and upload all = Checkin, generate and upload EoN exit 1 esac