40 |
grep '^ *lxc\.rootfs *=' "/var/lib/lxc/$1/config" | cut -d= -f2 | sed 's/^ *//' |
grep '^ *lxc\.rootfs *=' "/var/lib/lxc/$1/config" | cut -d= -f2 | sed 's/^ *//' |
41 |
} |
} |
42 |
|
|
43 |
|
lxc_hostname() { |
44 |
|
inside=`cat $(lxc_rootfs $1)/etc/hostname` |
45 |
|
config=`grep lxc.utsname /var/lib/lxc/$name/config | cut -d= -f2` |
46 |
|
echo "$config [$inside]"; |
47 |
|
} |
48 |
|
|
49 |
|
lxc_ip() { |
50 |
|
( grep lxc.network.ipv4 /var/lib/lxc/$name/config | grep -v '^#' | cut -d= -f2 || \ |
51 |
|
grep address $(lxc_rootfs $name)/etc/network/interfaces | grep -v '^#' | sed 's/.*address //' ) | \ |
52 |
|
head -1 | \ |
53 |
|
sed -e 's/ *//g' -e 's/\/.*$//' |
54 |
|
} |
55 |
|
|
56 |
lxc_status() { |
lxc_status() { |
57 |
( find /var/lib/lxc/ -name "config" | cut -d/ -f5 | sort -u | xargs -i lxc-info -n {} | sed "s/'//g" | while read name is status ; do |
( find /var/lib/lxc/ -name "config" | cut -d/ -f5 | sort -u | xargs -i lxc-info -n {} | sed "s/'//g" | while read name is status ; do |
58 |
boot="-" |
boot="-" |
|
hostname=`cat $(lxc_rootfs $name)/etc/hostname` |
|
|
ip=`grep address $(lxc_rootfs $name)/etc/network/interfaces | sed 's/.*address //'` |
|
59 |
test -s /var/lib/lxc/$name/on_boot && boot="boot" |
test -s /var/lib/lxc/$name/on_boot && boot="boot" |
60 |
echo "$name $status $boot $(lxc_rootfs $name) $ip $hostname" |
echo "$name $status $boot $(lxc_rootfs $name) $(lxc_ip $name) $(lxc_hostname $name)" |
61 |
done ) | column -t |
done ) | column -t |
62 |
} |
} |
63 |
|
|
66 |
rootfs=$(lxc_rootfs $1) |
rootfs=$(lxc_rootfs $1) |
67 |
|
|
68 |
ls \ |
ls \ |
69 |
|
$rootfs/etc/rc?.d/*checkroot* \ |
70 |
$rootfs/etc/rc?.d/*umountfs \ |
$rootfs/etc/rc?.d/*umountfs \ |
71 |
$rootfs/etc/rc?.d/*umountroot \ |
$rootfs/etc/rc?.d/*umountroot \ |
72 |
$rootfs/etc/rc?.d/*hwclock* \ |
$rootfs/etc/rc?.d/*hwclock* \ |
74 |
2>/dev/null | xargs -i rm -v {} |
2>/dev/null | xargs -i rm -v {} |
75 |
|
|
76 |
echo $1 > $rootfs/etc/hostname |
echo $1 > $rootfs/etc/hostname |
77 |
|
grep $1 $rootfs/etc/hosts || echo "$(lxc_ip $1) $1" >> $rootfs/etc/hosts |
78 |
} |
} |
79 |
|
|
80 |
|
|
146 |
while true; do |
while true; do |
147 |
vps_utmp=${rootfs}/var/run/utmp |
vps_utmp=${rootfs}/var/run/utmp |
148 |
tasks=`wc -l < /cgroup/${name}/tasks` |
tasks=`wc -l < /cgroup/${name}/tasks` |
149 |
|
stop_on=1 # init |
150 |
|
sulogins=`lxc-ps --name backuppc | grep sulogin | wc -l` |
151 |
|
if [ "$sulogins" -gt 0 ] ; then |
152 |
|
stop_on=`expr $stop_on + $sulogins` |
153 |
|
fi |
154 |
|
|
155 |
test -z "$tasks" && exit 1 |
test -z "$tasks" && exit 1 |
156 |
if [ "$tasks" -eq 1 ]; then |
if [ "$tasks" -eq $stop_on ]; then |
157 |
|
|
158 |
runlevel="$(runlevel ${vps_utmp})" |
runlevel="$(runlevel ${vps_utmp})" |
159 |
lxc_log "$name runlevel $runlevel" |
lxc_log "$name runlevel $runlevel" |
181 |
;; |
;; |
182 |
esac |
esac |
183 |
else |
else |
184 |
lxc_log "$name $tasks tasks" |
lxc_log "$name $tasks tasks $sulogins console" |
185 |
fi |
fi |
186 |
|
|
187 |
# time of 5 minutes on it JUST IN CASE... |
# time of 5 minutes on it JUST IN CASE... |