summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2024-05-15 06:50:36 +0200
committerHelmut Grohne <helmut@subdivi.de>2024-05-15 06:50:36 +0200
commit12c293c3e7777d425070ca140c8ab00a5c7a4883 (patch)
tree50d3e245aca97cbf140f7a1d406a8b0a7ffabee9
parentf145fdc1cadc10f9aaa82f00af8e05541f38d4a4 (diff)
downloaddebvm-12c293c3e7777d425070ca140c8ab00a5c7a4883.tar.gz
useraddhook: rename USERNAME environment variable to be less generic
USERNAME has uses beyond e.g. in a Windows context, so avoid that. Then again, this hook may be useful beyond debvm and is installed to /usr/share/mmdebstrap, so don't use a DEBVM_ prefix either. Reported-by: Johannes Schauer Marin Rodrigues <josch@mister-muffin.de>
-rwxr-xr-xuseraddhook/customize.sh22
1 files changed, 11 insertions, 11 deletions
diff --git a/useraddhook/customize.sh b/useraddhook/customize.sh
index bc827a7..ec85d0a 100755
--- a/useraddhook/customize.sh
+++ b/useraddhook/customize.sh
@@ -5,7 +5,7 @@
# Add a non-root user, add them to the sudo group and use the same authorized
# ssh keys as the root user.
#
-# - the new user is called "user" by default (customizable via $USERNAME)
+# - the new user is called "user" by default (customizable via $USERADDHOOK_USERNAME)
# - no password required for login
# - requires the passwd and coreutils packages installed inside the chroot
# - adds the new user to the sudo group if it exists
@@ -24,24 +24,24 @@
set -eu
-: "${USERNAME:=user}"
+: "${USERADDHOOK_USERNAME:=user}"
-chroot "$1" useradd --home-dir "/home/$USERNAME" --create-home --shell /bin/bash "$USERNAME"
-chroot "$1" passwd --delete "$USERNAME"
+chroot "$1" useradd --home-dir "/home/$USERADDHOOK_USERNAME" --create-home --shell /bin/bash "$USERADDHOOK_USERNAME"
+chroot "$1" passwd --delete "$USERADDHOOK_USERNAME"
if chroot "$1" getent group sudo >/dev/null; then
- echo "Adding $USERNAME to sudo group"
- chroot "$1" usermod --append --groups sudo "$USERNAME"
+ echo "Adding $USERADDHOOK_USERNAME to sudo group"
+ chroot "$1" usermod --append --groups sudo "$USERADDHOOK_USERNAME"
fi
if [ -e "$1"/root/.ssh/authorized_keys ]; then
- echo "Installing ssh authorized_keys for $USERNAME"
- chroot "$1" install -o "$USERNAME" -g "$USERNAME" -m 700 -d "/home/$USERNAME/.ssh"
- chroot "$1" install -o "$USERNAME" -g "$USERNAME" -t "/home/$USERNAME/.ssh" /root/.ssh/authorized_keys
+ echo "Installing ssh authorized_keys for $USERADDHOOK_USERNAME"
+ chroot "$1" install -o "$USERADDHOOK_USERNAME" -g "$USERADDHOOK_USERNAME" -m 700 -d "/home/$USERADDHOOK_USERNAME/.ssh"
+ chroot "$1" install -o "$USERADDHOOK_USERNAME" -g "$USERADDHOOK_USERNAME" -t "/home/$USERADDHOOK_USERNAME/.ssh" /root/.ssh/authorized_keys
fi
if [ -e "$1/etc/lightdm/lightdm.conf" ]; then
- echo "Enabling autologin in lightdm for $USERNAME"
+ echo "Enabling autologin in lightdm for $USERADDHOOK_USERNAME"
cat >>"$1/etc/lightdm/lightdm.conf" <<EOF
[SeatDefaults]
-autologin-user=$USERNAME
+autologin-user=$USERADDHOOK_USERNAME
autologin-user-timeout=0
EOF
fi