Skip to content

Commit e8a772d

Browse files
authored
Merge pull request #3134 from IntersectMBO/handle_state_dir_rm_errors
fix(start-cluster): handle state dir deletion errors
2 parents 514ddbf + 0695843 commit e8a772d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cardano_node_tests/cluster_scripts/testnets/start-cluster

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ TESTNET_DIR="${1:?"Testnet dir needed"}"
77
SCRIPT_DIR="$(readlink -m "${0%/*}")"
88
SOCKET_PATH="$(readlink -m "$CARDANO_NODE_SOCKET_PATH")"
99
STATE_CLUSTER="${SOCKET_PATH%/*}"
10+
# Fail if PWD is STATE_CLUSTER, as STATE_CLUSTER will be deleted
11+
if [ "$PWD" = "$STATE_CLUSTER" ]; then
12+
echo "Please run this script from outside of '$STATE_CLUSTER'" >&2
13+
exit 1
14+
fi
1015
STATE_CLUSTER_NAME="${STATE_CLUSTER##*/}"
1116
SUPERVISORD_SOCKET_PATH="${STATE_CLUSTER}/supervisord.sock"
1217
START_CLUSTER_LOG="${STATE_CLUSTER}/start-cluster.log"
@@ -31,7 +36,10 @@ if [ -e "$SCRIPT_DIR/shell_env" ]; then
3136
source "$SCRIPT_DIR/shell_env"
3237
fi
3338

34-
rm -rf "$STATE_CLUSTER"
39+
if ! ( rm -rf "$STATE_CLUSTER" || rm -rf "$STATE_CLUSTER"; ); then
40+
echo "Could not remove existing '$STATE_CLUSTER'" >&2
41+
exit 1
42+
fi
3543
mkdir -p "$STATE_CLUSTER"/{byron,shelley,webserver}
3644
cd "$STATE_CLUSTER/.."
3745

0 commit comments

Comments
 (0)