diff options
author | Helmut Grohne <helmut@subdivi.de> | 2022-12-20 14:58:48 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2022-12-20 14:59:27 +0100 |
commit | 4bb29d3fb7bc5258e4339115000564cc3452b799 (patch) | |
tree | 74d83c92c7008c6c5c0cec98f81bc1eac72a54ce | |
parent | e3258ab831172b3760577507b0437365f343cc5e (diff) | |
download | debvm-4bb29d3fb7bc5258e4339115000564cc3452b799.tar.gz |
debvm-create: allow passing arbitrary mmdebstrap options
Reported-by: Johannes Schauer Marin Rodrigues <josch@debian.org>
-rwxr-xr-x | debvm-create | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/debvm-create b/debvm-create index 6728e90..4821d39 100755 --- a/debvm-create +++ b/debvm-create @@ -21,7 +21,7 @@ die() { } usage() { - die "usage: $0 [-a architecture] [-h hostname] [-k sshkey] [-m mirror] [-o output] [-p packages] [-r release] [-s size_in_GB]" + die "usage: $0 [-a architecture] [-h hostname] [-k sshkey] [-m mirror] [-o output] [-p packages] [-r release] [-s size_in_GB] [-- mmdebstrap options]" } @@ -67,6 +67,10 @@ while test "$#" -gt 0; do SIZE=$(($2*1024*1024*1024)) shift 2 ;; + --) + shift + break + ;; *) usage ;; @@ -96,7 +100,8 @@ set -- \ --verbose \ --variant=apt \ "--architecture=$ARCHITECTURE" \ - "--include=$INCLUDE_PACKAGES" + "--include=$INCLUDE_PACKAGES" \ + "$@" # unless we set up a fstab, / will be read-only case "$ARCHITECTURE" in @@ -107,42 +112,44 @@ case "$ARCHITECTURE" in DISKDEV=sda ;; esac -set -- "$@" "--customize-hook=echo '/dev/$DISKDEV / ext4 defaults 0 1' >"'"$1/etc/fstab"' +set -- "--customize-hook=echo '/dev/$DISKDEV / ext4 defaults 0 1' >"'"$1/etc/fstab"' "$@" # set up a hostname -set -- "$@" \ +set -- \ "--customize-hook=echo $VMNAME >"'"$1/etc/hostname"' \ - "--customize-hook=echo 127.0.0.1 localhost $VMNAME >"'"$1/etc/hosts"' + "--customize-hook=echo 127.0.0.1 localhost $VMNAME >"'"$1/etc/hosts"' \ + "$@" # allow password-less root login -set -- "$@" '--customize-hook=sed -i -e "s/^root:\\*:/root::/" $1/etc/shadow' -#set -- "$@" '--customize-hook=chroot "$1" passwd --delete root' +set -- '--customize-hook=chroot "$1" passwd --delete root' "$@" # dhcp on all network interfaces -set -- "$@" \ +set -- \ '--customize-hook=systemctl --root="$1" enable systemd-networkd.service' \ - "--customize-hook=printf '"'[Match]\nName=en*\nName=eth*\n[Network]\nDHCP=yes\n'"'"' > "$1/etc/systemd/network/20-wired.network"' + "--customize-hook=printf '"'[Match]\nName=en*\nName=eth*\n[Network]\nDHCP=yes\n'"'"' > "$1/etc/systemd/network/20-wired.network"' \ + "$@" # add ssh key for root if test -n "$SSHKEY"; then - set -- "$@" \ + set -- \ '--customize-hook=mkdir -p "$1/root/.ssh"' \ - "--customize-hook=upload $SSHKEY /root/.ssh/authorized_keys" + "--customize-hook=upload $SSHKEY /root/.ssh/authorized_keys" \ + "$@" fi -set -- "$@" '--customize-hook=chroot "$1" apt update' +set -- '--customize-hook=chroot "$1" apt update' "$@" case "$SUITE" in jessie) # Use obsolete and expired keys. - set -- "$@" '--keyring=/usr/share/keyrings/debian-archive-removed-keys.gpg' - set -- "$@" --aptopt='Apt::Key::gpgvcommand "/usr/libexec/mmdebstrap/gpgvnoexpkeysig"' + set -- '--keyring=/usr/share/keyrings/debian-archive-removed-keys.gpg' "$@" + set -- --aptopt='Apt::Key::gpgvcommand "/usr/libexec/mmdebstrap/gpgvnoexpkeysig"' "$@" # chfn does not work, because libpam-runtime.postinst is late setting up /etc/pam.d/common-auth et al - set -- "$@" --extract-hook='chroot "$1" pam-auth-update --package --force' + set -- --extract-hook='chroot "$1" pam-auth-update --package --force' "$@" ;; buster) # We need /var/lib/dpkg/available for dpkg --set-selections to work. - set -- "$@" '--customize-hook=cat "$1"/var/lib/apt/lists/*_Packages | chroot "$1" dpkg --update-avail' + set -- '--customize-hook=cat "$1"/var/lib/apt/lists/*_Packages | chroot "$1" dpkg --update-avail' "$@" ;; esac |