#!/bin/bash # # drbdlinksclean Clean up drbdlinks links on system boot or shutdown # # chkconfig: - 74 06 # description: Calls drbdlinks on initial system boot and shutdown to make \ # sure that any links set up by drbdlinks are cleaned up when \ # drbd is not running. # config: /etc/drbdlinks.conf ### BEGIN INIT INFO # Provides: drbdlinksclean # Required-Start: $local_fs $remote_fs # Required-Stop: $local_fs $remote_fs # Short-Description: Clean up drbdlinks links on system boot or shutdown # Description: Calls drbdlinks on initial system boot and shutdown to make # sure that any links set up by drbdlinks are cleaned up when # drbd is not running. ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions RETVAL=0 FOUNDFILE=0 drbdlinks=/usr/sbin/drbdlinks [ -f /etc/drbdlinks.conf ] && FOUNDFILE=1 for FILE in /var/run/drbdlinks/configs-to-clean/*; do if [ -f "$FILE" ]; then FOUNDFILE=1 break fi done if [ $FOUNDFILE -ne 1 ]; then echo "No /etc/drbdlinks.conf file, aborting." exit 1 fi # See how we were called. case "$1" in start|stop|restart|force-reload) echo -n "Cleaning up drbdlinks.conf links..." # Main drbdlinks.conf file if [ -f /etc/drbdlinks.conf ]; then if grep -q '^mountpoint(' /etc/drbdlinks.conf; then $drbdlinks stop RETVAL=$? else echo "No mountpoint found in /etc/drbdlinks.conf, skipping." fi fi # clean up any supplemental config files for FILE in /var/run/drbdlinks/configs-to-clean/*; do if [ -f "$FILE" ]; then echo -n "Cleaning up '${FILE##*/}' links..." $drbdlinks --config-file "$FILE" stop || RETVAL=$? fi done [ $RETVAL -eq 0 ] && echo_success || echo_failure echo ;; status) $drbdlinks status ;; *) echo $"Usage: drbdlinksclean {start|stop|status|restart|force-reload}" RETVAL=1 ;; esac exit $RETVAL