Files
lcdproc/scripts/debian/lcdproc.lcdvc.init
T

80 lines
1.8 KiB
Bash

#! /bin/sh
### BEGIN INIT INFO
# Provides: lcdvc
# Required-Start: $syslog $local_fs $network $remote_fs
# Required-Stop: $syslog $local_fs $network $remote_fs
# Should-Start: LCDd
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: LCDproc virtual console
# Description: Debian init script for lcdvc, the virtual
# console client in the LCDproc suite
### END INIT INFO
# local variables
PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=$(basename $0 | sed -e 's/^[SK][0-9][0-9]//')
NAME=${NAME:-lcdvc}
DAEMON=/usr/bin/lcdvc
DESC="LCDproc virtual console"
DEFAULTS=/etc/default/$NAME
CONFIGFILE=/etc/lcdproc/$NAME.conf
PIDFILE=/var/run/$NAME.pid
OPTIONS=""
START=no
# Source defaults file; edit that file to configure this script.
if [ -e "${DEFAULTS}" ]; then
. "${DEFAULTS}"
fi
# try to get PID file name from config file
if [ -f "${CONFIGFILE:=/etc/lcdproc/$NAME.conf}" ]; then
PIDFILE=`grep -i '^[:space:]*PidFile[:space:]*=' ${CONFIGFILE} \
| head -n1 \
| cut -d= -f2- \
| sed -e 's,^[:space:]*\(.*\)[:space:]*$,\1,'`
OPTIONS="${OPTIONS} -c ${CONFIGFILE}"
fi
# if necessary set default PID file name
PIDFILE=${PIDFILE:-/var/run/$NAME.pid}
# If we're not to start the daemon, simply exit
if [ "${START}" != "yes" ]; then
exit 0
fi
# installation check
test -x $DAEMON || exit 5
# load LSB 3.x init functions
. /lib/lsb/init-functions
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
start_daemon -p $PIDFILE $DAEMON $OPTIONS
log_end_msg $?
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
killproc -p $PIDFILE $DAEMON
log_end_msg $?
;;
restart|reload|force-reload)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
exit 2
;;
esac
exit 0