From 93b9103f7383d400616d222606c294e07b16e1aa Mon Sep 17 00:00:00 2001 From: Lars Müller Date: Sat, 1 Mar 2008 18:30:38 +0000 Subject: Import dnbd* from the former openslx-contrib repo as of revision 92. openslx-contrib is currently read only and will get removed in some days. git-svn-id: http://svn.openslx.org/svn/openslx/contrib/dnbd2/trunk@1592 95ad53e4-c205-0410-b2fa-d234c58c8868 --- init-script/Makefile | 10 +++++++ init-script/dnbd2 | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 init-script/Makefile create mode 100755 init-script/dnbd2 (limited to 'init-script') diff --git a/init-script/Makefile b/init-script/Makefile new file mode 100644 index 0000000..b523ffc --- /dev/null +++ b/init-script/Makefile @@ -0,0 +1,10 @@ +# +# init-script/Makefile +# + +all: + +install: + cp dnbd2 /etc/init.d/ + +clean: diff --git a/init-script/dnbd2 b/init-script/dnbd2 new file mode 100755 index 0000000..e9a67ab --- /dev/null +++ b/init-script/dnbd2 @@ -0,0 +1,84 @@ +#! /bin/bash +# +### BEGIN INIT INFO +# Provides: dnbd2 +# Required-Start: $local_fs $network +# Required-Stop: $local_fs $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: starts and stops the DNBD2 server. +# Description: DNDB2 is a Distributed Network Block Device for +# diskless clients in unicast networks. +### END INIT INFO +# +# Author: Vito Di Leo + +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +USER=dnbd2 +SERVER_NAME=dnbd2-server +SERVER_DESC="DNBD2 Server" + +[ -x "`which $SERVER_NAME`" ] || exit 0 + +. /lib/lsb/init-functions + +if ! (id $USER >/dev/null 2>&1) ; then + log_failure_msg "Please create system user $USER." + exit 0 +fi + +if [ ! -x /usr/bin/pkill ] ; then + log_failure_msg "Please install pkill." + exit 0 +fi + +if [ ! -x /usr/bin/sudo ] ; then + log_failure_msg "Please install sudo." + exit 0 +fi + + +case "$1" in + start) + for FILE in `ls /etc/dnbd2/servers/* 2>/dev/null` ; do + log_begin_msg "Starting $SERVER_DESC ($FILE)..." + sudo -u $USER $SERVER_NAME $FILE + log_end_msg $? + done + ;; + + stop) + log_begin_msg "Stoping $SERVER_DESC"s... + pkill -u $USER $SERVER_NAME + log_end_msg 0 + ;; + + reload|force-reload) + log_begin_msg "Reloading $SERVER_DESC"s... + pkill -SIGHUP -u $USER $SERVER_NAME + log_end_msg 0 + ;; + + restart) + $0 stop + sleep 1 + $0 start + ;; + + status) + PIDS=`pgrep -u $USER $SERVER_NAME` + if [ -n "$PIDS" ] ; then + echo $SERVER_NAME running on pids $PIDS + exit 0 + fi + echo $SERVER_NAME not running. + exit 3 + ;; + + *) + echo "Usage: dnbd2 {start|stop|restart|reload|force-reload}" >&2 + exit 3 + ;; +esac + +exit 0 -- cgit v1.2.3-55-g7522