82 lines
1.7 KiB
Bash
82 lines
1.7 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
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 ""
|
|
return 0
|
|
;;
|
|
n)
|
|
echo ""
|
|
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
|
|
|
|
bash --norc --noprofile
|