Merge branch 'master' of github.com:john30/ebusd
This commit is contained in:
@@ -3,3 +3,14 @@
|
|||||||
|
|
||||||
# Options to pass to ebusd (run "ebusd -?" for more info):
|
# Options to pass to ebusd (run "ebusd -?" for more info):
|
||||||
EBUSD_OPTS="--scanconfig"
|
EBUSD_OPTS="--scanconfig"
|
||||||
|
|
||||||
|
# In order to run multiple ebusd instances, simply define several EBUSD_OPTS
|
||||||
|
# with a unique suffix for each.
|
||||||
|
# Recommended is using a number as suffix for all EBUSD_OPTS settings.
|
||||||
|
# That number can then be used as additional "instance" parameter to the init.d
|
||||||
|
# script in order to start/stop an individual ebusd instance instead of all
|
||||||
|
# instances.
|
||||||
|
# Example (uncomment the EBUSD_OPTS above):
|
||||||
|
#EBUSD_OPTS1="--scanconfig -d /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A50285BI-if00-port0 -p 8888 -l /var/log/ebusd1.log"
|
||||||
|
#EBUSD_OPTS2="--scanconfig -d /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A900acTF-if00-port0 -p 8889 -l /var/log/ebusd2.log"
|
||||||
|
#EBUSD_OPTS3="--scanconfig -d /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A900beCG-if00-port0 -p 8890 -l /var/log/ebusd3.log"
|
||||||
Executable → Regular
+68
-13
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
### BEGIN INIT INFO
|
### BEGIN INIT INFO
|
||||||
# Provides: ebusd
|
# Provides: ebusd
|
||||||
@@ -10,7 +10,8 @@
|
|||||||
### END INIT INFO
|
### END INIT INFO
|
||||||
|
|
||||||
DAEMON=/usr/bin/ebusd
|
DAEMON=/usr/bin/ebusd
|
||||||
PIDFILE=/var/run/ebusd.pid
|
PIDFILE_PREFIX=/var/run/ebusd
|
||||||
|
PIDFILE_SUFFIX=.pid
|
||||||
|
|
||||||
. /lib/lsb/init-functions
|
. /lib/lsb/init-functions
|
||||||
[ -r /etc/default/ebusd ] && . /etc/default/ebusd
|
[ -r /etc/default/ebusd ] && . /etc/default/ebusd
|
||||||
@@ -20,27 +21,81 @@ if [ ! -x $DAEMON ]; then
|
|||||||
exit 5
|
exit 5
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ALL_OPTS=${!EBUSD_OPTS*}
|
||||||
|
if [ ${#ALL_OPTS[@]} -lt 1 ]; then
|
||||||
|
ALL_OPTS[0]=EBUSD_OPTS
|
||||||
|
fi
|
||||||
|
instance="EBUSD_OPTS$2"
|
||||||
|
instance=${!instance}
|
||||||
|
|
||||||
|
start_instance () {
|
||||||
|
local opts suffix
|
||||||
|
opts=$1
|
||||||
|
shift
|
||||||
|
suffix="${opts#EBUSD_OPTS}"
|
||||||
|
log_daemon_msg "Starting ebusd${suffix}" ebusd
|
||||||
|
pidfile=$PIDFILE_PREFIX${suffix}$PIDFILE_SUFFIX
|
||||||
|
start-stop-daemon --start --quiet --oknodo --pidfile $pidfile --exec $DAEMON -- --pidfile $pidfile ${!opts}
|
||||||
|
log_end_msg $?
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_instance () {
|
||||||
|
local opts suffix
|
||||||
|
opts=$1
|
||||||
|
shift
|
||||||
|
suffix="${opts#EBUSD_OPTS}"
|
||||||
|
log_daemon_msg "Stopping ebusd${suffix}" ebusd
|
||||||
|
pidfile=$PIDFILE_PREFIX${suffix}$PIDFILE_SUFFIX
|
||||||
|
start-stop-daemon --stop --quiet --oknodo --pidfile $pidfile
|
||||||
|
log_end_msg $?
|
||||||
|
rm -f $PIDFILE_PREFIX${suffix}$PIDFILE_SUFFIX
|
||||||
|
}
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
start)
|
start)
|
||||||
log_daemon_msg "Starting ebusd" "ebusd"
|
if [ -z "$2" ]; then
|
||||||
start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON -- $EBUSD_OPTS
|
for opts in $ALL_OPTS; do
|
||||||
status=$?
|
start_instance $opts
|
||||||
log_end_msg $status
|
done
|
||||||
|
elif [ -z "$instance" ]; then
|
||||||
|
log_failure_msg "ebusd$2 is not configured"
|
||||||
|
else
|
||||||
|
start_instance EBUSD_OPTS$2
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
log_daemon_msg "Stopping ebusd" "ebusd"
|
if [ -z "$2" ]; then
|
||||||
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
|
for opts in $ALL_OPTS; do
|
||||||
log_end_msg $?
|
stop_instance $opts
|
||||||
rm -f $PIDFILE
|
done
|
||||||
|
else
|
||||||
|
if [ -z "$instance" ]; then
|
||||||
|
log_warning_msg "ebusd$2 is not configured"
|
||||||
|
fi
|
||||||
|
stop_instance EBUSD_OPTS$2
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
restart|force-reload)
|
restart|force-reload)
|
||||||
$0 stop && sleep 2 && $0 start
|
ARGS=($@)
|
||||||
|
$0 stop ${ARGS[@]:1} && sleep 2 && $0 start ${ARGS[@]:1}
|
||||||
;;
|
;;
|
||||||
status)
|
status)
|
||||||
status_of_proc $DAEMON "ebusd"
|
if [ -z "$2" ]; then
|
||||||
|
for opts in $ALL_OPTS; do
|
||||||
|
suffix=${opts#EBUSD_OPTS}
|
||||||
|
pidfile=$PIDFILE_PREFIX$suffix$PIDFILE_SUFFIX
|
||||||
|
status_of_proc -p $pidfile $DAEMON ebusd$suffix
|
||||||
|
done
|
||||||
|
else
|
||||||
|
if [ -z "$instance" ]; then
|
||||||
|
log_warning_msg "ebusd$2 is not configured"
|
||||||
|
fi
|
||||||
|
pidfile=$PIDFILE_PREFIX$2$PIDFILE_SUFFIX
|
||||||
|
status_of_proc -p $pidfile $DAEMON ebusd$2
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0 {start|stop|restart|force-reload|status}"
|
echo "Usage: $0 {start|stop|restart|force-reload|status} [instance]"
|
||||||
exit 2
|
exit 2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user