From 261cfdd77d49b02880e160e129c0336a012392bf Mon Sep 17 00:00:00 2001 From: meator Date: Thu, 17 Oct 2024 16:19:42 +0200 Subject: [PATCH] mklive.sh: Make default shell configurable This commit add a -S option that changes the default root shell of the iso. It also mentions the live.shell kernel option that changes the shell of the unprivileged user (anon). --- mklive.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mklive.sh b/mklive.sh index 7b8c807..17001fd 100755 --- a/mklive.sh +++ b/mklive.sh @@ -89,6 +89,8 @@ usage() { -g " ..." Ignore packages when building the ISO image -I Include directory structure under given path in the ROOTFS -S " ..." Enable services in the ISO image + -e Default shell of the root user (must be absolute path). + Set the live.shell kernel argument to change the default shell of anon. -C " ..." Add additional kernel command line arguments -T Modify the bootloader title (default: Void Linux) -v linux<version> Install a custom Linux version on ISO image (default: linux metapackage) @@ -160,6 +162,11 @@ enable_services() { done } +change_shell() { + chroot "$ROOTFS" chsh -s "$ROOT_SHELL" root + [ $? -ne 0 ] && die "Failed to change the shell for root" +} + copy_include_directories() { for includedir in "${INCLUDE_DIRS[@]}"; do info_msg "=> copying include directory '$includedir' ..." @@ -313,7 +320,7 @@ generate_iso_image() { # # main() # -while getopts "a:b:r:c:C:T:Kk:l:i:I:S:s:o:p:g:v:Vh" opt; do +while getopts "a:b:r:c:C:T:Kk:l:i:I:S:e:s:o:p:g:v:Vh" opt; do case $opt in a) BASE_ARCH="$OPTARG";; b) BASE_SYSTEM_PKG="$OPTARG";; @@ -326,6 +333,7 @@ while getopts "a:b:r:c:C:T:Kk:l:i:I:S:s:o:p:g:v:Vh" opt; do i) INITRAMFS_COMPRESSION="$OPTARG";; I) INCLUDE_DIRS+=("$OPTARG");; S) SERVICE_LIST="$SERVICE_LIST $OPTARG";; + e) ROOT_SHELL="$OPTARG";; s) SQUASHFS_COMPRESSION="$OPTARG";; o) OUTPUT_FILE="$OPTARG";; p) PACKAGE_LIST="$PACKAGE_LIST $OPTARG";; @@ -387,6 +395,7 @@ CURRENT_STEP=0 STEP_COUNT=10 [ "${#INCLUDE_DIRS[@]}" -gt 0 ] && STEP_COUNT=$((STEP_COUNT+1)) [ -n "${IGNORE_PKGS}" ] && STEP_COUNT=$((STEP_COUNT+1)) +[ -n "$ROOT_SHELL" ] && STEP_COUNT=$((STEP_COUNT+1)) : ${SYSLINUX_DATADIR:="$VOIDHOSTDIR"/usr/lib/syslinux} : ${GRUB_DATADIR:="$VOIDHOSTDIR"/usr/share/grub} @@ -447,6 +456,11 @@ install_packages print_step "Enabling services: ${SERVICE_LIST} ..." enable_services ${DEFAULT_SERVICE_LIST} ${SERVICE_LIST} +if [ -n "$ROOT_SHELL" ]; then + print_step "Changing the root shell ..." + change_shell +fi + if [ "${#INCLUDE_DIRS[@]}" -gt 0 ];then print_step "Copying directory structures into the rootfs ..." copy_include_directories