| 1 | #!/bin/sh -e |
|---|
| 2 | |
|---|
| 3 | ### BEGIN INIT INFO |
|---|
| 4 | # Provides: sams |
|---|
| 5 | # Required-Start: $local_fs $network $time |
|---|
| 6 | # Required-Stop: |
|---|
| 7 | # Should-Start: $named $mysql $squid |
|---|
| 8 | # Should-Stop: |
|---|
| 9 | # Default-Start: 2 3 4 5 |
|---|
| 10 | # Default-Stop: 0 1 6 |
|---|
| 11 | # Short-Description: Starting sams daemon |
|---|
| 12 | # Description: Squid Account Management System (SAMS) |
|---|
| 13 | # Starting sams management daemon - samsdaemon |
|---|
| 14 | ### END INIT INFO |
|---|
| 15 | # |
|---|
| 16 | # Author: Pavel Vinogradov <Pavel.Vinogradov@nixdev.net> |
|---|
| 17 | # |
|---|
| 18 | # /etc/init.d/sams: start and stop the sams daemon |
|---|
| 19 | |
|---|
| 20 | SAMSPATH=`cat /etc/sams2.conf | grep SAMSPATH | tr "SAMSPATH=" "\0"` |
|---|
| 21 | NAME="sams" |
|---|
| 22 | DAEMON=$SAMSPATH/bin/samsdaemon |
|---|
| 23 | LOCKFILE=/var/lock/samsd |
|---|
| 24 | PIDFILE=/var/run/samsdaemon.pid |
|---|
| 25 | RETVAL=0 |
|---|
| 26 | SAMS_ENABLE=false |
|---|
| 27 | |
|---|
| 28 | test -x $DAEMON || exit 0 |
|---|
| 29 | |
|---|
| 30 | if ! [ -x "/lib/lsb/init-functions" ]; then |
|---|
| 31 | . /lib/lsb/init-functions |
|---|
| 32 | else |
|---|
| 33 | echo "E: /lib/lsb/init-functions not found, lsb-base (>= 3.0-6) needed" |
|---|
| 34 | exit 1 |
|---|
| 35 | fi |
|---|
| 36 | |
|---|
| 37 | . /etc/default/rcS |
|---|
| 38 | |
|---|
| 39 | case "$1" in |
|---|
| 40 | start) |
|---|
| 41 | if "$SAMS_ENABLE"; then |
|---|
| 42 | log_daemon_msg "Starting $NAME daemon" "$NAME" |
|---|
| 43 | if [ -s $PIDFILE ] && kill -0 $(cat $PIDFILE) >/dev/null 2>&1; then |
|---|
| 44 | log_progress_msg "apparently already running" |
|---|
| 45 | log_end_msg 0 |
|---|
| 46 | exit 0 |
|---|
| 47 | fi |
|---|
| 48 | |
|---|
| 49 | start-stop-daemon --start --quiet --background \ |
|---|
| 50 | --pidfile $PIDFILE \ |
|---|
| 51 | --exec $DAEMON |
|---|
| 52 | RETVAL=$? |
|---|
| 53 | [ $RETVAL -eq 0 ] && touch "$LOCKFILE" |
|---|
| 54 | log_end_msg $RETVAL |
|---|
| 55 | else |
|---|
| 56 | [ "VERBOSE" != no ] && log_warning_msg "$NAME daemon not enabled, not starting. Please read /usr/share/doc/sams2/README.Debian" |
|---|
| 57 | fi |
|---|
| 58 | ;; |
|---|
| 59 | |
|---|
| 60 | stop) |
|---|
| 61 | if "$SAMS_ENABLE"; then |
|---|
| 62 | log_daemon_msg "Stopping $NAME daemon" "$NAME" |
|---|
| 63 | start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE |
|---|
| 64 | RETVAL=$? |
|---|
| 65 | [ $RETVAL -eq 0 ] && rm -f "$LOCKFILE" |
|---|
| 66 | log_end_msg $RETVAL |
|---|
| 67 | else |
|---|
| 68 | [ "VERBOSE" != no ] && log_warning_msg "$NAME daemon not enabled, not stoping..." |
|---|
| 69 | fi |
|---|
| 70 | |
|---|
| 71 | ;; |
|---|
| 72 | |
|---|
| 73 | restart|force-reload) |
|---|
| 74 | /etc/init.d/sams stop |
|---|
| 75 | /etc/init.d/sams start |
|---|
| 76 | ;; |
|---|
| 77 | |
|---|
| 78 | *) |
|---|
| 79 | echo "Usage: ${0##*/} {start|stop|restart}" |
|---|
| 80 | RETVAL=1 |
|---|
| 81 | ;; |
|---|
| 82 | esac |
|---|