summaryrefslogtreecommitdiff
path: root/community-testing/drbd/drbd.rc
diff options
context:
space:
mode:
authorroot <root@rshg054.dnsready.net>2012-08-23 00:03:08 +0000
committerroot <root@rshg054.dnsready.net>2012-08-23 00:03:08 +0000
commitc40883520f917311c212dc4a22e86be30cef658f (patch)
treeef8badd68c32564574e9b9317db1884fdaf98d2f /community-testing/drbd/drbd.rc
parent297a042ac9a7bbd2b18a9551f5fa4fe43faf53b2 (diff)
Thu Aug 23 00:03:08 UTC 2012
Diffstat (limited to 'community-testing/drbd/drbd.rc')
-rw-r--r--community-testing/drbd/drbd.rc58
1 files changed, 58 insertions, 0 deletions
diff --git a/community-testing/drbd/drbd.rc b/community-testing/drbd/drbd.rc
new file mode 100644
index 000000000..b8b196e4b
--- /dev/null
+++ b/community-testing/drbd/drbd.rc
@@ -0,0 +1,58 @@
+#!/bin/bash
+# Written by Sébastien Luttringer
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+DRBDADM='/usr/sbin/drbdadm'
+PROC_DRBD='/proc/drbd'
+
+check_config() {
+ # check if module is loaded
+ if [[ ! -e $PROC_DRBD ]]; then
+ echo "Missing $PROC_DRBD. Try to load drbd module!"
+ stat_fail
+ exit 1
+ fi
+ # check if config is correct
+ if ! $DRBDADM dump &>/dev/null; then
+ echo 'Invalid configuration'
+ stat_fail
+ exit 1
+ fi
+}
+
+case "$1" in
+ start)
+ stat_busy 'Starting DRBD resources'
+ # check module and config
+ check_config
+ # load config
+ $DRBDADM adjust all 2>/dev/null || { stat_fail; exit 1; }
+ # user interruptible version of wait-connect all
+ $DRBDADM wait-con-int 2>/dev/null || { stat_fail; exit 1; }
+ # become primary if configured
+ $DRBDADM sh-b-pri all 2>/dev/nul l|| { stat_fail; exit 1; }
+ add_daemon drbd
+ stat_done
+ ;;
+ stop)
+ stat_busy 'Stopping DRBD resources'
+ # check module and config
+ check_config
+ # disconnect and detach all resources
+ $DRBDADM down all 2>/dev/null || { stat_fail; exit 1; }
+ rm_daemon drbd
+ stat_done
+ ;;
+ restart)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo "usage: $0 {start|stop|restart}"
+esac
+
+exit 0
+
+# vim:set ts=2 sw=2 ft=sh et: