X-Git-Url: https://git.sommitrealweird.co.uk/lxc-debian-unprivileged.git/blobdiff_plain/00184e955388c820536d620f4f8b5b44aaa142ab..93d38eb89c0b281584fc66dc8bf9e7a1868e903b:/templates/lxc-debian-unprivileged?ds=sidebyside diff --git a/templates/lxc-debian-unprivileged b/templates/lxc-debian-unprivileged index 9a3f248..9cbd7c0 100755 --- a/templates/lxc-debian-unprivileged +++ b/templates/lxc-debian-unprivileged @@ -96,7 +96,8 @@ fi eval set -- "$options" -DEBIAN_MIRROR="http://mirror.mythic-beasts.com/debian/" +DEBIAN_MIRROR_DEFAULT="http://mirror.sommitrealweird.co.uk/debian/" +DEBIAN_MIRROR=$DEBIAN_MIRROR_DEFAULT DEBIAN_RELEASE="jessie" NETWORK_CONFIG="" @@ -130,6 +131,12 @@ while :; do esac done +if [ "$DEBIAN_RELEASE" == "squeeze" ] || [ "$DEBIAN_RELEASE" == "lenny" ] || [ "$DEBIAN_RELEASE" == "etch" ]; then + if [ "$DEBIAN_MIRROR" == "$DEBIAN_MIRROR_DEFAULT" ]; then + DEBIAN_MIRROR="http://archive.debian.org/debian/" + fi +fi + INTERFACE_DEFAULTS="auto eth0 iface eth0 inet dhcp" @@ -139,6 +146,10 @@ generate_network_config() { return 0 fi + ETH0_HEADER="auto eth0" + ETH0_IPV4="" + ETH0_IPV6="" + echo "auto eth0" # see if there's a type network_type=${NETWORK_CONFIG/,*} @@ -148,15 +159,15 @@ generate_network_config() { v6_configured=no if [ "$network_type" == "dhcp" ]; then - echo "iface eth0 inet dhcp" - echo "iface eth0 inet6 dhcp" + ETH0_IPV4="iface eth0 inet dhcp" + ETH0_IPV6="iface eth0 inet6 dhcp" v4_configured=yes v6_configured=yes elif [ "$network_type" == "dhcp4" ]; then - echo "iface eth0 inet dhcp" + ETH0_IPV4="iface eth0 inet dhcp" v4_configured=yes elif [ "$network_type" == "dhcp6" ]; then - echo "iface eth0 inet6 dhcp" + ETH0_IPV6="iface eth0 inet6 dhcp" v6_configured=yes elif [ "$network_type" != "static" ]; then echo "Unknown network type: $network_type" 1>&2 @@ -256,10 +267,6 @@ generate_network_config() { INTERFACE_DETAILS="$(generate_network_config)" -# temporarily do something stupid -echo "$INTERFACE_DETAILS" -exit 1 - # rewrite the default config file sed -i -e "/lxc./{w ${LXC_PATH}/config-auto" -e "d}" "${LXC_PATH}/config" @@ -271,8 +278,8 @@ cat <> "${LXC_PATH}/config" lxc.include = /usr/share/lxc/config/debian.common.conf lxc.include = /usr/share/lxc/config/debian.userns.conf -# Set our hostname -lxc.utsname = $LXC_NAME +# Set hostname +lxc.uts.name = $LXC_NAME # Automatic configuration EOF @@ -285,14 +292,35 @@ mkdir "${LXC_PATH}/bin" cat < "${LXC_PATH}/bin/mknod" #!/bin/sh -exec touch "\$1" +# look for the first argument that looks like a path +for i do + case \$i in + /*) + exec touch "\$i" + ;; + esac +done + EOF chmod 755 "${LXC_PATH}/bin/mknod" export PATH="${LXC_PATH}/bin:$PATH" -debootstrap --foreign --include debian-archive-keyring,ifupdown,isc-dhcp-client,locales,openssh-server $DEBIAN_RELEASE "${LXC_ROOTFS}" $DEBIAN_MIRROR +DEBOOTSTRAPOPTIONS="" +STANDARDPACKAGES="debian-archive-keyring,ifupdown,isc-dhcp-client,locales,openssh-server" + +if [ "$DEBIAN_RELEASE" == "squeeze" ] || [ "$DEBIAN_RELEASE" == "lenny" ] || [ "$DEBIAN_RELEASE" == "etch" ]; then + DEBOOTSTRAPOPTIONS="--no-check-gpg" +fi + +if [ "$DEBIAN_RELEASE" == "lenny" ] || [ "$DEBIAN_RELEASE" == "etch" ]; then + STANDARDPACKAGES="debian-archive-keyring,ifupdown,locales,openssh-server" +fi + +debootstrap $DEBOOTSTRAPOPTIONS --foreign --include "${STANDARDPACKAGES}" $DEBIAN_RELEASE "${LXC_ROOTFS}" $DEBIAN_MIRROR + +echo "DEBOOTSTRAP STAGE 1 COMPLETE" # now totally skip that check in the new root, because it sucks. sed -i -e 's#check_sane_mount () {#check_sane_mount () {\n\treturn 0#;' "${LXC_ROOTFS}/debootstrap/functions" @@ -305,9 +333,16 @@ keyring_dpkg=$(sed -ne "/^debian-archive-keyring/ { s#.* ##; p; }" "${LXC_ROOTFS (cd "${LXC_ROOTFS}" && dpkg-deb -x ".$keyring_dpkg" .) # replace the tar containing devices with something that doesn't contain any -(cd "$LXC_ROOTFS/debootstrap" && rm devices.tar.gz && tar czvf devices.tar.gz --files-from=/dev/null) +if [ -e "$LXC_ROOTFS/debootstrap/devices.tar.gz" ]; then + (cd "$LXC_ROOTFS/debootstrap" && rm devices.tar.gz && tar czvf devices.tar.gz --files-from=/dev/null) +fi + +# if squeeze, which is totally out of date, then ignore release file expired +if [ "$DEBIAN_RELEASE" == "squeeze" ]; then + echo 'Acquire::Check-Valid-Until "0";' > ${LXC_ROOTFS}/etc/apt/apt.conf.d/squeeze.conf +fi -# and mount a shitload of things for fun and profit... +# and mount a shedload of things for fun and profit... for file in /var/lib/lxcfs/proc/*; do fname="$(basename $file)" touch "${LXC_ROOTFS}/proc/$fname" @@ -372,6 +407,14 @@ if [ "$DEBIAN_RELEASE" != "sid" ] && [ "$DEBIAN_RELEASE" != "unstable" ]; then SECURITY="deb http://security.debian.org/ $DEBIAN_RELEASE/updates main" fi +if [ "$DEBIAN_RELEASE" == "squeeze" ]; then + SECURITY="deb http://archive.debian.org/debian/ squeeze-lts main" +fi + +if [ "$DEBIAN_RELEASE" == "lenny" ] || [ "$DEBIAN_RELEASE" == "etch" ]; then + SECURITY="" +fi + # setup sources.list cat < "${LXC_ROOTFS}/etc/apt/sources.list" deb $DEBIAN_MIRROR $DEBIAN_RELEASE main @@ -389,7 +432,7 @@ if [ -e "${LXC_ROOTFS}/etc/systemd/system/" ]; then touch "${LXC_ROOTFS}/etc/systemd/system/dev-hugepages.mount" touch "${LXC_ROOTFS}/etc/systemd/system/udev.service" touch "${LXC_ROOTFS}/etc/systemd/system/systemd-udevd.service" - chroot "${LXC_ROOTFS}" systemctl set-default multi-user.target + chroot "${LXC_ROOTFS}" systemctl set-default multi-user.target || true chroot "${LXC_ROOTFS}" ln -s /lib/systemd/system/halt.target /etc/systemd/system/sigpwr.target fi