init.d.in
changeset 23 31d7a4ab5910
parent 22 9d0f18677fec
child 30 c22ca6b1ad5c
equal deleted inserted replaced
22:9d0f18677fec 23:31d7a4ab5910
       
     1 #! /bin/sh
       
     2 ### BEGIN INIT INFO
       
     3 # Provides:          tele-watch
       
     4 # Required-Start:    $local_fs $remote_fs
       
     5 # Required-Stop:     $local_fs $remote_fs
       
     6 # Default-Start:     2 3 4 5
       
     7 # Default-Stop:      0 1 6
       
     8 # Short-Description: watcher for dtele home directory
       
     9 # Description:       tele-watch watches a list of directories
       
    10 #                    and enforces the dtele directory policy
       
    11 ### END INIT INFO
       
    12 
       
    13 # Author: Heiko Schlittermann <hs@schlittermann.de>
       
    14 #
       
    15 # Please remove the "Author" lines above and replace them
       
    16 # with your own name if you copy and modify this script.
       
    17 
       
    18 # Do NOT "set -e"
       
    19 
       
    20 # PATH should only include /usr/* if it runs after the mountnfs.sh script
       
    21 PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin
       
    22 DESC="Tele-Watch"
       
    23 NAME=tele-watch
       
    24 DAEMON=__sbindir__/$NAME
       
    25 #DAEMON_ARGS=""
       
    26 PIDFILE=/var/run/$NAME.pid
       
    27 SCRIPTNAME=/etc/init.d/$NAME
       
    28 
       
    29 # Exit if the package is not installed
       
    30 [ -x "$DAEMON" ] || exit 0
       
    31 
       
    32 # Read configuration variable file if it is present
       
    33 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
       
    34 
       
    35 # Load the VERBOSE setting and other rcS variables
       
    36 . /lib/init/vars.sh
       
    37 
       
    38 # Define LSB log_* functions.
       
    39 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
       
    40 . /lib/lsb/init-functions
       
    41 
       
    42 #
       
    43 # Function that starts the daemon/service
       
    44 #
       
    45 do_start()
       
    46 {
       
    47 	test -n "$WATCHPOINTS" || return 1
       
    48 	# Return
       
    49 	#   0 if daemon has been started
       
    50 	#   0 if daemon was already running
       
    51 	#   2 if daemon could not be started
       
    52 	PID=$(pidof $NAME) && return 0
       
    53 	
       
    54 	if [ ! $PID ]; then
       
    55 		$DAEMON "$WATCHPOINTS" || return 2
       
    56 	fi
       
    57 	return 0
       
    58 }
       
    59 
       
    60 #
       
    61 # Function that stops the daemon/service
       
    62 #
       
    63 do_stop()
       
    64 {
       
    65 	# Return
       
    66 	#   0 if daemon has been stopped
       
    67 	#   0 if daemon was already stopped
       
    68 	#   2 if daemon could not be stopped
       
    69 	#   other if a failure occurred
       
    70 	PID=$(pidof $NAME) || return 0
       
    71 
       
    72 	$DAEMON --kill || return 2
       
    73 	return 0
       
    74 }
       
    75 
       
    76 case "$1" in
       
    77   start)
       
    78 	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
       
    79 	do_start
       
    80 	case "$?" in
       
    81 		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
       
    82 		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
       
    83 	esac
       
    84 	;;
       
    85   stop)
       
    86 	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
       
    87 	do_stop
       
    88 	case "$?" in
       
    89 		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
       
    90 		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
       
    91 	esac
       
    92 	;;
       
    93   restart|force-reload)
       
    94 	#
       
    95 	# If the "reload" option is implemented then remove the
       
    96 	# 'force-reload' alias
       
    97 	#
       
    98 	log_daemon_msg "Restarting $DESC" "$NAME"
       
    99 	do_stop
       
   100 	case "$?" in
       
   101 	  0|1)
       
   102 		do_start
       
   103 		case "$?" in
       
   104 			0) log_end_msg 0 ;;
       
   105 			1) log_end_msg 1 ;; # Old process is still running
       
   106 			*) log_end_msg 1 ;; # Failed to start
       
   107 		esac
       
   108 		;;
       
   109 	  *)
       
   110 	  	# Failed to stop
       
   111 		log_end_msg 1
       
   112 		;;
       
   113 	esac
       
   114 	;;
       
   115   *)
       
   116 	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
       
   117 	exit 3
       
   118 	;;
       
   119 esac
       
   120 
       
   121 :