From 05011ab6987a78555d03ccdb6373546787242bb3 2016-06-08 05:29:34 From: Stephen A. Brandli Date: 2016-06-08 05:29:34 Subject: [PATCH] Added custom user name (other than "pi") --- diff --git a/README.md b/README.md index 03fc476..2f43742 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,10 @@ Install and enable the hardware accelerated Xorg video driver `fbturbo`. Please Enable iptables IPv4/IPv6 firewall. Simplified ruleset: Allow all outgoing connections. Block all incoming connections except to OpenSSH service. ##### `ENABLE_USER`=true -Create pi user with password raspberry +Create non-root user with password raspberry. Unless overridden with `USER_NAME`=user, username will be `pi`. + +##### `USER_NAME`=pi +Non-root user to create. Ignored if `ENABLE_USER`=false ##### `ENABLE_ROOT`=true Set root user password so root login will be enabled diff --git a/bootstrap.d/30-security.sh b/bootstrap.d/30-security.sh index a5b558b..a2435b9 100644 --- a/bootstrap.d/30-security.sh +++ b/bootstrap.d/30-security.sh @@ -10,8 +10,9 @@ ENCRYPTED_PASSWORD=`mkpasswd -m sha-512 "${PASSWORD}"` # Setup default user if [ "$ENABLE_USER" = true ] ; then - chroot_exec adduser --gecos pi --add_extra_groups --disabled-password pi - chroot_exec usermod -a -G sudo -p "${ENCRYPTED_PASSWORD}" pi + chroot_exec adduser --gecos $USER_NAME --add_extra_groups \ + --disabled-password $USER_NAME + chroot_exec usermod -a -G sudo -p "${ENCRYPTED_PASSWORD}" $USER_NAME fi # Setup root password or not diff --git a/rpi2-gen-image.sh b/rpi2-gen-image.sh index e921e25..fad70cf 100755 --- a/rpi2-gen-image.sh +++ b/rpi2-gen-image.sh @@ -101,6 +101,7 @@ ENABLE_XORG=${ENABLE_XORG:=false} ENABLE_WM=${ENABLE_WM:=""} ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true} ENABLE_USER=${ENABLE_USER:=true} +USER_NAME=${USER_NAME:="pi"} ENABLE_ROOT=${ENABLE_ROOT:=false} ENABLE_ROOT_SSH=${ENABLE_ROOT_SSH:=false}