Skip to content

Commit

Permalink
sh: update cleanup.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0Vu committed Dec 5, 2023
1 parent d8bd26b commit 67bd472
Showing 1 changed file with 62 additions and 60 deletions.
122 changes: 62 additions & 60 deletions testnet/local/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,71 @@

echo "Clean up data generated when execute scripts..."

NOW=$(TZ=UTC date +"%Y-%m-%dT%H:%M:%S.000000Z")
TITLE="\"genesis_time\""
# NOW=$(TZ=UTC date +"%Y-%m-%dT%H:%M:%S.000000Z")
# TITLE="\"genesis_time\""

clean_mix_dir () {
d=$1
if [ -d $d ]; then
echo "Clean mix data: $d"
if [ -d $d/data ]; then
rm -rf $d/data/*
fi;
fi;
}
# clean_mix_dir () {
# d=$1
# if [ -d $d ]; then
# echo "Clean mix data: $d"
# if [ -d $d/data ]; then
# rm -rf $d/data/*
# fi;
# fi;
# }

clean_provider_dir () {
d=$1
if [ -d $d ]; then
echo "Clean provider data: $d"
if [ -d $d/data ]; then
rm -rf $d/data/*
fi;
if [ -f $d/cpu.prof ]; then
rm -rf $d/cpu.prof
fi;
if [ -f $d/mem.prof ]; then
rm -rf $d/mem.prof
fi;
fi;
}
# clean_provider_dir () {
# d=$1
# if [ -d $d ]; then
# echo "Clean provider data: $d"
# if [ -d $d/data ]; then
# rm -rf $d/data/*
# fi;
# if [ -f $d/cpu.prof ]; then
# rm -rf $d/cpu.prof
# fi;
# if [ -f $d/mem.prof ]; then
# rm -rf $d/mem.prof
# fi;
# fi;
# }

clean_katzenmint_dir () {
d=$1
if [ -d $d ]; then
echo "Clean katzenmint data: $d"
if [ ! -d $d/data ]; then
mkdir $d/data
fi;
if [ -d $d/data ]; then
rm -rf $d/data/*
fi;
if [ -d $d/kdata ]; then
rm -rf $d/kdata/*
fi;
if [ -d $d/katzenmint ]; then
rm -rf $d/katzenmint
fi;
if [ -d $d/config ]; then
rm -rf $d/config/write-file-atomic*
fi;
echo "{
\"height\": \"0\",
\"round\": 0,
\"step\": 0
}" > $d/data/priv_validator_state.json
# Update genesis block time
perl -i -pe"s/$TITLE.*/$TITLE: \"$NOW\",/g" $d/config/genesis.json
fi;
}
# clean_katzenmint_dir () {
# d=$1
# if [ -d $d ]; then
# echo "Clean katzenmint data: $d"
# if [ ! -d $d/data ]; then
# mkdir $d/data
# fi;
# if [ -d $d/data ]; then
# rm -rf $d/data/*
# fi;
# if [ -d $d/kdata ]; then
# rm -rf $d/kdata/*
# fi;
# if [ -d $d/katzenmint ]; then
# rm -rf $d/katzenmint
# fi;
# if [ -d $d/config ]; then
# rm -rf $d/config/write-file-atomic*
# fi;
# echo "{
# \"height\": \"0\",
# \"round\": 0,
# \"step\": 0
# }" > $d/data/priv_validator_state.json
# # Update genesis block time
# perl -i -pe"s/$TITLE.*/$TITLE: \"$NOW\",/g" $d/config/genesis.json
# fi;
# }

for d in conf/* ; do
[ -L "${d%/}" ] && continue
[[ $d =~ ^conf/mix[1-3] ]] && clean_mix_dir $d
[[ $d =~ ^conf/provider[1-3] ]] && clean_provider_dir $d
[[ $d =~ ^conf/node[1-4] ]] && clean_katzenmint_dir $d
done
# for d in conf/* ; do
# [ -L "${d%/}" ] && continue
# [[ $d =~ ^conf/mix[1-3] ]] && clean_mix_dir $d
# [[ $d =~ ^conf/provider[1-3] ]] && clean_provider_dir $d
# [[ $d =~ ^conf/node[1-4] ]] && clean_katzenmint_dir $d
# done

git checkout HEAD conf

echo "Cleaned up!"

0 comments on commit 67bd472

Please sign in to comment.