6 write_lxc_is_container() {
9 # This program is written by /etc/rc.d/rc.sysinit.
10 # It simply reports whether or not this system is in an lxc container
14 echo "# This is an LXC container"
15 echo '[ "$1" = "-v" ] && echo '"$_LXC_CONTAINER"
18 echo "# This is NOT an LXC container"
19 echo '[ "$1" = "-v" ] && echo none'
24 fail() { echo "FAIL:" "$@"; }
25 warn() { echo "WARN:" "$@"; }
29 if [ ! -d /proc/1 ]; then
30 mount -n -t proc /proc /proc || fail "failed mount /proc"
33 read uptime cputime < /proc/uptime
34 iinfo "$0: up at $uptime"
36 if (: >/.testrw; ) >/dev/null 2>&1; then
39 mount -o remount,rw / || fail "failed mount / rw"
42 is_mounted sysfs "" /sys ||
43 mount -t sysfs sysfs /sys || fail "failed mount /sys!"
46 mount_once devtmpfs /dev /dev || fail "failed mount /dev"
48 iinfo "container: $_LXC_CONTAINER"
50 mkdir -p /dev/pts /dev/shm /run
56 hostname -F /etc/hostname
58 f="/bin/lxc-is-container" && write_lxc_is_container > "$f" && chmod 755 "$f"
61 for d in $(awk '$2 == "/" { print $1 }' /proc/mounts); do
62 [ -e "/dev/${d#/dev}" ] && ln -sf "${d#/dev/}" /dev/root && break
66 ## pretend you're runlevel 3
68 for s in /etc/rc3.d/S*; do
69 [ -x "$s" ] || continue
70 "$s" "start" </dev/null || warn "$s failed"
75 grep -q "^pts/0$" /etc/securetty || echo "pts/0" >> /etc/securetty
76 if ! [ /dev/tty1 -ef /dev/console ]; then
77 # on libvirt lxc, /dev/console is a symlink to /dev/pts0
78 # and /dev/tty1 is also a symlink to /dev/pts/0. So using
79 # the tty1 gets us a getty on "console"
81 # on upstream lxc, /dev/console is a character device
82 # so we run a getty there if so.
88 for tty in $lxc_console tty1 ttyS0 hvc0; do
89 if [ -e /dev/$tty ] && { echo "" >> "/dev/$tty" ; } 2>/dev/null ; then
90 s_args="${s_args:+${s_args} }s/^#$tty:\(.*\)/$tty:\1/;"
92 s_args="${s_args:+${s_args} }s/^$tty:\(.*\)/#$tty:\1/;"
96 { sed -i "$s_args" /etc/inittab && kill -HUP 1; }
98 if [ -f /etc/rc.local -a -x /etc/rc.local ]; then