|
|
@ -20,6 +20,32 @@ usage() |
|
|
|
echo "Usage: $0 -i <4mb_top_image>.rom" |
|
|
|
} |
|
|
|
|
|
|
|
check_battery() { |
|
|
|
local capacity=$(cat /sys/class/power_supply/BAT*/capacity 2>/dev/null || echo -ne "0") |
|
|
|
local online=$(cat /sys/class/power_supply/AC/online 2>/dev/null || cat /sys/class/power_supply/ADP*/online 2>/dev/null || echo -ne "0") |
|
|
|
local failed=0 |
|
|
|
|
|
|
|
if [ "${online}" == "0" ] ; then |
|
|
|
failed=1 |
|
|
|
fi |
|
|
|
if [ "${capacity}" -lt 25 ]; then |
|
|
|
failed=1 |
|
|
|
fi |
|
|
|
if [ $failed == "1" ]; then |
|
|
|
echo -e "${YELLOW}WARNING:${NC} To prevent shutdowns, we recommend to only run this script when" |
|
|
|
echo " your laptop is plugged in to the power supply AND" |
|
|
|
echo " the battery is present and sufficiently charged (over 25%)." |
|
|
|
while true; do |
|
|
|
read -r -p "Continue anyways? (please do NOT!) y/N: " yn |
|
|
|
case $yn in |
|
|
|
[Yy]* ) break;; |
|
|
|
[Nn]* ) exit;; |
|
|
|
* ) exit;; |
|
|
|
esac |
|
|
|
done |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
args=$(getopt -o i:h -- "$@") |
|
|
|
if [ $? -ne 0 ] ; then |
|
|
|
usage |
|
|
@ -106,6 +132,7 @@ echo "0x00800000:0x00bfffff bios" >> ${OUTPUT_PATH}/${LAYOUT_FILENAME} |
|
|
|
|
|
|
|
echo -e "${YELLOW}WARNING${NC}: Make sure not to power off your computer or interrupt this process in any way!" |
|
|
|
echo -e " Interrupting this process may result in irreparable damage to your computer!" |
|
|
|
check_battery |
|
|
|
while true; do |
|
|
|
read -r -p "Flash the BIOS now? y/N: " yn |
|
|
|
case $yn in |
|
|
|