Add customization mecanism for keyboard layout, hostname, username:password and root password with the config file
This commit is contained in:
parent
330ce73491
commit
0fee534ea0
20
README.md
20
README.md
|
@ -73,6 +73,26 @@ 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.
|
||||
|
||||
* `RPI_LOCALHOST` (Default: `"raspberrypi"`)
|
||||
|
||||
Your image hostname.
|
||||
|
||||
* `RPI_USERNAME` (Default: `"pi"`)
|
||||
|
||||
Default non priviledged user name.
|
||||
|
||||
* `RPI_USERPASS` (Default: `"raspberry"`)
|
||||
|
||||
Default user password.
|
||||
|
||||
* `RPI_ROOTPASS` (Default: `"root"`)
|
||||
|
||||
root user default password.
|
||||
|
||||
* `KEYBOARD_LANG` (Default: `"gb"`)
|
||||
|
||||
Change the keyboard default mapping (gb=qwerty, fr=azerty).
|
||||
|
||||
|
||||
A simple example for building Raspbian:
|
||||
|
||||
|
|
9
build.sh
9
build.sh
|
@ -133,9 +133,14 @@ if [ -z "${IMG_NAME}" ]; then
|
|||
fi
|
||||
|
||||
export USE_QEMU="${USE_QEMU:-0}"
|
||||
export IMG_DATE="${IMG_DATE:-"$(date +%Y-%m-%d)"}"
|
||||
export RPI_LOCALHOST=${RPI_LOCALHOST:-"raspberrypi"}
|
||||
export RPI_USERNAME=${RPI_USERNAME:-"pi"}
|
||||
export RPI_USERPASS=${RPI_USERPASS:-"raspberry"}
|
||||
export RPI_ROOTPASS=${RPI_ROOTPASS:-"root"}
|
||||
export KEYBOARD_LANG=${KEYBOARD_LANG:-"gb"}
|
||||
|
||||
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
export IMG_DATE=${IMG_DATE:-"$(date +%Y-%m-%d)"}
|
||||
export BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
export SCRIPT_DIR="${BASE_DIR}/scripts"
|
||||
export WORK_DIR="${WORK_DIR:-"${BASE_DIR}/work/${IMG_DATE}-${IMG_NAME}"}"
|
||||
export DEPLOY_DIR=${DEPLOY_DIR:-"${BASE_DIR}/deploy"}
|
||||
|
|
7
config.exemple
Normal file
7
config.exemple
Normal file
|
@ -0,0 +1,7 @@
|
|||
IMG_NAME="Raspbian"
|
||||
USE_QEMU=1
|
||||
KEYBOARD_LANG="gb"
|
||||
RPI_LOCALHOST="raspberrypi"
|
||||
RPI_USERNAME="pi"
|
||||
RPI_USERPASS="raspberry"
|
||||
RPI_ROOTPASS="root"
|
|
@ -8,8 +8,8 @@ on_chroot << EOF
|
|||
hardlink -t /usr/share/doc
|
||||
EOF
|
||||
|
||||
if [ -d "${ROOTFS_DIR}/home/pi/.config" ]; then
|
||||
chmod 700 "${ROOTFS_DIR}/home/pi/.config"
|
||||
if [ -d "${ROOTFS_DIR}/home/${RPI_USERNAME}/.config" ]; then
|
||||
chmod 700 "${ROOTFS_DIR}/home/${RPI_USERNAME}/.config"
|
||||
fi
|
||||
|
||||
rm -f "${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache"
|
||||
|
|
|
@ -5,11 +5,9 @@ install -m 644 files/noclear.conf "${ROOTFS_DIR}/etc/systemd/system/getty@tty1.s
|
|||
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 ${RPI_USERNAME} >/dev/null 2>&1; then
|
||||
adduser --disabled-password --gecos "" ${RPI_USERNAME}
|
||||
fi
|
||||
echo "pi:raspberry" | chpasswd
|
||||
echo "root:root" | chpasswd
|
||||
echo "${RPI_USERNAME}:${RPI_USERPASS}" | chpasswd
|
||||
echo "root:${RPI_ROOTPASS}" | chpasswd
|
||||
EOF
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
Index: jessie-stage1/rootfs/etc/hosts
|
||||
===================================================================
|
||||
--- jessie-stage1.orig/rootfs/etc/hosts
|
||||
+++ jessie-stage1/rootfs/etc/hosts
|
||||
@@ -3,3 +3,4 @@
|
||||
ff02::1 ip6-allnodes
|
||||
ff02::2 ip6-allrouters
|
||||
|
||||
+127.0.1.1 raspberrypi
|
|
@ -1 +0,0 @@
|
|||
01-hosts.diff
|
|
@ -4,3 +4,6 @@ install -m 644 files/ipv6.conf "${ROOTFS_DIR}/etc/modprobe.d/ipv6.conf"
|
|||
install -m 644 files/hostname "${ROOTFS_DIR}/etc/hostname"
|
||||
|
||||
ln -sf /dev/null "${ROOTFS_DIR}/etc/systemd/network/99-default.link"
|
||||
|
||||
echo "${RPI_LOCALHOST}" > "${ROOTFS_DIR}/etc/hostname"
|
||||
echo "127.0.1.1 ${RPI_LOCALHOST}" >> "${ROOTFS_DIR}/etc/hosts"
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -37,7 +37,7 @@ for GRP in input spi i2c gpio; do
|
|||
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 ${RPI_USERNAME} $GRP
|
||||
done
|
||||
EOF
|
||||
|
||||
|
@ -45,8 +45,4 @@ on_chroot << EOF
|
|||
setupcon --force --save-only -v
|
||||
EOF
|
||||
|
||||
on_chroot << EOF
|
||||
usermod --pass='*' root
|
||||
EOF
|
||||
|
||||
rm -f "${ROOTFS_DIR}/etc/ssh/"ssh_host_*_key*
|
||||
|
|
|
@ -13,13 +13,14 @@ fi
|
|||
|
||||
ln -sf pip3 "${ROOTFS_DIR}/usr/bin/pip-3.2"
|
||||
|
||||
install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/pi/python_games"
|
||||
tar xvf files/python_games.tar.gz -C "${ROOTFS_DIR}/home/pi/python_games" --strip-components=1
|
||||
chown 1000:1000 "${ROOTFS_DIR}/home/pi/python_games" -Rv
|
||||
chmod +x "${ROOTFS_DIR}/home/pi/python_games/launcher.sh"
|
||||
install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${RPI_USERNAME}/python_games"
|
||||
tar xvf files/python_games.tar.gz -C "${ROOTFS_DIR}/home/${RPI_USERNAME}/python_games" --strip-components=1
|
||||
chown 1000:1000 "${ROOTFS_DIR}/home/${RPI_USERNAME}/python_games" -Rv
|
||||
chmod +x "${ROOTFS_DIR}/home/${RPI_USERNAME}/python_games/launcher.sh"
|
||||
|
||||
|
||||
#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/${RPI_USERNAME}/.local"
|
||||
install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${RPI_USERNAME}/.local/share"
|
||||
install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${RPI_USERNAME}/.local/share/applications"
|
||||
install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${RPI_USERNAME}/.local/share/desktop-directories"
|
||||
|
|
Loading…
Reference in New Issue
Block a user