From 346d629f950a5d242530dc44e2a9dafcf62bad19 Mon Sep 17 00:00:00 2001 From: Uncle Stinky Date: Thu, 6 Feb 2025 16:21:04 +0300 Subject: [PATCH] validator flag added to the starter.sh script Signed-off-by: Uncle Stinky --- scripts/starter.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/scripts/starter.sh b/scripts/starter.sh index b544c37..9813e22 100755 --- a/scripts/starter.sh +++ b/scripts/starter.sh @@ -7,6 +7,7 @@ INSERT_KEYS=false UNIT_FILE=false SKIP_BUILD=false SET_ENVIRONMENT=false +VALIDATE=false EXECUTABLE_PATH="/usr/bin/" SPECIFICATION_PATH="/etc/ghost/" BASE_PATH="/var/lib/ghost" @@ -88,6 +89,7 @@ help() { echo -e "-k, --check-keys\n\tCheck if your keys are already included in 'ghosties' file." echo -e "-y, --insert-keys\n\tInsert session keys to the keystore via JSON RPC." echo -e "-r, --release\n\tCompile node with '--release' flag." + echo -e "-v, --validate\n\tManipulate '--validate' flag in CLI_ARGS." echo -e "-p, --profile\n\tCompile node with '--profile [PROFILE]' flag." echo -e "-f, --features\n\tCompilation features '--features=\"FEATURE1,FEATURE2\"'" echo -e "-e, --executable-path\n\tPath to the executable ('/usr/lib/' is default)." @@ -133,6 +135,9 @@ while [ $# -gt 0 ]; do RELEASE="--release" TARGET="release" ;; + --validate|-v) + VALIDATE=true + ;; --profile*|-p*) if [[ "$1" != *=* ]]; then shift; fi RELEASE="--profile=${1#*=}" @@ -263,6 +268,32 @@ if [[ ! -z $RELEASE ]]; then fi fi +if [[ ! -z $VALIDATE ]]; then + cli_args=$(cat /etc/default/ghost) + if prompt "[?] turn on validator mode?"; then + if [[ $cli_args == *"--validator"* ]]; then + echo "[+] '--validator' flag already exists in CLI_ARGS, check /etc/default/ghost" + else + cli_args="${cli_args%?} --validator\"" + echo "[+] '--validator' flag inserted to CLI_ARGS, check /etc/default/ghost" + fi + else + cli_args=${cli_args// --validator/} + echo "[+] '--validator' flag removed" + fi + + echo "[+] trying to store CLI updated arguments to '/etc/default/ghost'" + sudo echo "$cli_args" > /etc/default/ghost + echo "[+] updated CLI arguments stored in '/etc/default/ghost'" + + if prompt "[?] do you want to restart 'ghost-node.service' now?"; then + sudo systemctl status ghost-node.service + echo "[+] 'ghost-node.service' succefully restarted, new CLI_ARGS applied" + else + echo "[+] don't forget to restart ghost node service manually" + fi +fi + if [[ $MAKE_GLOBAL = true ]]; then cd $PROJECT_FOLDER echo "[+] trying to copy executable to '$EXECUTABLE_PATH'"