better usage, install as init script docs
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 16 Mar 2010 23:14:38 +0000 (23:14 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 16 Mar 2010 23:14:38 +0000 (23:14 +0000)
git-svn-id: svn://svn.rot13.org/sysadmin-cookbook@190 191e9f34-6774-4a6d-acfc-7664dacd4a2a

recepies/lxc/lxc-watchdog.sh

index 8c3a77d..d003f2f 100755 (executable)
 #
 # based on Tony Risinger post to lxc-users mailing list
 # http://www.mail-archive.com/lxc-users@lists.sourceforge.net/msg00074.html
+#
+# Install with:
+# ln -sf /srv/sysadmin-cookbook/recepies/lxc/lxc-watchdog.sh /etc/init.d/lxc-watchdog
+# update-rc.d lxc-watchdog defaults
 
 
 which inotifywait >/dev/null || apt-get install inotify-tools
@@ -160,6 +164,11 @@ lxc_log "$name watchdog exited"
 }
 
 
+usage() {
+       echo "Usage: $0 {start|stop|restart|status|boot|disable} [name name ... ]" >&2
+       exit 3
+}
+
 command_on_lxc() {
 command=$1
 shift
@@ -194,8 +203,7 @@ disable)
        echo -n > /var/lib/lxc/$1/on_boot
        ;;
 *)
-       echo "Usage: $0 {start|stop|restart|status}" >&2
-       exit 3
+       usage
        ;;
 
 esac
@@ -203,9 +211,9 @@ esac
 }
 
 command=$1
-shift
-
+test -z "$command" && usage
 test "$command" = "status" && lxc_status && exit
+shift
 
 if [ -z "$1" ] ; then
        ls /var/lib/lxc/*/on_boot | while read path ; do