#!/bin/sh # Copyright for the Uniform Repository Service (c) 1997, # by Gerald Banon. All rights reserved. # Version 1.1 # mount_server (ms) pid=$$ na=$# a0=$* a1=$1 umask 2 col=../../../../.. serv=dpi.inpe.br/banon/1995/08.08.00.00 httpd=dpi.inpe.br/banon/1996/11.20.18.56 cd .. # level 0 from not_sent if test ! -d library_service then echo "" echo improper current directory echo "" echo The current directory must be library_service. echo "" exit fi mkdir .t$pid # mount server ---------------------------- who=`cat .setenv/e-mail | sed 's/@.*$//'` # get the name group from the col directory index=`ls -lg $col/.. | egrep col$ | awk '{ print NF - 5 }'` group=`ls -lg $col/.. | egrep col$ | awk '{ print $'$index' }'` # if test "$a1" = "" || test "$a1" = "-t" # -t stands for test then # start server not_sent=`pwd` if test -f .setenv/library_location then # server probably mounted ll=`cat .setenv/library_location` hn=`echo $ll | awk -F. '{ print $1 }'` pt=`echo $ll | awk -F: '{ print $NF }'` current_host=`hostname | awk -F. '{ print $1 }'` if test $hn = $current_host then # running on the proper host cd $col/$httpd/not_sent ap=`pwd` # ap absolute path cd ../doc ./httpd \ -p $pt -r $ap/httpd-$hn-$pt.cf 2>$ap/nfs-$hn-$pt cd $not_sent # level 0 from not_sent if test -s $ap/nfs-$hn-$pt then cat $ap/nfs-$hn-$pt | \ egrep 'Possibly server already running' >.t$pid/bx if test -s .t$pid/bx then echo "" echo 'server already mounted' echo "" else cat $ap/nfs-$hn-$pt fi else echo "" echo server mounted echo "" fi else echo "" echo \ 'mount_server: library_service should be run under '$hn echo "" fi cd $not_sent # level 0 from not_sent else # server umounted cd $col/.. if test ! -d col/$httpd then echo "" echo \ 'mount_server: '$httpd' repository not installed' echo "" cd $not_sent rm -r .t$pid exit fi if test ! -f robots.txt then echo 'User-agent: *' >robots.txt echo 'Disallow: /' >>robots.txt fi hp=`pwd` # hp (home path) hn=`hostname | awk -F. '{ print $1 }'` cd col/$httpd/not_sent pt=1905 ls httpd-$hn-$pt.cf >$not_sent/.t$pid/ax \ 2>$not_sent/.t$pid/bx while test ! $pt = 2000 && test -s $not_sent/.t$pid/ax do pt=`echo $pt + 1 | bc` ls \ httpd-$hn-$pt.cf >$not_sent/.t$pid/ax 2>$not_sent/.t$pid/bx done if test $pt = 2000 then echo "" echo 'mount_server: system limit' echo "" cd $not_sent rm -r .t$pid exit fi ap=`pwd` # ap absolute path cd ../doc if test ! -f ../not_sent/httpd-$hn-$pt.cf then cd $hp/col ls -d */*/*/* >$serv/not_sent/.t$pid/l1 cd $not_sent cat .t$pid/l1 | \ awk '{ printf "Map /col/%s/doc/goto/* /from/%s/to/*\n", $0, $0 }' >.t$pid/l2 cat .t$pid/l1 | \ awk '{ printf "Map /col/%s/doc/goto-/* /from/%s/to-/*\n", $0, $0 }' >.t$pid/l3 cd $col/$httpd/doc cat \ >../not_sent/httpd-$hn-$pt.cf <$ap/nfs-$hn-$pt if test -s $ap/nfs-$hn-$pt then cat $ap/nfs-$hn-$pt | \ egrep 'Possibly server already running' >$not_sent/.t$pid/bx if test -s $not_sent/.t$pid/bx then # server already mounted if test -f ../not_sent/httpd-$hn-$pt-pid then ./httpd -p $pt -restart \ -r $ap/httpd-$hn-$pt.cf 2>$ap/nfs-$hn-$pt echo "" echo \ 'server restarted' echo "" else echo "" echo \ 'mount_server: httpd-'$hn'-'$pt'-pid not found; httpd fails to restart' echo "" cd $not_sent rm -r .t$pid exit fi else echo "" cat $ap/nfs-$hn-$pt echo "" cd $not_sent rm -r .t$pid exit fi else echo "" echo 'server mounted' echo "" fi cd $not_sent # level 0 from not_sent if test -f domainname then dom=`cat domainname` # dom (domain name) else dom=`domainname` # dom (domain name) fi echo $hn.$dom:$pt >.setenv/library_location if test "$a1" = "" then rm -f .setenv/last_change ../doc/sendchange ../doc/setindicator fi fi rm -r .t$pid exit fi # unmount server -------------------------- if test "$a1" = "-u" || test "$a1" = "-ut" || test "$a1" = "-tu" # -t stands for test then # unmount server if test -f .setenv/library_location then ll=`cat .setenv/library_location` hn=`echo $ll | awk -F. '{ print $1 }'` pt=`echo $ll | awk -F: '{ print $NF }'` if test -f $col/$httpd/not_sent/httpd-$hn-$pt-pid then kill -9 \ `cat $col/$httpd/not_sent/httpd-$hn-$pt-pid` 2>.t$pid/ax cat .t$pid/ax | grep -v 'No such process' >.t$pid/bx if test -s .t$pid/bx then echo "" echo 'mount_server: not umounted - permission denied' echo "" rm -r .t$pid exit fi rm $col/$httpd/not_sent/httpd-$hn-$pt-pid fi rm -f $col/../robots.txt rm -f $col/$httpd/not_sent/httpd-$hn-$pt.cf rm -f .setenv/library_location echo "" echo 'server umounted' echo "" if test "$a1" = "-u" then cd $col ls -d */*/*/* | \ sed 's/^/'$ll' /' >$serv/not_sent/.t$pid/output cd $serv/not_sent # send mail to URS --------------------------- cat >.t$pid/mail <.t$pid/mail2 # send mail to URS ---------------------- end rm -f .setenv/last_change ../doc/sendchange ../doc/setindicator fi else echo "" echo 'server already umounted' echo "" fi else echo "" echo 'mount_server (ms): illegal option' echo 'usage: mount_server [ -u ]' echo "" fi rm -r .t$pid