]> git.sommitrealweird.co.uk Git - lxc-debian-unprivileged.git/blobdiff - templates/lxc-debian-unprivileged
Quick fixups to unpriv'd debian template for newer lxc
[lxc-debian-unprivileged.git] / templates / lxc-debian-unprivileged
index dd7bdafc11e5e862f594dc8378e7697a24836a29..9cbd7c0e622347cb1f3ec6cb96738b8a242115c2 100755 (executable)
@@ -96,7 +96,8 @@ fi
 
 eval set -- "$options"
 
 
 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=""
 
 DEBIAN_RELEASE="jessie"
 NETWORK_CONFIG=""
 
@@ -130,6 +131,12 @@ while :; do
     esac
 done
 
     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"
 
 INTERFACE_DEFAULTS="auto eth0
 iface eth0 inet dhcp"
 
@@ -271,8 +278,8 @@ cat <<EOF >> "${LXC_PATH}/config"
 lxc.include = /usr/share/lxc/config/debian.common.conf
 lxc.include = /usr/share/lxc/config/debian.userns.conf
 
 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
 
 # Automatic configuration
 EOF
@@ -300,7 +307,18 @@ chmod 755 "${LXC_PATH}/bin/mknod"
 
 export PATH="${LXC_PATH}/bin:$PATH"
 
 
 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"
 
 
 echo "DEBOOTSTRAP STAGE 1 COMPLETE"
 
@@ -319,7 +337,12 @@ 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
 
     (cd "$LXC_ROOTFS/debootstrap" && rm devices.tar.gz && tar czvf devices.tar.gz --files-from=/dev/null)
 fi
 
-# and mount a shitload of things for fun and profit...
+# 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 shedload of things for fun and profit...
 for file in /var/lib/lxcfs/proc/*; do
     fname="$(basename $file)"
     touch "${LXC_ROOTFS}/proc/$fname"
 for file in /var/lib/lxcfs/proc/*; do
     fname="$(basename $file)"
     touch "${LXC_ROOTFS}/proc/$fname"
@@ -384,6 +407,14 @@ if [ "$DEBIAN_RELEASE" != "sid" ] && [ "$DEBIAN_RELEASE" != "unstable" ]; then
     SECURITY="deb http://security.debian.org/ $DEBIAN_RELEASE/updates main"
 fi
 
     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 <<EOF > "${LXC_ROOTFS}/etc/apt/sources.list"
 deb $DEBIAN_MIRROR $DEBIAN_RELEASE main
 # setup sources.list
 cat <<EOF > "${LXC_ROOTFS}/etc/apt/sources.list"
 deb $DEBIAN_MIRROR $DEBIAN_RELEASE main
@@ -401,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"
     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
 
     chroot "${LXC_ROOTFS}" ln -s /lib/systemd/system/halt.target /etc/systemd/system/sigpwr.target
 fi