void-minecraft-usb/install-stage2.sh

120 lines
2.9 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2023-07-03 14:12:55 +02:00
LOGFILE=/tmp/void-usb-install-log
function press_any_key {
echo "Press any key to continue or Ctrl+c to abort..."
read -n1 DISCARD_ME
echo ""
}
function yesno {
unset DISCARD_ME
while [ -z "$DISCARD_ME" ]; do
read -p "[y/n] " -n1 DISCARD_ME
case "$DISCARD_ME" in
y)
echo ""
2023-07-03 14:12:55 +02:00
return 0
;;
n)
echo ""
2023-07-03 14:12:55 +02:00
return 1
;;
*)
echo " Please enter y for yes or n for no."
unset DISCARD_ME
;;
esac
done
}
[ -z "$TERM" ] && export TERM=linux
echo -n "Checking for internet connection..."
INTERNET="down"
WAITING=0
while [ "$INTERNET" = "down" -a "$WAITING" -lt 15 ]; do
sleep 1
if ping -c2 repo-default.voidlinux.org >> $LOGFILE 2>&1; then
INTERNET="up"
fi
WAITING=$((WAITING+1))
echo -n "."
done
echo " $INTERNET"
if [ "$INTERNET" = "down" ]; then
clear
echo "Connect to WiFi?
Any network settings from before the reboot have not been saved and need to be entered again.
Use 'Activate a connection' in the dialog to select your network.
Alternatively, you can continue without internet but the system will be left in a barebones state.
"
if yesno; then
nmtui
clear
echo -n "Checking for internet connection..."
WAITING=0
while [ "$INTERNET" = "down" -a "$WAITING" -lt 15 ]; do
sleep 1
if ping -c2 repo-default.voidlinux.org >> $LOGFILE 2>&1; then
INTERNET="up"
fi
WAITING=$((WAITING+1))
echo -n "."
done
echo " $INTERNET"
fi
fi
if [ "$INTERNET" = "up" ]; then
echo -n "Retrieving package lists... "
xbps-install --sync >>$LOGFILE 2>&1
echo "done"
fi
readarray -t SECTIONS < /opt/void-usb/installer/package_selections/sections.lst
for I in ${!SECTIONS[@]}; do
readarray -t OPTIONS < "/opt/void-usb/installer/package_selections/${SECTIONS[$I]}/options.lst"
AVAILABLE_OPTIONS=()
for J in ${!OPTIONS[@]}; do
source "/opt/void-usb/installer/package_selections/${SECTIONS[$I]}/${OPTIONS[$J]}"
if check; then
AVAILABLE_OPTIONS+=("${OPTIONS[$J]}")
fi
done
if [ -z "${AVAILABLE_OPTIONS[1]}" ]; then
# no need to ask, there is only one option anyway
CHOICE="${AVAILABLE_OPTIONS[0]}"
else
clear
cat "/opt/void-usb/installer/package_selections/${SECTIONS[$I]}/description.txt"
echo ""
2023-07-03 14:12:55 +02:00
for J in ${!AVAILABLE_OPTIONS[@]}; do
source "/opt/void-usb/installer/package_selections/${SECTIONS[$I]}/${AVAILABLE_OPTIONS[$J]}"
echo "$J: $DESCRIPTION"
done
CHOICE=""
while [ -z "$CHOICE" ]; do
echo ""
2023-07-03 14:12:55 +02:00
echo "Select by entering the corresponding number."
read -p "> " CHOICE_NUMBER
grep "^[0-9]*$" <<< "$CHOICE_NUMBER" && CHOICE="${AVAILABLE_OPTIONS[$CHOICE_NUMBER]}"
2023-07-03 14:12:55 +02:00
done
fi
source "/opt/void-usb/installer/package_selections/${SECTIONS[$I]}/$CHOICE"
if [ -n "$PACKAGES" ]; then
xbps-install --yes $PACKAGES
fi
post_install
done
bash --norc --noprofile