hlog.init
branchfoerste
changeset 61 9fc4a8acb237
equal deleted inserted replaced
60:e84b06852c25 61:9fc4a8acb237
       
     1 #! /bin/sh
       
     2 ### BEGIN INIT INFO
       
     3 # Provides:          skeleton
       
     4 # Required-Start:    $remote_fs $syslog
       
     5 # Required-Stop:     $remote_fs $syslog
       
     6 # Default-Start:     2 3 4 5
       
     7 # Default-Stop:      0 1 6
       
     8 # Short-Description: hlog
       
     9 # Description:       HTTP(S) access to some (log) file
       
    10 ### END INIT INFO
       
    11 
       
    12 # Author: Matthias Förste <foerste@schlittermann.de>
       
    13 
       
    14 # Do NOT "set -e"
       
    15 
       
    16 # PATH should only include /usr/* if it runs after the mountnfs.sh script
       
    17 PATH=/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin
       
    18 DESC="HTTP(S) access to some (log) file"
       
    19 NAME=hlog
       
    20 DAEMON=/usr/local/bin/$NAME
       
    21 DAEMON_ARGS=""
       
    22 PIDFILE=/var/run/$NAME.pid
       
    23 SCRIPTNAME=/etc/init.d/$NAME
       
    24 
       
    25 # Exit if the package is not installed
       
    26 [ -x "$DAEMON" ] || exit 0
       
    27 
       
    28 # Read configuration variable file if it is present
       
    29 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
       
    30 
       
    31 # Load the VERBOSE setting and other rcS variables
       
    32 . /lib/init/vars.sh
       
    33 
       
    34 # Define LSB log_* functions.
       
    35 # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
       
    36 # and status_of_proc is working.
       
    37 . /lib/lsb/init-functions
       
    38 
       
    39 #
       
    40 # Function that starts the daemon/service
       
    41 #
       
    42 do_start()
       
    43 {
       
    44 	# Return
       
    45 	#   0 if daemon has been started
       
    46 	#   1 if daemon was already running
       
    47 	#   2 if daemon could not be started
       
    48 	$DAEMON $DAEMON_ARGS
       
    49 }
       
    50 
       
    51 #
       
    52 # Function that stops the daemon/service
       
    53 #
       
    54 do_stop()
       
    55 {
       
    56 	# Return
       
    57 	#   0 if daemon has been stopped
       
    58 	#   1 if daemon was already stopped
       
    59 	#   2 if daemon could not be stopped
       
    60 	#   other if a failure occurred
       
    61 	$DAEMON $DAEMON_ARGS -k
       
    62 }
       
    63 
       
    64 case "$1" in
       
    65   start)
       
    66 	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
       
    67 	do_start
       
    68 	case "$?" in
       
    69 		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
       
    70 		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
       
    71 	esac
       
    72 	;;
       
    73   stop)
       
    74 	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
       
    75 	do_stop
       
    76 	case "$?" in
       
    77 		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
       
    78 		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
       
    79 	esac
       
    80 	;;
       
    81   status)
       
    82 	status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
       
    83 	;;
       
    84   #reload|force-reload)
       
    85 	#
       
    86 	# If do_reload() is not implemented then leave this commented out
       
    87 	# and leave 'force-reload' as an alias for 'restart'.
       
    88 	#
       
    89 	#log_daemon_msg "Reloading $DESC" "$NAME"
       
    90 	#do_reload
       
    91 	#log_end_msg $?
       
    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|reload|force-reload}" >&2
       
   117 	echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
       
   118 	exit 3
       
   119 	;;
       
   120 esac
       
   121 
       
   122 :