#!/bin/sh # # Script to shutdown all the systems # # GRACE, minutes GRACE=5 ABORT=false MESSAGE="" VERSION="0.0.3a, SPDsoft. Jun 21 12:50:06 2006" DIST=http://webdiis.unizar.es/pub/unix/util/sd BIN=/root/bin DO= PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/etc/:/etc:/usr/bsd unset LD_LIBRARY_PATH unset LD_LIBRARYN32_PATH unset DYLD_LIBRARY_PATH unset LYNX_TEMP_SPACE set -- `getopt VIDhang:m: $*` for i in $* do case $i in -n) DO=echo; shift;; -a) ABORT=:; shift;; -g) GRACE=$2; shift; shift;; -m) MESSAGE="$2"; shift; shift;; -V) echo "$VERSION"; exit 0;; -I) PATH=$PATH:/usr/local/bin:/sw/bin; export PATH LD_LIBRARY_PATH=/usr/local/lib; export LD_LIBRARY_PATH LD_LIBRARYN32_PATH=/usr/local/lib32; export LD_LIBRARYN32_PATH DV=`lynx -source $DIST | awk -F'"' '/^VERSION/{print $2; exit;}'` if [ "_$DV" != "_$VERSION" ] then echo "#### Warning: Server version is \"$DV\"" echo "#### program version is \"$VERSION\"" exit 1 fi exit 0 ;; -D) PATH=$PATH:/usr/local/bin:/sw/bin; export PATH LD_LIBRARY_PATH=/usr/local/lib; export LD_LIBRARY_PATH LD_LIBRARYN32_PATH=/usr/local/lib32; export LD_LIBRARYN32_PATH lynx -source $DIST > /tmp/sd.$$ ||\ exit 1 && \ mv /tmp/sd.$$ $BIN/sd chmod 755 $BIN/sd chown root $BIN/sd chgrp 0 $BIN/sd exit 0 ;; -h) echo "Use: $0 -VIDhnga" echo " -V: version" echo " -I: internet version" echo " -D: download and install update" echo " -h: help" echo " -n: do nothing" echo " -g: grace minutes (default $GRACE)" echo " -a: abort shutdown" echo " -m: message" exit 0 ;; esac done GRACES=`expr $GRACE '*' 60` case `uname` in OSF1) ARCH=osf-alpha ;; SunOS) ARCH=sunos-`arch` ;; Linux) ARCH=linux-`arch` ;; IRIX*) ARCH=irix-mips ;; Darwin*) ARCH=darwin-`arch` ;; HP-UX) if /bin/hp-mc680x0 then ARCH=hpux-68k else ARCH=hpux-hppa fi ;; CYGWIN_NT*) ARCH=cygwin-i386 ;; FreeBSD) ARCH=FreeBSD-i386 ;; *) echo Warning: unsupported system ;; esac $DO cd / if $ABORT then case $ARCH in sunos-sun4) if test -f /usr/sbin/shutdown then $DO exec /usr/sbin/shutdown -y -g$GRACES -i5 else $DO exec /usr/etc/shutdown -h +$GRACE "$MESSAGE" fi ;; osf-alpha|darwin-ppc|linux-*) ;; irix-mips) $DO /sbin/killall -v shutdown ;; hpux-*) ;; cygwin-*) ;; FreeBSD-i386) ;; *) ;; esac else case $ARCH in sunos-sun4) if test -f /usr/sbin/shutdown then $DO exec /usr/sbin/shutdown -y -g$GRACES -i5 else $DO exec /usr/etc/shutdown -h +$GRACE "$MESSAGE" fi ;; osf-alpha|darwin-ppc|linux-*) $DO exec /sbin/shutdown -h +$GRACE "$MESSAGE" ;; irix-mips) $DO exec /etc/shutdown -y -g$GRACES -i0 -p & ;; hpux-*) ;; cygwin-*) $DO exec /usr/bin/shutdown -s +$GRACE "$MESSAGE" ;; FreeBSD-i386) ;; *) ;; esac fi