Skip to content

Commit aa90bbe

Browse files
authored
fix: sed only if writable (#157)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 7c3e98f commit aa90bbe

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

bin/run-network

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,16 @@ if ! test -e /data/db/protocolMagicId; then
4444
fi
4545

4646
# Enable TraceMempool and PeerSharing
47-
sed -i \
48-
-e 's/"PeerSharing": false/"PeerSharing": true/' \
49-
-e 's/"TraceMempool": false/"TraceMempool": true/' \
50-
/opt/cardano/config/${NETWORK}/config.json
47+
set +e
48+
# Check if our configuration is writable (may be different from permissions)
49+
touch /opt/cardano/config/${NETWORK}/config.json 2>&1 >/dev/null
50+
if test $? -eq 0; then
51+
sed -i \
52+
-e 's/"PeerSharing": false/"PeerSharing": true/' \
53+
-e 's/"TraceMempool": false/"TraceMempool": true/' \
54+
/opt/cardano/config/${NETWORK}/config.json
55+
fi
56+
set -e
5157

5258
echo "Starting: /usr/local/bin/cardano-node run"
5359
echo "--config /opt/cardano/config/${NETWORK}/config.json"

bin/run-node

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,16 @@ if [[ ${CARDANO_BLOCK_PRODUCER} == true ]]; then
7676
echo CARDANO_SHELLEY_VRF_KEY=${CARDANO_SHELLEY_VRF_KEY}
7777
echo CARDANO_SHELLEY_OPERATIONAL_CERTIFICATE=${CARDANO_SHELLEY_OPERATIONAL_CERTIFICATE}
7878
else
79-
sed -i \
80-
-e 's/"PeerSharing": false/"PeerSharing": true/' \
81-
-e 's/"TraceMempool": false/"TraceMempool": true/' \
82-
${CARDANO_CONFIG}
79+
set +e
80+
# Check if our configuration is writable (may be different from permissions)
81+
touch ${CARDANO_CONFIG} 2>&1 >/dev/null
82+
if test $? -eq 0; then
83+
sed -i \
84+
-e 's/"PeerSharing": false/"PeerSharing": true/' \
85+
-e 's/"TraceMempool": false/"TraceMempool": true/' \
86+
${CARDANO_CONFIG}
87+
fi
88+
set -e
8389
fi
8490

8591
echo AGGREGATOR_ENDPOINT=${AGGREGATOR_ENDPOINT}

0 commit comments

Comments
 (0)