2022-07-22 01:45:22 +00:00
#!/bin/bash
2022-07-21 18:02:14 +00:00
2023-12-17 04:51:24 +00:00
# CONFUSING BUT FYI: Steps below run *strictly sequentially* when this script
# (/usr/local/sbin/iiab-netwarn) is run on boot, triggered by either autostart:
# https://specifications.freedesktop.org/autostart-spec/autostart-spec-latest.html
2024-12-12 21:54:44 +00:00
# ...or by Wayland compositor's ~/.config/labwc/autostart in new RasPiOS 12+:
# https://forums.raspberrypi.com/viewtopic.php?t=379321
# (Prior to Dec 2024, RasPiOS compositor Wayfire did the same...)
# https://github.com/iiab/iiab/pull/3685
2023-12-17 04:51:24 +00:00
# https://github.com/WayfireWM/wayfire/wiki/Configuration#autostart
#
# This allows return codes ($rc) to be meaningful, at each successive step.
2022-07-27 19:53:46 +00:00
# (As of July 2022, this is tested to work well with Ubuntu Mate and "Raspberry
# Pi OS with desktop" on Raspberry Pi 4!)
2022-07-27 16:55:20 +00:00
#
# IN CONTRAST: return codes below are NOT MEANINGFUL when this script is
2023-12-17 12:16:59 +00:00
# invoked manually after boot from a regular graphical desktop session -- so
# make sure to test (either kind of) "autostart" during actual OS boot-up!
2022-07-27 16:55:20 +00:00
2022-07-19 01:33:08 +00:00
if [ -f /etc/iiab/install-flags/iiab-network-complete ]; then
exit
fi
2022-07-21 18:02:14 +00:00
zenity --question --width=360 --text="IIAB needs to configure networking:\n\n► Internet must be live before you begin.\n►You might be prompted for your password.\n\nContinue? (This can take 2-3 minutes)"
rc=$?
2022-07-22 01:45:22 +00:00
if [[ $rc != "0" ]]; then
2022-07-21 18:02:14 +00:00
exit $rc
fi
2022-07-19 01:33:08 +00:00
2022-07-22 01:45:22 +00:00
# mate-terminal always returns 255 w/ autostart, so intercept/record return code
x-terminal-emulator -e "bash -c '/usr/local/bin/iiab-network; echo \"\$?\" > /tmp/iiab-network.rc'"
rc=$(cat /tmp/iiab-network.rc)
if [[ $rc != "0" ]]; then
2022-07-21 18:02:14 +00:00
zenity --warning --width=360 --text="iiab-network exited with error: $rc\n\nPlease review /opt/iiab/iiab/iiab-network.log"
exit $rc
2022-07-19 01:33:08 +00:00
fi
2022-07-21 18:02:14 +00:00
zenity --question --width=360 --text="iiab-network complete.\n\nWould you like to REBOOT now? (Recommended)"
2022-07-22 01:45:22 +00:00
if [[ $? == "0" ]]; then
2022-07-19 01:33:08 +00:00
x-terminal-emulator -e "sudo reboot"
2022-07-16 16:45:29 +00:00
fi