hard reset flag added to starter script

Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
Uncle Stinky 2025-07-28 13:10:07 +03:00
parent d575895841
commit 67fd48d500
Signed by: st1nky
GPG Key ID: 016064BD97603B40

View File

@ -2,6 +2,7 @@
set -Ee
HARD_RESET=false
CHECK_KEYS=false
INSERT_KEYS=false
UNIT_FILE=false
@ -96,6 +97,7 @@ help() {
echo -e "-s, --base-path\n\tPath to the folder with chain database ('/var/lib/ghost' is default)."
echo -e "-c, --specification-path\n\tPath to specification ('/etc/ghost' is default)."
echo -e "-n, --specification-name\n\tSpecification name to be used ('casper' is default)."
echo -e "--hard-reset-i-know-what-im-doing\n\tWill completely remove ledger along with associated session keys."
echo -e "-h, --help\n\tPrints help information."
}
@ -163,6 +165,9 @@ while [ $# -gt 0 ]; do
if [[ "$1" != *=* ]]; then shift; fi
SPECIFICATION_NAME="${1#*=}"
;;
--hard-reset-i-know-what-im-doing)
HARD_RESET=true
;;
--help|-h)
help
exit 0
@ -175,6 +180,51 @@ while [ $# -gt 0 ]; do
shift
done
if [[ $HARD_RESET = true ]]; then
echo -e "\n"
echo "WARNING!!! THIS ACTION WILL COMPLETELY PURGE THE LEDGER AND REBUILD THE NODE USING THE LATEST"
echo "REPOSITORY VERSION. NOTE THAT THE VALIDATION PROCESS WILL BE LOST BECAUSE SESSION OF KEYS."
echo "THERE ARE TWO SCENARIOS IN WHICH YOU MIGHT NEED TO PROCEED:"
echo -e "\t- A new version of the network hsa been released, and a restart is neccessary"
echo -e "\t- There is a critical issue, and you require a hard reset of the node in a single command"
echo -e "\n"
if prompt "[?] do you understand all risks?"; then
echo "[+] you were warned, I hope you know what you're doing"
else
echo "[-] aborting hard reset"
exit 1
fi
cd $PROJECT_FOLDER
# TODO: uncomment later
# echo "[+] fetching the latest ghost-node source code"
# git switch main
# git pull origin main
cd $PROJECT_FOLDER
echo "[+] starting build in 3 seconds..."
sleep 3
cargo build $RELEASE $FEATURES
echo "[+] trying to stop current ghost-node"
sudo systemctl stop ghost-node
echo "[+] trying to remove locally stored ledger"
sudo rm -rf "$BASE_PATH/chains/*"
cd $PROJECT_FOLDER
echo "[+] trying to copy executable to '$EXECUTABLE_PATH'"
sudo cp target/$TARGET/ghost $EXECUTABLE_PATH
cp service/chain-specs/$SPECIFICATION_NAME.json $SPECIFICATION_PATH
echo "[+] ghost executable copied in '$EXECUTABLE_PATH' from '$TARGET'"
echo "[+] specification '$SPECIFICATION_NAME.json' copied to '$SPECIFICATION_PATH'"
echo "[+] starting ghost-node"
sudo systemctl start ghost-node
exit 0
fi
if [[ $SET_ENVIRONMENT = true ]]; then
echo -e "\n"
echo "WARNING!!! THIS IS HIGHLY EXPERIMENTAL FLAG, USE IT ONLY ON YOUR"
@ -262,7 +312,7 @@ fi
if [[ ! -z $RELEASE ]]; then
if prompt "[?] 'cargo build $RELEASE $FEATURES' is what you want?"; then
cd $PROJECT_FOLDER
echo "[+] Starting build in 3 seconds..."
echo "[+] starting build in 3 seconds..."
sleep 3
cargo build $RELEASE $FEATURES
fi
@ -347,7 +397,6 @@ if [[ $ARGUMENTS = true ]]; then
CLI_ARGS+=("--public-addr=$public_addr")
fi
# default for now
CLI_ARGS+=("--telemetry-url='wss://telemetry.ghostchain.io/submit/ 9'")
CLI_ARGS+=("--base-path=$BASE_PATH")