install stage 1: all sorts of minor fixes and rc.conf configuration

master
BodgeMaster 2023-06-14 09:47:23 +02:00
parent b36a64f223
commit db6c18e67a
1 changed files with 111 additions and 9 deletions

View File

@ -15,13 +15,32 @@ function are_you_really_really_sure {
fi
}
function yesno {
unset DISCARD_ME
while [ -z "$DISCARD_ME" ]; do
read -p "[y/n]" -n1 DISCARD_ME
case "$DISCARD_ME" in
y)
return 0
;;
n)
return 1
;;
*)
echo " Please enter y for yes or n for no."
unset DISCARD_ME
;;
esac
done
}
clear
echo "
This script will now install Void Linux on your USB stick.
It will be formatted and will not be usable from Windows or MacOS.
This script will now download and install Void Linux on your USB stick.
Any data that is currently on the stick will be lost and it wont be
usable from Windows or MacOS.
Before we begin, lets make sure some dependencies are installed on the host/live system:
- up-to-date xbps
Before we begin, the following tools need to be installed:
- xmirror
- squashfs-tools"
press_any_key
@ -39,12 +58,13 @@ KBD_LAYOUT="de-latin1"
clear
echo "Select the USB stick to install to (NAME column below)...
"
lsblk --nodeps --output NAME,SIZE,MODEL
# exclude loop devices
lsblk --exclude 7 --nodeps --output NAME,SIZE,MODEL
echo ""
read -p "> " TARGET_DISK
while [ ! -b "/dev/$TARGET_DISK" ]; do
lsblk --nodeps --output NAME,SIZE,MODEL
lsblk --exclude 7 --nodeps --output NAME,SIZE,MODEL
echo "$TARGET_DISK is not a valid device!"
read -p "> " TARGET_DISK
done
@ -125,8 +145,11 @@ clear
echo "Storage is now prepared and ready for installation.
You need to select a download mirror for Void next.
The script will launch xmirror on the host system and read the mirror
from the config file it generates."
The script will launch xmirror on the host/live system and determine
the chosen mirror from the config file it generates.
TODO:
"
press_any_key
xmirror
@ -142,7 +165,7 @@ fi
mkdir -p /mnt/target/var/db/xbps/keys
cp /var/db/xbps/keys/* /mnt/target/var/db/xbps/keys/
XBPS_ARCH="$TARGET_TYPE" xbps-install -S -r /mnt/target -R "$TARGET_MIRROR" \
XBPS_ARCH="$TARGET_TYPE" xbps-install --yes --sync --rootdir /mnt/target --repository "$TARGET_MIRROR" \
linux bash shadow f2fs-tools dosfstools dbus NetworkManager iana-etc \
iw wpa_supplicant util-linux which tar man-pages iproute2 iputils \
wifi-firmware traceroute grep gzip file sed gawk less coreutils findutils \
@ -167,5 +190,84 @@ UUID=$(blkid --output value --match-tag UUID $TARGET_PART_EFI) /boot/efi vfat de
/container/home /home none bind 0 0
" > /mnt/target/etc/fstab
if grep "#KEYMAP=" /mnt/target/etc/rc.conf; then
sed -i -e 's/#KEYMAP=.*/KEYMAP="'"$KBD_LAYOUT"'"/'
else
clear
echo "WARNING: Could not locate the keymap setting in rc.conf."
echo "The script will attempt to add one."
echo ""
press_any_key
echo "" >> /mnt/target/etc/rc.conf
echo "# Install script could not find keymap setting, adding one here." >> /mnt/target/etc/rc.conf
echo "KEYMAP=\"$KBD_LAYOUT\"" >> /mnt/target/etc/rc.conf
fi
#TODO timezone
clear
echo "Set hardware clock to UTC?
Most Unix/Linux systems set the clock in your computer to UTC and add
the time zone on-the-fly. If you use Windows, you will want to answer no here.
"
if yesno; then
if grep "#HARDWARECLOCK=" /mnt/target/etc/rc.conf; then
sed -i -e 's/#HARDWARECLOCK=.*/HARDWARECLOCK="UTC"/'
else
clear
echo "WARNING: Could not locate the hardwareclock setting in rc.conf."
echo "The script will attempt to add one."
echo ""
press_any_key
echo "" >> /mnt/target/etc/rc.conf
echo "# Install script could not find hardwareclock setting, adding one here." >> /mnt/target/etc/rc.conf
echo 'HARDWARECLOCK="UTC"' >> /mnt/target/etc/rc.conf
fi
else
if grep "#HARDWARECLOCK=" /mnt/target/etc/rc.conf; then
sed -i -e 's/#HARDWARECLOCK=.*/HARDWARECLOCK="localtime"/'
else
clear
echo "WARNING: Could not locate the hardwareclock setting in rc.conf."
echo "The script will attempt to add one."
echo ""
press_any_key
echo "" >> /mnt/target/etc/rc.conf
echo "# Install script could not find hardwareclock setting, adding one here." >> /mnt/target/etc/rc.conf
echo 'HARDWARECLOCK="localtime"' >> /mnt/target/etc/rc.conf
fi
fi
clear
echo "Do you want to set a hostname?
This is equivalent to giving a name to your computer - except it's a system
on a USB drive.
If you leave this empty, it will be set to void-usb.
Allowed characters are a-zA-Z0-9 (and - in the middle).
"
while [ -z "$TARGET_HOSTNAME" ]; do
read -p "> " TARGET_HOSTNAME
if [ -z "$TARGET_HOSTNAME" ]; then
TARGET_HOSTNAME="void-usb"
else
if grep -e "^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$" -e "^[a-zA-Z0-9]*$" <<< "$TARGET_HOSTNAME" > /dev/null 2>&1; then
echo "$TARGET_HOSTNAME" > /mnt/target/etc/hostname
else
echo "Allowed characters are a-zA-Z0-9 (and - in the middle)."
unset TARGET_HOSTNAME
fi
fi
done
#