diff --git a/zcutil/fetch-params.sh b/zcutil/fetch-params.sh index 20cc8315d..8ca8477af 100755 --- a/zcutil/fetch-params.sh +++ b/zcutil/fetch-params.sh @@ -13,7 +13,6 @@ REGTEST_DIR="$PARAMS_DIR/regtest" # This should have the same params as regtest. We use symlinks for now. TESTNET3_DIR="$PARAMS_DIR/testnet3" - function fetch_params { local url="$1" local output="$2" @@ -38,26 +37,47 @@ function fetch_params { fi } -cat </$lockfile" + # acquire the lock + flock -n 200 \ + && return 0 \ + || return 1 +} + +function exit_locked_error { + echo "Only one instance of fetch-params.sh can be run at a time." >&2 + exit 1 +} + +function main() { + + lock fetch-params.sh \ + || exit_locked_error + + cat <> "$README_PATH" <> "$README_PATH" <