File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -20,13 +20,20 @@ if [ "${BASE_DISTRO}" == "ubuntu" ]; then
2020 [ -n " $BASE_ZIP_IMG " ] || BASE_ZIP_IMG=` ls -t $BASE_IMAGE_PATH /ubuntu-* .xz | head -n 1`
2121 # Default user ubuntu
2222 [ -n " $BASE_USER " ] || BASE_USER=ubuntu
23+
24+ # Add base user if does not exist
25+ [ -n " $BASE_ADD_USER " ] || BASE_ADD_USER=yes
26+ # When adding a base user which password to use
27+ [ -n " $BASE_USER_PASSWORD " ] || BASE_USER_PASSWORD=ubuntu
2328elif [ " ${BASE_DISTRO} " == " raspios64" ]; then
2429 [ -n " $BASE_ZIP_IMG " ] || BASE_ZIP_IMG=` ls -t $BASE_IMAGE_PATH /* -{raspbian,raspios}-* -arm64-* .zip | head -n 1`
30+ [ -n " $BASE_ADD_USER " ] || BASE_ADD_USER=no
2531else
2632 # Default image raspbian
2733 [ -n " $BASE_ZIP_IMG " ] || BASE_ZIP_IMG=` ls -t $BASE_IMAGE_PATH /* -{raspbian,raspios}* .zip | head -n 1`
2834 # Default user raspbian
2935 [ -n " $BASE_USER " ] || BASE_USER=pi
36+ [ -n " $BASE_ADD_USER " ] || BASE_ADD_USER=no
3037fi
3138
3239# Release compression
Original file line number Diff line number Diff line change @@ -33,6 +33,17 @@ if [ "${BASE_DISTRO}" == "ubuntu" ]; then
3333
3434 # Undo prevent any installed services from automatically starting
3535 rm -r /usr/sbin/policy-rc.d || true
36+
37+ fi
38+
39+ if [ " ${BASE_ADD_USER} " == " yes" ]; then
40+ if id -u " ${BASE_USER} " > /dev/null 2>&1 ; then
41+ echo " Base user exists, not adding"
42+ else
43+ echo " Adding base user ${BASE_USER} "
44+ password=$( perl -e ' printf("%s\n", crypt($ARGV[0], "password"))' " ${BASE_USER_PASSWORD} " )
45+ useradd -m -p " ${password} " -s /bin/bash " ${BASE_USER} "
46+ fi
3647fi
3748
3849if [ -n " $BASE_APT_PROXY " ]
You can’t perform that action at this time.
0 commit comments