44 lines
838 B
Bash
44 lines
838 B
Bash
#!/usr/bin/env bash
|
|
|
|
if [ ! "$(whoami)" = "root" ]; then
|
|
echo "$0 needs to run as root!"
|
|
exit 1
|
|
fi
|
|
|
|
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
|
|
}
|
|
|
|
if [ "$1" = "--defer" ]; then
|
|
touch "/run/void-usb/system-image-auto-confirm-marker"
|
|
exit 0
|
|
else
|
|
echo "This will cause the system to reboot. Alternatively, you can invoke
|
|
$0 with --defer to save the image on next shutdown/reboot.
|
|
|
|
Save system image and reboot?"
|
|
if yesno; then
|
|
touch "/run/void-usb/system-image-auto-confirm-marker"
|
|
reboot
|
|
else
|
|
exit 1
|
|
fi
|
|
fi
|