Skip to content

Instantly share code, notes, and snippets.

@simonft
Forked from zellio/gentrusty.sh
Created November 16, 2015 20:05
Show Gist options
  • Save simonft/ee9ba5f0dfa392ebe896 to your computer and use it in GitHub Desktop.
Save simonft/ee9ba5f0dfa392ebe896 to your computer and use it in GitHub Desktop.
Generate Ubuntu Trusty container that will boot under systemd-nspawn
#!/usr/bin/env bash
function __main
{
local -r path="$(realpath "${1:-.}")"
debootstrap --variant=buildd trusty "$1" http://archive.ubuntu.com/ubuntu/
patch --unified "$path/etc/init/console.conf" <<'EOF'
@@ -3,7 +3,8 @@
# This service maintains a getty on console from the point the system is
# started until it is shut down again.
-start on stopped rc RUNLEVEL=[2345] and container CONTAINER=lxc
+start on stopped rc RUNLEVEL=[2345] and (container CONTAINER=lxc or
+ container CONTAINER=systemd-nspawn)
stop on runlevel [!2345]
EOF
path --unified "$path/etc/shadow" <<'EOF'
@@ -1,4 +1,4 @@
-root:*:16730:0:99999:7:::
+root::16730:0:99999:7:::
daemon:*:16730:0:99999:7:::
bin:*:16730:0:99999:7:::
sys:*:16730:0:99999:7:::
EOF
}
__main "$@"
exit "$!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment