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.
pull/236/head
Sam Tygier 2018-12-09 22:52:03 +00:00 committed by XECDesign
parent d1b747747c
commit d07096ebb5
5 changed files with 20 additions and 10 deletions

View File

@ -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 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. 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: A simple example for building Raspbian:

View File

@ -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 DEPLOY_DIR=${DEPLOY_DIR:-"${BASE_DIR}/deploy"}
export LOG_FILE="${WORK_DIR}/build.log" 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 BASE_DIR
export CLEAN export CLEAN

View File

@ -5,10 +5,10 @@ install -m 644 files/noclear.conf "${ROOTFS_DIR}/etc/systemd/system/getty@tty1.s
install -v -m 644 files/fstab "${ROOTFS_DIR}/etc/fstab" install -v -m 644 files/fstab "${ROOTFS_DIR}/etc/fstab"
on_chroot << EOF on_chroot << EOF
if ! id -u pi >/dev/null 2>&1; then if ! id -u ${FIRST_USER_NAME} >/dev/null 2>&1; then
adduser --disabled-password --gecos "" pi adduser --disabled-password --gecos "" ${FIRST_USER_NAME}
fi fi
echo "pi:raspberry" | chpasswd echo "${FIRST_USER_NAME}:${FIRST_USER_PASS}" | chpasswd
echo "root:root" | chpasswd echo "root:root" | chpasswd
EOF EOF

View File

@ -32,12 +32,12 @@ systemctl enable resize2fs_once
EOF EOF
fi fi
on_chroot << \EOF on_chroot <<EOF
for GRP in input spi i2c gpio; do for GRP in input spi i2c gpio; do
groupadd -f -r "$GRP" groupadd -f -r "\$GRP"
done done
for GRP in adm dialout cdrom audio users sudo video games plugdev input gpio spi i2c netdev; do 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 done
EOF EOF

View File

@ -1,7 +1,7 @@
#!/bin/bash -e #!/bin/bash -e
#Alacarte fixes #Alacarte fixes
install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/pi/.local" install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.local"
install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/pi/.local/share" 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/pi/.local/share/applications" 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/pi/.local/share/desktop-directories" install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.local/share/desktop-directories"