lxc-alpine.in revision b1aa0624bae5a81d6f6bbc2653a388d148cffef8
rootfs="$1"
else
fi
}
rootfs="$1"
::sysinit:/sbin/rc sysinit
::wait:/sbin/rc default
tty1:12345:respawn:/sbin/getty 38400 tty1
::ctrlaltdel:/sbin/reboot
::shutdown:/sbin/rc shutdown
EOF
# set up nameserver
# configure the network using the dhcp
# note that lxc will set up lo interface
cat <<EOF > $rootfs/etc/network/interfaces
#auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
EOF
# set the hostname
# missing device nodes
echo "Setting up device nodes"
# start services
return 0
}
path=$1
rootfs=$2
hostname=$3
cat <<EOF >> $path/config
lxc.tty = 4
lxc.pts = 1024
lxc.utsname = $hostname
# When using LXC with apparmor, uncomment the next line to run unconfined:
#lxc.aa_profile = unconfined
# network interface
lxc.network.name = eth0
lxc.network.type = veth
lxc.network.flags = up
# enable for bridging
#lxc.network.link = br0
#lxc.network.ipv4 = n.n.n.n
#lxc.network.ipv4.gateway = auto
# devices
lxc.cgroup.devices.deny = a
# /dev/null and zero
lxc.cgroup.devices.allow = c 1:3 rwm
lxc.cgroup.devices.allow = c 1:5 rwm
# consoles
lxc.cgroup.devices.allow = c 5:1 rwm
lxc.cgroup.devices.allow = c 5:0 rwm
lxc.cgroup.devices.allow = c 4:0 rwm
lxc.cgroup.devices.allow = c 4:1 rwm
# /dev/{,u}random
lxc.cgroup.devices.allow = c 1:9 rwm
lxc.cgroup.devices.allow = c 1:8 rwm
lxc.cgroup.devices.allow = c 136:* rwm
lxc.cgroup.devices.allow = c 5:2 rwm
# rtc
lxc.cgroup.devices.allow = c 254:0 rwm
# mounts point
lxc.mount.entry=proc proc proc nodev,noexec,nosuid 0 0
lxc.mount.entry=run run tmpfs nodev,noexec,nosuid,relatime,size=1m,mode=0755 0 0
lxc.mount.entry=none dev/pts devpts gid=5,mode=620 0 0
EOF
return 0
}
echo "$@" >&2
exit 1
}
}
exit 1
}
if [ -z "$2" ]; then
usage_err "option '$1' requires an argument"
fi
}
while [ $# -gt 0 ]; do
opt="$1"
shift
-h|--help)
exit 0
;;
-n|--name)
name=$1
shift
;;
-p|--path)
path=$1
shift
;;
--)
break;;
--*=*)
# split --myopt=foo=bar into --myopt foo=bar
;;
-?)
;;
-*)
# split opts -abc into -a -b -c
;;
*)
exit 1
;;
esac
done
if [ -z "${path}" ]; then
path="${default_path}/${name}"
fi
if [ -z "$rootfs" ]; then
rootfs="${path}/rootfs"
fi
copy_configuration "$path" "$rootfs" "$name"