Skip to content

Commit e82e64c

Browse files
authored
Remove lockfile on fail (#2613)
1 parent 30a4398 commit e82e64c

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

ethd

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ __source_ver=1
4949
__minty_fresh=0
5050
__network_change=0
5151
__handler_ran=0
52+
__lock_file=""
5253
__deployment=""
5354
__write_vars=()
5455
__command=""
@@ -2270,7 +2271,6 @@ update() {
22702271
local targetcli
22712272
local script_dir
22722273
local uniq_id
2273-
local lock_file
22742274
local screen_session
22752275
local old_sessions
22762276
local session_id
@@ -2292,9 +2292,9 @@ update() {
22922292
# Only one copy of update() should run per Eth Docker stack
22932293
script_dir="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
22942294
uniq_id="${script_dir//\//_}"
2295-
lock_file="${uniq_id}_lock"
2296-
${__as_owner} touch "/tmp/${lock_file}"
2297-
exec 200<"/tmp/${lock_file}"
2295+
__lock_file="${uniq_id}_lock"
2296+
${__as_owner} touch "/tmp/${__lock_file}"
2297+
exec 200<"/tmp/${__lock_file}"
22982298
if ! flock -n 200; then
22992299
echo "Another instance of \"${__me} update\" is running. Aborting."
23002300
exit 1
@@ -2564,7 +2564,7 @@ reset to defaults."
25642564
if [[ ! "$OSTYPE" = "darwin"* ]]; then
25652565
# Release lock and remove lock file
25662566
exec 200<&-
2567-
${__as_owner} rm -f "/tmp/${lock_file}"
2567+
${__as_owner} rm -f "/tmp/${__lock_file}"
25682568
fi
25692569

25702570
if [[ -n "${STY:-}" || -n "${TMUX:-}" ]]; then
@@ -5542,6 +5542,10 @@ __handle_error() {
55425542
local line=$2
55435543
local calling_line=$3
55445544

5545+
if [[ -f /tmp/"${__lock_file}" ]]; then
5546+
${__as_owner} rm -f "/tmp/${__lock_file}"
5547+
fi
5548+
55455549
if [[ ! $- =~ e ]]; then
55465550
# set +e, do nothing
55475551
return 0

0 commit comments

Comments
 (0)