session key helper added
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
parent
7b59411e5f
commit
e850ed9aea
@ -2,6 +2,8 @@
|
||||
|
||||
set -Ee
|
||||
|
||||
CHECK_KEYS=false
|
||||
INSERT_KEYS=false
|
||||
UNIT_FILE=false
|
||||
SKIP_BUILD=false
|
||||
SET_ENVIRONMENT=false
|
||||
@ -46,6 +48,8 @@ help() {
|
||||
echo -e "-u, --unit-file\n\tCreation of systemd unit file."
|
||||
echo -e "-m, --make-global\n\tStore compiled ghost executable and chain specification globally."
|
||||
echo -e "-a, --set-arguments\n\tPrepare CLI arguments for running ghost node."
|
||||
echo -e "-k, --check-keys\n\tCheck if your keys are already included in 'ghosties' file."
|
||||
echo -e "-r, --insert-keys\n\tInsert session keys to the keystore via JSON RPC."
|
||||
echo -e "-r, --release\n\tCompile node with '--release' flag."
|
||||
echo -e "-p, --profile\n\tCompile node with '--profile [PROFILE]' flag."
|
||||
echo -e "-f, --features\n\tCompilation features '--features=\"FEATURE1,FEATURE2\"'"
|
||||
@ -79,6 +83,12 @@ while [ $# -gt 0 ]; do
|
||||
--set-arguments|-a)
|
||||
ARGUMENTS=true
|
||||
;;
|
||||
--check-keys|-k)
|
||||
CHECK_KEYS=true
|
||||
;;
|
||||
--insert-keys|-k)
|
||||
INSERT_KEYS=true
|
||||
;;
|
||||
--release|-r)
|
||||
RELEASE="--release"
|
||||
TARGET="release"
|
||||
@ -292,6 +302,11 @@ if [[ $ARGUMENTS = true ]]; then
|
||||
CLI_ARGS+=("--no-prometheus")
|
||||
fi
|
||||
|
||||
read -p "[?] list of bootnodes if any: " bootnodes
|
||||
if [ ! -z $bootnodes ]; then
|
||||
CLI_ARGS+=("--bootnodes=$bootnodes")
|
||||
fi
|
||||
|
||||
# default for now
|
||||
CLI_ARGS+=("--base-path=$NODE_PATH")
|
||||
CLI_ARGS+=("--state-pruning=archive")
|
||||
@ -308,3 +323,49 @@ if [[ $ARGUMENTS = true ]]; then
|
||||
echo "[+] new CLI arguments stored in '/etc/default/ghost'"
|
||||
cat /etc/default/ghost
|
||||
fi
|
||||
|
||||
if [ $CHECK_KEYS = true ]; then
|
||||
read -p "[?] path to the file with session key: (default: /etc/ghost/session-key) " seed_path
|
||||
seed_path="${seed_path:-/etc/ghost/session-key}"
|
||||
if [ ! -f $seed_path ]; then
|
||||
echo "[-] path to session keys not valid"
|
||||
exit 1
|
||||
fi
|
||||
echo "[+] path $seed_path is valid"
|
||||
seed=$(cat $seed_path)
|
||||
|
||||
if [ $INSERT_KEYS = true ]; then
|
||||
read -p "[?] JSON RPC endpoint to the node: (default: localhost:9945) " rpc_endpoint
|
||||
rpc_endpoint="${rpc_endpoint:-localhost:9945}"
|
||||
fi
|
||||
|
||||
for type in $(echo audi babe gran slow); do
|
||||
echo "[+] parsing session key for [$type]"
|
||||
scheme="sr25519"
|
||||
if [ $type = "gran" ]; then
|
||||
scheme="ed25519"
|
||||
fi
|
||||
|
||||
secret_seed=$(ghost key inspect --scheme="$scheme" "$seed//$type" | grep "Secret seed" | awk '{ print $3 }')
|
||||
account_id=$(ghost key inspect --scheme="$scheme" "$seed//$type" | grep "Account ID" | awk '{ print $3 }')
|
||||
|
||||
echo "[+] inspected account id: $account_id"
|
||||
num_keys=$(grep $account_id "$PROJECT_FOLDER/service/ghosties" | wc -l)
|
||||
num_types=$(grep $account_id "$PROJECT_FOLDER/service/ghosties" | grep $type | wc -l)
|
||||
if [ ! $num_keys = 1 ] || [ ! $num_types = 1 ]; then
|
||||
echo "[-] inspected account id not found on 'ghosties' file or wrong key type"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[+] inspected account id found in 'ghosties' file with correct key type"
|
||||
|
||||
if [ $INSERT_KEYS = true ]; then
|
||||
echo "[+] trying to make an 'author_insertKey' RPC call to $rpc_endpoint..."
|
||||
curl --location $rpc_endpoint \
|
||||
--header "Content-Type: application/json" \
|
||||
--data '{ "id":1, "jsonrpc":"2.0", "method":"author_insertKey", "params": ["'"$type"'", "'"$secret_seed"'", "'"$account_id"'"] }'
|
||||
fi
|
||||
echo
|
||||
done
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user