| 1 | #!/bin/sh |
| 2 | |
| 3 | # A semi-RedHat style init script for staring bnetd |
| 4 | |
| 5 | . /etc/rc.d/init.d/functions |
| 6 | |
| 7 | bnetduser="bnetd" |
| 8 | bnetdhome="/home/bnetd" |
| 9 | bnetdpid="${bnetdhome}/bnetd.pid" |
| 10 | bnetdexe="${bnetdhome}/sbin/bnetd" |
| 11 | |
| 12 | case "$1" in |
| 13 | start) |
| 14 | echo -n "Starting bnetd: " |
| 15 | if [ -r "${bnetdpid}" ] && kill -0 `cat "${bnetdpid}"`; then |
| 16 | echo "${bnetdpid} exists and the pid is still valid." |
| 17 | else |
| 18 | if [ -d "${bnetdhome}" ]; then |
| 19 | if [ -x "${bnetdexe}" ]; then |
| 20 | # su -c "cd ${bnetdhome}; ${bnetdexe} -f &" - "${bnetduser}" 2>&1 > /dev/null |
| 21 | su -c "${bnetdexe}" - "${bnetduser}" 2>&1 > /dev/null |
| 22 | # "${bnetdexe}" |
| 23 | echo bnetd |
| 24 | else |
| 25 | echo "${bnetdexe} is not an executable." |
| 26 | fi |
| 27 | else |
| 28 | echo "${bnetdhome} is not a directory." |
| 29 | fi |
| 30 | fi |
| 31 | ;; |
| 32 | restart) |
| 33 | echo -n "Restarting bnetd: " |
| 34 | if [ -f "${bnetdpid}" ] && kill -0 `cat "${bnetdpid}"`; then |
| 35 | kill -HUP `cat "${bnetdpid}"` |
| 36 | echo "bnetd" |
| 37 | else |
| 38 | echo "bnetd is not running." |
| 39 | fi |
| 40 | ;; |
| 41 | stop) |
| 42 | echo -n "Stopping bnetd: " |
| 43 | if [ -f "${bnetdpid}" ]; then |
| 44 | kill -TERM `cat "${bnetdpid}"` |
| 45 | sleep 1 |
| 46 | if [ -f "${bnetdpid}" ] && kill -0 `cat "${bnetdpid}"` 2>&1 > /dev/null; then |
| 47 | echo "waiting for users to log out." |
| 48 | else |
| 49 | rm -f "${bnetdpid}" |
| 50 | echo "bnetd" |
| 51 | fi |
| 52 | else |
| 53 | echo "bnetd is not running." |
| 54 | fi |
| 55 | ;; |
| 56 | status) |
| 57 | status bnetd |
| 58 | ;; |
| 59 | *) |
| 60 | echo "Usage: $0 {start|stop|restart|status}" |
| 61 | exit 1 |
| 62 | esac |
| 63 | |
| 64 | exit 0 |
| 65 |