#!/bin/bash # THIS IS A DRAFT # http://refspecs.linux-foundation.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html function usage { echo "${0##*/} " exit 1 } function fail { echo $@ exit 1 } [[ -z $2 ]] && usage res=$1 action=$2 drbdadm status $res >/dev/null || fail DRBD resource $res not found tmp=`drbdadm role $res` if [[ $action = start ]]; then [[ $tmp = Primary ]] && exit 0 drbdadm primary $res && echo started elif [[ $action = monitor ]]; then [[ $tmp = Primary ]] && echo OK || exit 1 elif [[ $action = stop ]]; then [[ $tmp = Secondary ]] && exit 0 drbdadm secondary $res && echo stopped # and check it becomes secondary? else usage fi