#!/bin/sh # # `/etc/shutdown.local' # executed by poffd(8) SCSI_ID_OF_MO=5 # eject the medium of this ID of SCSI device. GOODBYE_CHIME=/etc/byebye.pcm # ring this file at shutdown. PATH=/bin:/sbin:/usr/bin:/usr/sbin ## check the argument. if [ $# != 1 ]; then code=XXX else code=$1 fi ## if an X server process is running, kill it and do not shutdown. if [ $code = 0 ]; then for xserver in X X68Mono /usr/X11R6/bin/X /usr/X11R6/bin/X68Mono; do xserver=`echo $xserver | sed 's-/-\\\\/-g'` serverpid=`ps ax | awk '/[0-9]?[0-9]:[0-9][0-9]\.[0-9][0-9] '"${xserver}"'/ {print $1}'` if [ -n "$serverpid" ]; then kill $serverpid exec poffd "$0 %" exit 0 fi done fi ## stop Wnn kana-kanji conversion service. if [ -S /tmp/jd_sockV4 -a -x /usr/local/bin/Wnn4/wnnkill ]; then /usr/local/bin/Wnn4/wnnkill fi ## stop Canna kana-kanji conversion service. if [ -f /var/spool/canna/lock/.CANNALOCK -a -x /usr/local/canna/bin/cannakill ]; then /usr/local/canna/bin/cannakill fi ## stop DeleGate deamen and clean the log files. if [ -f /tmp/delegate/pid/10080 ]; then kill `cat /tmp/delegate/pid/10080` rm -f /var/spool/delegate/log/10080* fi if [ -f /tmp/delegate/pid/10081 ]; then kill `cat /tmp/delegate/pid/10081` rm -f /var/spool/delegate/log/10081* fi ## eject the MO medium if mounted. MODEVICE=`mount | awk '/^\/dev\/sd'${SCSI_ID_OF_MO}'[a-h]/ {print $1}'` test -z "$MODEVICE" || ( umount $MODEVICE && eject $MODEVICE ) ## ring the good-bye chime. if [ -f ${GOODBYE_CHIME} ]; then cat ${GOODBYE_CHIME} > /dev/adpcm & fi ## choose the wall notice. case $code in 0) mes="The front power switch has been turned off!!" ;; 1) mes="The external power signal has been turned off!!" ;; 2) mes="The system shutdown time has come!!" ;; XXX) mes="" ;; *) mes="????" ;; esac ## do actual shutdown, at last!! sync sync sync shutdown -r now "$mes"