/[sysadmin-cookbook]/recepies/lxc/lxc-watchdog.sh
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /recepies/lxc/lxc-watchdog.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 189 by dpavlin, Tue Mar 16 23:05:31 2010 UTC revision 193 by dpavlin, Fri Mar 19 14:11:49 2010 UTC
# Line 16  Line 16 
16  #  #
17  # based on Tony Risinger post to lxc-users mailing list  # based on Tony Risinger post to lxc-users mailing list
18  # http://www.mail-archive.com/lxc-users@lists.sourceforge.net/msg00074.html  # http://www.mail-archive.com/lxc-users@lists.sourceforge.net/msg00074.html
19    #
20    # Install with:
21    # ln -sf /srv/sysadmin-cookbook/recepies/lxc/lxc-watchdog.sh /etc/init.d/lxc-watchdog
22    # update-rc.d lxc-watchdog defaults
23    
24    
25  which inotifywait >/dev/null || apt-get install inotify-tools  which inotifywait >/dev/null || apt-get install inotify-tools
# Line 160  lxc_log "$name watchdog exited" Line 164  lxc_log "$name watchdog exited"
164  }  }
165    
166    
167    usage() {
168            echo "Usage: $0 {start|stop|restart|status|boot|disable} [name name ... ]" >&2
169            exit 3
170    }
171    
172  command_on_lxc() {  command_on_lxc() {
173  command=$1  command=$1
174  shift  shift
# Line 171  case "$command" in Line 180  case "$command" in
180  start)  start)
181          lxc_exists $1          lxc_exists $1
182          cleanup_init_scripts $1          cleanup_init_scripts $1
183          setup_inittab $1 ::power      "p0::powerfail:/sbin/init 0"          setup_inittab $1 ":respawn:/sbin/getty.*tty1"   "c1:12345:respawn:/sbin/getty 38400 tty1 linux"
184          setup_inittab $1 ::ctrlaltdel "p6::ctrlaltdel:/sbin/init 6"          setup_inittab $1 "::power"                      "p0::powerfail:/sbin/init 0"
185            setup_inittab $1 "::ctrlaltdel"                 "p6::ctrlaltdel:/sbin/init 6"
186          lxc_start $1          lxc_start $1
187          # give container 5 seconds to start more than one process          # give container 5 seconds to start more than one process
188          ( sleep 5 ; nohup $0 watchdog $1 >> /tmp/$1.log 2>/dev/null ) &          ( sleep 5 ; nohup $0 watchdog $1 >> /tmp/$1.log 2>/dev/null ) &
# Line 194  disable) Line 204  disable)
204          echo -n > /var/lib/lxc/$1/on_boot          echo -n > /var/lib/lxc/$1/on_boot
205          ;;          ;;
206  *)  *)
207          echo "Usage: $0 {start|stop|restart|status}" >&2          usage
         exit 3  
208          ;;          ;;
209    
210  esac  esac
# Line 203  esac Line 212  esac
212  }  }
213    
214  command=$1  command=$1
215  shift  test -z "$command" && usage
   
216  test "$command" = "status" && lxc_status && exit  test "$command" = "status" && lxc_status && exit
217    shift
218    
219  if [ -z "$1" ] ; then  if [ -z "$1" ] ; then
220          ls /var/lib/lxc/*/on_boot | while read path ; do          ls /var/lib/lxc/*/on_boot | while read path ; do

Legend:
Removed from v.189  
changed lines
  Added in v.193

  ViewVC Help
Powered by ViewVC 1.1.26