make container name first argument
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 16 Mar 2010 14:52:56 +0000 (14:52 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 16 Mar 2010 14:52:56 +0000 (14:52 +0000)
git-svn-id: svn://svn.rot13.org/sysadmin-cookbook@177 191e9f34-6774-4a6d-acfc-7664dacd4a2a

recepies/lxc/lxc-watchdog.sh

index 04a0d98..7962916 100755 (executable)
@@ -1,21 +1,22 @@
-#!/bin/bash -x
+#!/bin/bash
 
 # based on Tony Risinger code from lxc-users
 # http://www.mail-archive.com/lxc-users@lists.sourceforge.net/msg00074.html
 
-which inotifywait || apt-get install inotify-tools
+which inotifywait >/dev/null || apt-get install inotify-tools
 
-name=llin
+name=$1
 
-#lxc-info -n $name | grep RUNNING && exit
+if [ ! -e /var/lib/lxc/$name/config ] ; then
+       echo "Usage: $0 name"
+       ls /var/lib/lxc/*/config | cut -d/ -f5
+       exit 1
+fi
 
 rootfs=`grep lxc.rootfs /var/lib/lxc/$name/config | cut -d= -f2`
 echo "$name rootfs $rootfs"
 
-# fix lxc-stop which remounts ro
-mount /mnt/llin -o remount,rw
-
-lxc-start -d -n $name -o /tmp/${name}.log
+lxc-info -n $name | grep RUNNING || lxc-start -d -n $name -o /tmp/${name}.log && echo "$name start"
 
 while true; do
        # time of 5 minutes on it JUST IN CASE...