docs/etc_init.d/fixbot-nexus
changeset 43 78bc61c677d8
parent 42 ccd6d5632ca0
equal deleted inserted replaced
42:ccd6d5632ca0 43:78bc61c677d8
    14 # Do NOT "set -e"
    14 # Do NOT "set -e"
    15 
    15 
    16 # PATH should only include /usr/* if it runs after the mountnfs.sh script
    16 # PATH should only include /usr/* if it runs after the mountnfs.sh script
    17 PATH=/sbin:/usr/sbin:/bin:/usr/bin
    17 PATH=/sbin:/usr/sbin:/bin:/usr/bin
    18 
    18 
    19 # fixbot stuff
    19 # twisted plugin to run
    20 FIXBOT_NAME=fixbot-nexus
    20 PLUGIN_NAME=fixbot-nexus
    21 # what plugin to run
    21 PLUGIN_DOC="FixBot Nexus component"
    22 TWISTD_PLUGIN=fixbot_nexus
    22 
    23 DESC="FixBot Nexus component"
    23 TWISTD_PIDFILE=/var/run/$PLUGIN_NAME.pid
    24 PIDFILE=/var/run/$FIXBOT_NAME.pid
    24 
    25 SCRIPTNAME=/etc/init.d/$FIXBOT_NAME
       
    26 # custom arguments to twistd(1)
    25 # custom arguments to twistd(1)
    27 TWISTD_ARGS=
    26 TWISTD_ARGS=
    28 # custom arguments to fixbot, see `twistd fixbot_nexus --help`
    27 # custom arguments to fixbot, see `twistd fixbot_nexus --help`
    29 FIXBOT_ARGS=
    28 PLUGIN_ARGS=
    30 
    29 
    31 
    30 
    32 # twistd stuff
    31 # the daemon we run is twistd
    33 DAEMON_NAME=twistd
    32 DAEMON_NAME=twistd
    34 DAEMON=/usr/bin/$DAEMON_NAME
    33 DAEMON=/usr/bin/$DAEMON_NAME
    35 
    34 
    36 # Exit if the package is not installed
    35 # Exit if the package is not installed
    37 [ -x "$DAEMON" ] || exit 0
    36 [ -x "$DAEMON" ] || exit 0
    38 
    37 
    39 # Read configuration variable file if it is present
    38 # Read configuration variable file if it is present
    40 [ -r /etc/default/$FIXBOT_NAME ] && . /etc/default/$FIXBOT_NAME
    39 [ -r /etc/default/$PLUGIN_NAME ] && . /etc/default/$PLUGIN_NAME
    41 
    40 
    42 # what arguments we run with
    41 # what arguments we run with
    43 DAEMON_ARGS="--pidfile=$PIDFILE $TWISTD_ARGS $TWISTD_PLUGIN $FIXBOT_ARGS"
    42 DAEMON_ARGS="--pidfile=$PIDFILE $TWISTD_ARGS $PLUGIN_NAME $PLUGIN_ARGS"
    44 
    43 
    45 # Load the VERBOSE setting and other rcS variables
    44 # Load the VERBOSE setting and other rcS variables
    46 . /lib/init/vars.sh
    45 . /lib/init/vars.sh
    47 
    46 
    48 # Define LSB log_* functions.
    47 # Define LSB log_* functions.
   101 	#
   100 	#
   102 	# If the daemon can reload its configuration without
   101 	# If the daemon can reload its configuration without
   103 	# restarting (for example, when it is sent a SIGHUP),
   102 	# restarting (for example, when it is sent a SIGHUP),
   104 	# then implement that here.
   103 	# then implement that here.
   105 	#
   104 	#
   106 	start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME_DAEMON
   105 	start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $DAEMON_NAME
   107 	return 0
   106 	return 0
   108 }
   107 }
   109 
   108 
   110 case "$1" in
   109 case "$1" in
   111   start)
   110   start)
   112 	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$FIXBOT_NAME"
   111 	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $PLUGIN_DESC" "$PLUGIN_NAME"
   113 	do_start
   112 	do_start
   114 	case "$?" in
   113 	case "$?" in
   115 		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
   114 		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
   116 		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
   115 		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
   117 	esac
   116 	esac
   118 	;;
   117 	;;
   119   stop)
   118   stop)
   120 	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$FIXBOT_NAME"
   119 	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $PLUGIN_DESC" "$PLUGIN_NAME"
   121 	do_stop
   120 	do_stop
   122 	case "$?" in
   121 	case "$?" in
   123 		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
   122 		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
   124 		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
   123 		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
   125 	esac
   124 	esac
   136   restart|force-reload)
   135   restart|force-reload)
   137 	#
   136 	#
   138 	# If the "reload" option is implemented then remove the
   137 	# If the "reload" option is implemented then remove the
   139 	# 'force-reload' alias
   138 	# 'force-reload' alias
   140 	#
   139 	#
   141 	log_daemon_msg "Restarting $DESC" "$FIXBOT_NAME"
   140 	log_daemon_msg "Restarting $PLUGIN_DESC" "$PLUGIN_NAME"
   142 	do_stop
   141 	do_stop
   143 	case "$?" in
   142 	case "$?" in
   144 	  0|1)
   143 	  0|1)
   145 		do_start
   144 		do_start
   146 		case "$?" in
   145 		case "$?" in
   154 		log_end_msg 1
   153 		log_end_msg 1
   155 		;;
   154 		;;
   156 	esac
   155 	esac
   157 	;;
   156 	;;
   158   *)
   157   *)
   159 	#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
   158 	#echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
   160 	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
   159 	echo "Usage: $0 {start|stop|restart|force-reload}" >&2
   161 	exit 3
   160 	exit 3
   162 	;;
   161 	;;
   163 esac
   162 esac
   164 
   163 
   165 :
   164 :