lxc-debian.in revision 853d58fdf5af0960b7b6edc9dea0fadddb8535f1
0N/A# lxc: linux Container library 0N/A# Daniel Lezcano <daniel.lezcano@free.fr> 810N/A# This library is free software; you can redistribute it and/or 0N/A# modify it under the terms of the GNU Lesser General Public 0N/A# License as published by the Free Software Foundation; either 919N/A# version 2.1 of the License, or (at your option) any later version. 919N/A# This library is distributed in the hope that it will be useful, 919N/A# but WITHOUT ANY WARRANTY; without even the implied warranty of 919N/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0N/A# Lesser General Public License for more details. 919N/A# You should have received a copy of the GNU Lesser General Public 919N/A# License along with this library; if not, write to the Free Software 0N/A# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 0N/A # therefore creating missing device nodes for tty1-4. 906N/A # configure the inittab 0N/A cat <<EOF > $rootfs/etc/inittab 0N/Asi::sysinit:/etc/init.d/rcS 0N/Al0:0:wait:/etc/init.d/rc 0 0N/Al1:1:wait:/etc/init.d/rc 1 0N/Al2:2:wait:/etc/init.d/rc 2 0N/Al3:3:wait:/etc/init.d/rc 3 0N/Al4:4:wait:/etc/init.d/rc 4 0N/Al5:5:wait:/etc/init.d/rc 5 599N/Al6:6:wait:/etc/init.d/rc 6 906N/A# Normally not reached, but fallthrough in case of emergency. 0N/Az6:6:respawn:/sbin/sulogin 906N/A1:2345:respawn:/sbin/getty 38400 console 0N/Ac1:12345:respawn:/sbin/getty 38400 tty1 linux 0N/Ac2:12345:respawn:/sbin/getty 38400 tty2 linux 0N/Ac3:12345:respawn:/sbin/getty 38400 tty3 linux 0N/Ac4:12345:respawn:/sbin/getty 38400 tty4 linux 493N/Ap6::ctrlaltdel:/sbin/init 6 0N/Ap0::powerfail:/sbin/init 0 906N/A # disable selinux in debian 906N/A # configure the network using the dhcp 906N/A cat <<EOF > $rootfs/etc/network/interfaces 810N/A # reconfigure some services 0N/A # remove pointless services in a container 905N/A echo "Root password is 'root', please change !" # check the mini debian was not already downloaded # download a mini debian into a cache echo "Downloading debian minimal ..." echo "Failed to download the rootfs, aborting." echo "Download complete." # make a local copy of the minidebian echo -n "Copying rootfs to $rootfs..." echo "Cache repository is busy." echo "Failed to download 'debian base'" echo "Failed to copy rootfs" # if there is exactly one veth network entry, make sure it has an cat <<EOF >> $path/config lxc.cap.drop = sys_module mac_admin mac_override sys_time # When using LXC with apparmor, uncomment the next line to run unconfined: #lxc.aa_profile = unconfined lxc.cgroup.devices.deny = a lxc.cgroup.devices.allow = c 1:3 rwm lxc.cgroup.devices.allow = c 1:5 rwm 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 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 lxc.cgroup.devices.allow = c 254:0 rm lxc.mount.entry = proc proc proc nodev,noexec,nosuid 0 0 lxc.mount.entry = sysfs sys sysfs defaults 0 0 echo "Failed to add configuration" # lock, so we won't purge while someone is creating a repository echo "Cache repository is busy." echo -n "Purging the download cache..." $1 -h|--help -p|--path=<path> [-a|--arch] [-r|--release=<release>] [-c|--clean] release: the debian release (e.g. wheezy): defaults to current stable arch: the container architecture (e.g. amd64): defaults to host arch if [
"$arch" =
"i686" ];
then elif [
"$arch" =
"x86_64" ];
then elif [
"$arch" =
"armv7l" ];
then if [
"$arch" ==
"i686" ];
then if [
"$arch" ==
"x86_64" ];
then echo "'debootstrap' command is missing" echo "'path' parameter is required" if [
"$(id -u)" !=
"0" ];
then echo "This script should be run as 'root'" head |awk '/^Codename: (.*)$/ { print $2; }'` echo "Invalid release ${release}, valid ones are: ${valid_releases[*]}" echo "failed to install debian" echo "failed to configure debian for a container" echo "failed write configuration file"