Skip to content

Commit

Permalink
Allow setting user name and password from config
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
samtygier authored and fuji246 committed Sep 13, 2019
1 parent 0404b76 commit 538ebd9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions stage1/01-sys-tweaks/00-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions stage2/01-sys-tweaks/01-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,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

Expand Down
7 changes: 7 additions & 0 deletions stage4/02-extras/00-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash -e

#Alacarte fixes
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"

0 comments on commit 538ebd9

Please sign in to comment.