1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
#! /bin/bash
#
# ums2net init script for ums2net
#
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
# Modified for Debian GNU/Linux
# by Ian Murdock <imurdock@gnu.ai.mit.edu>.
# Modified for ums2net by Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
### BEGIN INIT INFO
# Provides: ums2net
# Required-Start: $network $remote_fs
# Required-Stop: $network $remote_fs
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Allows network connections to UMS
# Description: This daemon allows tcp sessions to be established with a UMS.
### END INIT INFO
set -e
if [ -r "/lib/lsb/init-functions" ]; then
. /lib/lsb/init-functions
else
echo "E: /lib/lsb/init-functions not found, lsb-base (>= 3.0-6) needed"
exit 1
fi
if [ -n "$UMS2NETDEBUG" ]; then
echo "now debugging $0 $@"
set -x
fi
LANG=C
export LANG
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/ums2net
NAME=ums2net
DESC="USB Mass Storage to network proxy"
PIDFILE=/run/$NAME.pid
test -f $DAEMON || exit 0
# Defaults
CONFFILE="/etc/ums2net.conf"
OPTIONS=""
# Read config file (will override defaults above)
[ -r /etc/default/ums2net ] && . /etc/default/ums2net
# this is from madduck on IRC, 2006-07-06
# There should be a better possibility to give daemon error messages
# and/or to log things
log()
{
case "$1" in
[[:digit:]]*) success=$1; shift;;
*) :;;
esac
log_action_begin_msg "$1"; shift
log_action_end_msg ${success:-0} "$*"
}
start () {
if ! pidofproc -p "$PIDFILE" "$DAEMON" >/dev/null; then
start_daemon -p $PIDFILE $DAEMON -c $CONFFILE -P $PIDFILE $OPTIONS
ret=$?
else
log_failure_msg "already running!"
log_end_msg 1
exit 1
fi
return $ret
}
stop () {
SIG="${1:--TERM}"
killproc -p "$PIDFILE" "$DAEMON" "$SIG"
if ! pidofproc -p "$PIDFILE" "$DAEMON" >/dev/null; then
rm -f $PIDFILE
fi
}
status()
{
log_action_begin_msg "checking $DESC"
if pidofproc -p "$PIDFILE" "$DAEMON" >/dev/null; then
log_action_end_msg 0 "$NAME running"
else
if [ -e "$PIDFILE" ]; then
log_action_end_msg 1 "$NAME failed"
exit 1
else
log_action_end_msg 0 "$NAME not running"
exit 3
fi
fi
}
if ! [ -e "$CONFFILE" ]; then
log_failure_msg "Not starting ums2net: Conffile $CONFFILE missing"
log_end_msg 1
exit 1
fi
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
start
log_end_msg 0
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
stop
log_end_msg 0
;;
reload|force-reload)
log_daemon_msg "Reloading $DESC" "$NAME"
stop "-HUP"
log_end_msg 0
;;
restart)
log_daemon_msg "Restarting $DESC" "$NAME"
stop
sleep 1
start
log_end_msg 0
;;
status)
status
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
exit 1
;;
esac
exit 0
|