Skip to content

Commit

Permalink
Better error handling during update
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdowne committed Nov 2, 2023
1 parent 6a15efb commit 8d6ba33
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions ethd
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ envmigrate() {
fi
fi
${__as_owner} cp "${ENV_FILE}" "${ENV_FILE}".source
__during_migrate=1
${__as_owner} cp default.env "${ENV_FILE}"
# Detect pre-merge
if grep -q "FALLBACK_NODE1" ".env.source"; then
Expand Down Expand Up @@ -899,7 +900,6 @@ envmigrate() {
for post-merge priority fees and, optionally, MEV. Please enter a valid ETH address in the next screen. Refer to \
Eth Docker docs (https://ethdocker.com/About/Rewards) for more information.\n\nCAUTION: \"./ethd up\" will fail if no \
valid address is set" 12 75
__during_update=1
query_coinbase
set_value_in_env
fi
Expand Down Expand Up @@ -959,6 +959,7 @@ Ethereum Merge.\n\nIf you run a distributed setup, you can shut off this nag scr
__el_adjusted=1
fi
${__as_owner} rm .env.original
__during_migrate=0
}


Expand Down Expand Up @@ -998,6 +999,7 @@ pull_and_build() {
# Arguments are passed, but shellcheck doesn't recognize that
# shellcheck disable=SC2120
update() {
__during_update=1
if [[ $(${__as_owner} git status --porcelain) ]]; then
__dirty=1
else
Expand Down Expand Up @@ -1083,7 +1085,6 @@ only"
;;
esac
done

# envmigrate used to be called w/ arguments and checks for that
# shellcheck disable=SC2119
envmigrate
Expand Down Expand Up @@ -1185,6 +1186,7 @@ value."
echo
${__as_owner} git status --porcelain
fi
__during_update=0
}


Expand Down Expand Up @@ -2591,7 +2593,18 @@ handle_error() {
elif [ "$exit_code" -eq 130 ]; then
echo "ethd terminated"
else
echo "ethd failed with error $exit_code"
echo
echo "ethd failed with error $exit_code on line $2"
if [ "$__during_update" -eq 1 ]; then
echo
echo "This happened during ethd update, which is a bug."
echo "Please come to Ethstaker Discord with logs to help me track this down."
if [ "$__during_migrate" -eq 1 ]; then
cp .env.source .env
echo
echo "Restored your .env file, which was partially migrated. Please verify it looks correct."
fi
fi
fi
}

Expand Down Expand Up @@ -2926,7 +2939,7 @@ printhelp() {


# Main body from here
trap 'handle_error $?' ERR
trap 'handle_error $? $LINENO' ERR

if [[ "$#" -eq 0 || "$1" == "help" || "$1" == "-h" || "$1" == "--help" ]]; then
printhelp
Expand All @@ -2950,6 +2963,7 @@ fi

ENV_FILE=.env
__during_update=0
__during_migrate=0

command="$1"
shift
Expand Down

0 comments on commit 8d6ba33

Please sign in to comment.