aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Tygier <[email protected]>2018-12-09 22:52:03 +0000
committerXECDesign <[email protected]>2018-12-21 04:09:47 +0000
commitd07096ebb565bc9ac97974895c57d88b0e82ce23 (patch)
tree98a718a8d82717f850136f44aa61f9492472562f
parentd1b747747c81d34c6779c2ac9bb86fcbfac79c6c (diff)
Allow setting user name and password from config
Add FIRST_USER_NAME and FIRST_USER_PASS variables that can be set in the config (or enviroment). Defaults to the standard pi and raspberry.
-rwxr-xr-xREADME.md7
-rwxr-xr-xbuild.sh3
-rwxr-xr-xstage1/01-sys-tweaks/00-run.sh6
-rwxr-xr-xstage2/01-sys-tweaks/01-run.sh6
-rwxr-xr-xstage4/02-extras/00-run.sh8
5 files changed, 20 insertions, 10 deletions
diff --git a/README.md b/README.md
index 65c5046..8af1f12 100755
--- a/README.md
+++ b/README.md
@@ -73,6 +73,13 @@ The following environment variables are supported:
Setting to '1' enables the QEMU mode - creating an image that can be mounted via QEMU for an emulated
environment. These images include "-qemu" in the image file name.
+ * `FIRST_USER_NAME` (Default: "pi" )
+
+ Username for the first user
+
+ * `FIRST_USER_PASS` (Default: "raspberry")
+
+ Password for the first user
A simple example for building Raspbian:
diff --git a/build.sh b/build.sh
index ebeb46a..4c8c3a3 100755
--- a/build.sh
+++ b/build.sh
@@ -141,6 +141,9 @@ export WORK_DIR="${WORK_DIR:-"${BASE_DIR}/work/${IMG_DATE}-${IMG_NAME}"}"
export DEPLOY_DIR=${DEPLOY_DIR:-"${BASE_DIR}/deploy"}
export LOG_FILE="${WORK_DIR}/build.log"
+export FIRST_USER_NAME=${FIRST_USER_NAME:-pi}
+export FIRST_USER_PASS=${FIRST_USER_PASS:-raspberry}
+
export BASE_DIR
export CLEAN
diff --git a/stage1/01-sys-tweaks/00-run.sh b/stage1/01-sys-tweaks/00-run.sh
index 61ba51b..9c380ec 100755
--- a/stage1/01-sys-tweaks/00-run.sh
+++ b/stage1/01-sys-tweaks/00-run.sh
@@ -5,10 +5,10 @@ install -m 644 files/noclear.conf "${ROOTFS_DIR}/etc/systemd/system/[email protected]
install -v -m 644 files/fstab "${ROOTFS_DIR}/etc/fstab"
on_chroot << EOF
-if ! id -u pi >/dev/null 2>&1; then
- adduser --disabled-password --gecos "" pi
+if ! id -u ${FIRST_USER_NAME} >/dev/null 2>&1; then
+ adduser --disabled-password --gecos "" ${FIRST_USER_NAME}
fi
-echo "pi:raspberry" | chpasswd
+echo "${FIRST_USER_NAME}:${FIRST_USER_PASS}" | chpasswd
echo "root:root" | chpasswd
EOF
diff --git a/stage2/01-sys-tweaks/01-run.sh b/stage2/01-sys-tweaks/01-run.sh
index 4e9c7d0..8fb99c1 100755
--- a/stage2/01-sys-tweaks/01-run.sh
+++ b/stage2/01-sys-tweaks/01-run.sh
@@ -32,12 +32,12 @@ systemctl enable resize2fs_once
EOF
fi
-on_chroot << \EOF
+on_chroot <<EOF
for GRP in input spi i2c gpio; do
- groupadd -f -r "$GRP"
+ groupadd -f -r "\$GRP"
done
for GRP in adm dialout cdrom audio users sudo video games plugdev input gpio spi i2c netdev; do
- adduser pi $GRP
+ adduser $FIRST_USER_NAME \$GRP
done
EOF
diff --git a/stage4/02-extras/00-run.sh b/stage4/02-extras/00-run.sh
index bd24ad8..6a24f82 100755
--- a/stage4/02-extras/00-run.sh
+++ b/stage4/02-extras/00-run.sh
@@ -1,7 +1,7 @@
#!/bin/bash -e
#Alacarte fixes
-install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/pi/.local"
-install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/pi/.local/share"
-install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/pi/.local/share/applications"
-install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/pi/.local/share/desktop-directories"
+install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.local"
+install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.local/share"
+install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.local/share/applications"
+install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.local/share/desktop-directories"