From c35f412cf4648f1a8e90999a3f87d5699d54f080 Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Mon, 30 Mar 2026 03:31:20 +0200 Subject: [PATCH] install stage 1: add timezone picker, set SEEDRNG_SKIP_CREDIT --- install-stage1.sh | 102 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 101 insertions(+), 1 deletion(-) diff --git a/install-stage1.sh b/install-stage1.sh index 897ecac..63f46be 100644 --- a/install-stage1.sh +++ b/install-stage1.sh @@ -324,7 +324,105 @@ else echo "KEYMAP=\"$KBD_LAYOUT\"" >> /mnt/target/etc/rc.conf fi -#TODO timezone +clear +REGIONS="$(find /usr/share/zoneinfo/ -mindepth 1 -maxdepth 1 -type d -exec basename \{\} \; | sort)" +I=1 +echo " +To set up time zone information, you will now be prompted for a region and location. +The location should be the one that determines your timezone, it isn't necessarily the one nearest to you. + +Please choose a region:" +for REGION in $REGIONS; do + echo "$I: $REGION" + I=$((I+1)) +done +REGION="" +CHOICE=0 +while ! [ "$CHOICE" -gt 0 -a "$CHOICE" -le "$(wc -l <<< "$REGIONS")" ]; do + read -p "Select an option [1-$(wc -l <<< "$REGIONS")]: " CHOICE + if [ "$CHOICE" -gt 0 -a "$CHOICE" -le "$(wc -l <<< "$REGIONS")" ]; then + REGION="$(sed -n -e "${CHOICE}p" <<< "$REGIONS")" + else + echo "Invalid choice." + fi +done +LOCATIONS="$(find /usr/share/zoneinfo/"$REGION"/ -mindepth 1 -maxdepth 1 -exec basename \{\} \; | sort)" +I=1 +echo " +Please choose a location or sub-region:" +for LOCATION in $LOCATIONS; do + if [ "$((I % 3))" -eq 0 ]; then + echo "$I: $LOCATION" + else + echo -n "$I: $LOCATION" + echo -ne "\t" + fi + I=$((I+1)) +done +LOCATION="" +CHOICE=0 +while ! [ "$CHOICE" -gt 0 -a "$CHOICE" -le "$(wc -l <<< "$LOCATIONS")" ]; do + read -p "Select an option [1-$(wc -l <<< "$LOCATIONS")]: " CHOICE + if [ "$CHOICE" -gt 0 -a "$CHOICE" -le "$(wc -l <<< "$LOCATIONS")" ]; then + LOCATION="$(sed -n -e "${CHOICE}p" <<< "$LOCATIONS")" + else + echo "Invalid choice." + fi +done +if [ -d "/usr/share/zoneinfo/$REGION/$LOCATION" ]; then + REGION="$REGION/$LOCATION" + LOCATIONS="$(find /usr/share/zoneinfo/"$REGION"/ -mindepth 1 -maxdepth 1 -exec basename \{\} \; | sort)" + I=1 + echo " + Please choose a location:" + for LOCATION in $LOCATIONS; do + if [ "$((I % 3))" -eq 0 ]; then + echo "$I: $LOCATION" + else + echo -n "$I: $LOCATION" + echo -ne "\t" + fi + I=$((I+1)) + done + LOCATION="" + CHOICE=0 + while ! [ "$CHOICE" -gt 0 -a "$CHOICE" -le "$(wc -l <<< "$LOCATIONS")" ]; do + read -p "Select an option [1-$(wc -l <<< "$LOCATIONS")]: " CHOICE + if [ "$CHOICE" -gt 0 -a "$CHOICE" -le "$(wc -l <<< "$LOCATIONS")" ]; then + LOCATION="$(sed -n -e "${CHOICE}p" <<< "$LOCATIONS")" + else + echo "Invalid choice." + fi + done +fi +TIMEZONE="$REGION/$LOCATION" +echo "Configuring timezone." +if grep "#TIMEZONE=" /mnt/target/etc/rc.conf; then + sed -i -e 's/#TIMEZONE=.*/TIMEZONE="'"$TIMEZONE"'"/' /mnt/target/etc/rc.conf +else + clear + echo "WARNING: Could not locate the time zone setting in rc.conf." | tee --append $LOGFILE + echo "The script will attempt to add one." | tee --append $LOGFILE + echo "" + press_any_key + echo "" >> /mnt/target/etc/rc.conf + echo "# Install script could not find time zone setting, adding one here." >> /mnt/target/etc/rc.conf + echo "TIMEZONE=\"$TIMEZONE\"" >> /mnt/target/etc/rc.conf +fi + +echo "Setting SEEDRNG_SKIP_CREDIT=true" +if grep "#SEEDRNG_SKIP_CREDIT=" /mnt/target/etc/rc.conf; then + sed -i -e 's/#SEEDRNG_SKIP_CREDIT=.*/SEEDRNG_SKIP_CREDIT=true/' /mnt/target/etc/rc.conf +else + clear + echo "WARNING: Could not locate the SEEDRNG_SKIP_CREDIT setting in rc.conf." | tee --append $LOGFILE + echo "The script will attempt to add one." | tee --append $LOGFILE + echo "" + press_any_key + echo "" >> /mnt/target/etc/rc.conf + echo "# Install script could not find SEEDRNG_SKIP_CREDIT setting, adding one here." >> /mnt/target/etc/rc.conf + echo "SEEDRNG_SKIP_CREDIT=true" >> /mnt/target/etc/rc.conf +fi clear echo "Assume that the hardware clock is UTC? @@ -386,6 +484,8 @@ done echo "$TARGET_HOSTNAME" > /mnt/target/etc/hostname +#TODO: set up / fix locale on glibc + clear echo -n "Installing bootloader... " mkdir /mnt/target/boot/efi/LOADER >> $LOGFILE 2>&1