summaryrefslogtreecommitdiff
path: root/useraddhook/customize.sh
diff options
context:
space:
mode:
Diffstat (limited to 'useraddhook/customize.sh')
-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