1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

Intercept mate-terminal RC + tee iiab-network errors to iiab-network.log

This commit is contained in:
root 2022-07-21 21:45:22 -04:00
parent 2530b779fc
commit 78e65f44dd
2 changed files with 24 additions and 33 deletions

View file

@ -1,13 +1,4 @@
#!/bin/sh
# Some OS's like Ubuntu with LightDM *IGNORE* the above shebang line when this
# script is invcked from /usr/share/mate/autostart/netwarn-iiab-network.desktop
#
# WHAT HAPPENS: sh (dash) NOT BASH will always be run! As confirmed by:
#
# ps -p $$ # Whereas 'echo $SHELL' DOES NOT show the actual running shell!
#
# RECAP: We hard-code the above '#!/bin/sh' for uniformity across all distros.
#!/bin/bash
if [ -f /etc/iiab/install-flags/iiab-network-complete ]; then
exit
@ -15,18 +6,19 @@ fi
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=$?
if [ "$rc" != "0" ]; then
if [[ $rc != "0" ]]; then
exit $rc
fi
x-terminal-emulator -e /usr/local/bin/iiab-network
rc=$?
if [ "$rc" != "0" ] && [ ! -f /usr/bin/mate-terminal ]; then
# 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
zenity --warning --width=360 --text="iiab-network exited with error: $rc\n\nPlease review /opt/iiab/iiab/iiab-network.log"
exit $rc
fi
zenity --question --width=360 --text="iiab-network complete.\n\nWould you like to REBOOT now? (Recommended)"
if [ "$?" = "0" ]; then
if [[ $? == "0" ]]; then
x-terminal-emulator -e "sudo reboot"
fi