16 |
rootfs=`grep lxc.rootfs /var/lib/lxc/$name/config | cut -d= -f2` |
rootfs=`grep lxc.rootfs /var/lib/lxc/$name/config | cut -d= -f2` |
17 |
echo "$name rootfs $rootfs" |
echo "$name rootfs $rootfs" |
18 |
|
|
19 |
|
|
20 |
# cleanup init scripts which don't work in containers |
# cleanup init scripts which don't work in containers |
21 |
ls $rootfs/etc/rc?.d/*umountfs 2>/dev/null | xargs -i rm -v {} |
ls \ |
22 |
ls $rootfs/etc/rc?.d/*umountroot 2>/dev/null | xargs -i rm -v {} |
$rootfs/etc/rc?.d/*umountfs \ |
23 |
ls $rootfs/etc/rc?.d/*hwclock* 2>/dev/null | xargs -i rm -v {} |
$rootfs/etc/rc?.d/*umountroot \ |
24 |
|
$rootfs/etc/rc?.d/*hwclock* \ |
25 |
|
2>/dev/null | xargs -i rm -v {} |
26 |
|
|
27 |
|
|
28 |
|
# let container respond to kill -SIGPWR |
29 |
|
inittab=$rootfs/etc/inittab |
30 |
|
powerfail="pw::powerfail:/sbin/init 0" |
31 |
|
if ! grep "$powerfail" ${inittab} >/dev/null ; then |
32 |
|
grep -v ::power ${inittab} > ${inittab}.new |
33 |
|
echo $powerfail >> ${inittab}.new |
34 |
|
mv ${inittab}.new ${inittab} |
35 |
|
echo "$initab modified" |
36 |
|
fi |
37 |
|
|
38 |
|
|
39 |
|
if [ "$2" == "stop" ] ; then |
40 |
|
echo "$name stop" |
41 |
|
kill -SIGPWR `head -1 /cgroup/$name/tasks` |
42 |
|
lxc-wait -n $name -s STOPPED |
43 |
|
exit |
44 |
|
fi |
45 |
|
|
46 |
|
|
47 |
lxc-info -n $name | grep RUNNING || lxc-start -d -n $name -o /tmp/${name}.log && echo "$name start" |
if ! lxc-info -n $name | grep RUNNING ; then |
48 |
|
echo "$name start" |
49 |
|
lxc-start -n $name -o /tmp/${name}.log -d |
50 |
|
lxc-wait -n $name -s RUNNING |
51 |
|
lxc-info -n $name |
52 |
|
fi |
53 |
|
|
54 |
while true; do |
while true; do |
55 |
# time of 5 minutes on it JUST IN CASE... |
# time of 5 minutes on it JUST IN CASE... |