diff options
author | Daniel Baumann <daniel@debian.org> | 2024-12-12 22:18:22 +0100 |
---|---|---|
committer | Daniel Baumann <daniel@debian.org> | 2024-12-12 22:37:18 +0100 |
commit | d7dba196f14971b34d3a5558ef64f9765aa6a9c4 (patch) | |
tree | 5cd92190c79ef2be590218b93c5206f8ca9b749e /src/dsc.sh | |
parent | Initial commit. (diff) | |
download | dsc-d7dba196f14971b34d3a5558ef64f9765aa6a9c4.tar.xz dsc-d7dba196f14971b34d3a5558ef64f9765aa6a9c4.zip |
Adding upstream version 2.15.2.
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to 'src/dsc.sh')
-rw-r--r-- | src/dsc.sh | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/src/dsc.sh b/src/dsc.sh new file mode 100644 index 0000000..7545707 --- /dev/null +++ b/src/dsc.sh @@ -0,0 +1,102 @@ +#!/bin/sh + +# +# dsc_enable=YES +# dsc_instances="node1 node2" +# + +. /etc/rc.subr + +name="dsc" +rcvar=`set_rcvar` +load_rc_config $name + +case "$dsc_enable" in +[Yy][Ee][Ss]) + ;; +*) + exit 0 +esac + +PIDDIR=/var/run +PREFIX=/usr/local/dsc + +get_pid() { + instance=$1 + if test -f $PIDDIR/dsc-$instance.pid ; then + PID=`cat $PIDDIR/dsc-$instance.pid` + else + PID='' + fi +} + +do_status() { + instance=$1 + if test ! -n "$PID" ; then + echo "dsc-$instance is not running" + false + elif kill -0 $PID 2>/dev/null ; then + echo "dsc-$instance is running as PID $PID" + else + echo "dsc-$instance is not running" + false + fi +} + +do_start() { + instance=$1 + if test -n "$PID" ; then + if kill -0 $PID 2>/dev/null ; then + echo "dsc-$instance is already running as PID $PID" + true + return + fi + fi + if test -s $PREFIX/etc/dsc-$instance.conf ; then + echo "Starting dsc-$instance" + $PREFIX/bin/dsc $PREFIX/etc/dsc-$instance.conf + else + echo "$PREFIX/etc/dsc-$instance.conf not found" + false + fi +} + +do_stop() { + if test -n "$PID" ; then + echo "Stopping dsc-$instance" + kill -INT $PID + else + echo "dsc-$instance is not running" + exit 0; + fi +} + + +action=$1 ; shift + +if test $# -eq 0 -a -n "$dsc_instances" ; then + set $dsc_instances +fi + +for instance ; do + get_pid $instance + case $action in + start|faststart) + do_start $instance + ;; + stop) + do_stop $instance + ;; + restart) + do_stop $instance + do_start $instance + ;; + status) + do_status $instance + ;; + *) + echo "unknown action: $action" + exit 1 + ;; + esac +done |