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

@ -4,11 +4,15 @@
CWD=`pwd` CWD=`pwd`
export ANSIBLE_LOG_PATH="$CWD/iiab-network.log" export ANSIBLE_LOG_PATH="$CWD/iiab-network.log"
if [ ! -f iiab-network.yml ]; then exit_error() {
echo "iiab-network.yml not found in current directory." echo -e "\nEXITING: "$@ | tee -a /opt/iiab/iiab/iiab-network.log
echo "Please rerun this command from the top level of the git repo."
echo "Exiting."
exit 1 exit 1
}
if [ ! -f iiab-network.yml ]; then
exit_error "iiab-network.yml not found in current directory." \
"Please rerun this command from the top level of the git repo." \
"Exiting."
fi fi
OS="unknown" # will be overridden below, if /etc/iiab/iiab.env is legit OS="unknown" # will be overridden below, if /etc/iiab/iiab.env is legit
@ -19,26 +23,21 @@ if [ -f /etc/iiab/iiab.env ]; then
if grep -q STAGE= /etc/iiab/iiab.env ; then if grep -q STAGE= /etc/iiab/iiab.env ; then
echo -e "\nExtracted STAGE=$STAGE (counter) from /etc/iiab/iiab.env" echo -e "\nExtracted STAGE=$STAGE (counter) from /etc/iiab/iiab.env"
if ! [ "$STAGE" -eq "$STAGE" ] 2> /dev/null; then if ! [ "$STAGE" -eq "$STAGE" ] 2> /dev/null; then
echo -e "\nEXITING: STAGE (counter) value == ""$STAGE"" is non-integer" exit_error "STAGE (counter) value == ""$STAGE"" is non-integer"
exit 1
elif [ "$STAGE" -lt 0 ] || [ "$STAGE" -gt 9 ]; then elif [ "$STAGE" -lt 0 ] || [ "$STAGE" -gt 9 ]; then
echo -e "\nEXITING: STAGE (counter) value == ""$STAGE"" is out-of-range" exit_error "STAGE (counter) value == ""$STAGE"" is out-of-range"
exit 1
elif [ "$STAGE" -lt 3 ]; then elif [ "$STAGE" -lt 3 ]; then
echo -e "\nEXITING: STAGE (counter) value == ""$STAGE" exit_error "STAGE (counter) value == ""$STAGE" \
echo -e "\nIIAB Stage 3 not complete." "\nIIAB Stage 3 not complete." \
echo -e "\nPlease run: ./iiab-install" "\nPlease run: ./iiab-install"
exit 1
fi fi
else else
echo -e "\nEXITING: STAGE (counter) not found" exit_error "STAGE (counter) not found" \
echo -e "\nIIAB not installed." "\nIIAB not installed." \
echo -e "\nPlease run: ./iiab-install" "\nPlease run: ./iiab-install"
exit 1
fi fi
else else
echo -e "\nEXITING: /etc/iiab/iiab.env not found" exit_error "/etc/iiab/iiab.env not found"
exit 1
fi fi
echo "Ansible will now run iiab-network.yml -- log file is iiab-network.log" echo "Ansible will now run iiab-network.yml -- log file is iiab-network.log"

View file

@ -1,13 +1,4 @@
#!/bin/sh #!/bin/bash
# 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.
if [ -f /etc/iiab/install-flags/iiab-network-complete ]; then if [ -f /etc/iiab/install-flags/iiab-network-complete ]; then
exit 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)" 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=$? rc=$?
if [ "$rc" != "0" ]; then if [[ $rc != "0" ]]; then
exit $rc exit $rc
fi fi
x-terminal-emulator -e /usr/local/bin/iiab-network # mate-terminal always returns 255 w/ autostart, so intercept/record return code
rc=$? x-terminal-emulator -e "bash -c '/usr/local/bin/iiab-network; echo \"\$?\" > /tmp/iiab-network.rc'"
if [ "$rc" != "0" ] && [ ! -f /usr/bin/mate-terminal ]; then 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" zenity --warning --width=360 --text="iiab-network exited with error: $rc\n\nPlease review /opt/iiab/iiab/iiab-network.log"
exit $rc exit $rc
fi fi
zenity --question --width=360 --text="iiab-network complete.\n\nWould you like to REBOOT now? (Recommended)" 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" x-terminal-emulator -e "sudo reboot"
fi fi