+setup_inittab() {
+ rootfs=$(lxc_rootfs $1)
+ remove=$2
+ add=$3
+
+ # let container respond to kill -SIGPWR
+ inittab=$rootfs/etc/inittab
+ if test -e $inittab && ! grep "$add" ${inittab} >/dev/null ; then
+ grep -v "$remove" ${inittab} > ${inittab}.new
+ echo $add >> ${inittab}.new
+ mv ${inittab}.new ${inittab}
+ echo "$inittab modified with $add"
+ fi
+}
+
+
+lxc_log() {
+ echo `date +%Y-%m-%dT%H:%M:%S` $*
+}
+
+
+lxc_kill() {
+ name=$1
+ sig=$2
+
+ init_pid=`lxc-ps -C init -o pid | grep "^$name" | cut -d" " -f2-`
+ if [ -z "$init_pid" ] ; then
+ lxc-info -n $name
+ exit 1
+ fi
+ lxc_log "$name kill $sig $init_pid"
+ /bin/kill $sig $init_pid
+}
+
+lxc_stop() {
+ lxc_log "$name stop"
+ lxc_kill $name -SIGPWR
+ lxc-wait -n $name -s STOPPED
+ lxc_log "$name stoped"
+# rm -f /var/lib/lxc/${name}/on_boot
+}
+
+
+lxc_start() {
+ name=$1
+ rootfs=$(lxc_rootfs $1)
+
+ if [ ! -e $rootfs ] ; then
+ echo "ERROR $name rootfs $rootfs not found"
+ return
+ fi
+
+ if ! lxc-info -n $name | grep RUNNING ; then
+ lxc_log "$name start"
+ lxc-start -n $name -o /tmp/${name}.log -d
+ lxc-wait -n $name -s RUNNING
+ lxc-info -n $name
+ test -f /var/lib/lxc/${name}/on_boot || echo $name > /var/lib/lxc/${name}/on_boot
+ fi
+}
+
+lxc_watchdog() {
+name=$1
+rootfs=$(lxc_rootfs $1)