aboutsummaryrefslogtreecommitdiff
path: root/src/nbd/nbd
diff options
context:
space:
mode:
Diffstat (limited to 'src/nbd/nbd')
-rwxr-xr-xsrc/nbd/nbd39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/nbd/nbd b/src/nbd/nbd
new file mode 100755
index 0000000..76d16c7
--- /dev/null
+++ b/src/nbd/nbd
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+PIDFILE="/var/run/nbd-server.pid"
+PID=`cat $PIDFILE 2>/dev/null`
+case "$1" in
+ start)
+ stat_busy "Starting Network Block Device Server"
+ if [ "$PID" = "" ]; then
+ /usr/bin/nbd-server
+ fi
+ if [ "$PID" != "" -o $? -gt 0 ]; then
+ stat_fail
+ else
+ add_daemon nbd
+ stat_done
+ fi
+ ;;
+ stop)
+ stat_busy "Stopping Network Block Device Server"
+ [ ! -z "$PID" ] && kill $PID &> /dev/null
+ rm -f $PIDFILE
+ if [ $? -gt 0 ]; then
+ stat_fail
+ else
+ rm_daemon nbd
+ stat_done
+ fi
+ ;;
+ restart)
+ $0 stop
+ sleep 1
+ $0 start
+ ;;
+ *)
+ echo "usage: $0 {start|stop|restart}"
+esac