forked from ghostchain/ghost-node
check-keys and insert-keys flags added
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
parent
86d762fca3
commit
40f9dcd2ee
@ -39,7 +39,29 @@ prompt() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
trap 'final "$?"' EXIT
|
sanity_check() {
|
||||||
|
secret_seed=$(ghost key inspect --scheme="$1" "$2" | grep "Secret seed" | awk '{ print $3 }')
|
||||||
|
account_id=$(ghost key inspect --scheme="$1" "$2" | grep "Account ID" | awk '{ print $3 }')
|
||||||
|
|
||||||
|
echo "[+] inspected account id for $3: $account_id"
|
||||||
|
num_keys=$(grep $account_id "$PROJECT_FOLDER/service/ghosties" | wc -l)
|
||||||
|
num_types=$(grep $account_id "$PROJECT_FOLDER/service/ghosties" | grep $3 | 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
|
||||||
|
}
|
||||||
|
|
||||||
|
extract_seed() {
|
||||||
|
name_with_spaces=$(echo $1 | tr '-' ' ')
|
||||||
|
read -p "[?] path to the file with $name_with_spaces: (default: /etc/ghost/$1) " seed_path
|
||||||
|
seed_path="${seed_path:-/etc/ghost/$1}"
|
||||||
|
if [ ! -f $seed_path ]; then
|
||||||
|
echo "[-] path to $name_with_spaces is not valid"
|
||||||
|
fi
|
||||||
|
seed=$(cat $seed_path)
|
||||||
|
echo $seed
|
||||||
|
}
|
||||||
|
|
||||||
help() {
|
help() {
|
||||||
echo -e "Ghost Node Build automation tool. Helper for Ghost Node environment preparation.\n"
|
echo -e "Ghost Node Build automation tool. Helper for Ghost Node environment preparation.\n"
|
||||||
@ -59,6 +81,8 @@ help() {
|
|||||||
echo -e "-h, --help\n\tPrints help information."
|
echo -e "-h, --help\n\tPrints help information."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trap 'final "$?"' EXIT
|
||||||
|
|
||||||
clear
|
clear
|
||||||
echo " ____ _ _ _ _ _"
|
echo " ____ _ _ _ _ _"
|
||||||
echo " / ___| |__ ___ ___| |_ | \ | | ___ __| | ___"
|
echo " / ___| |__ ___ ___| |_ | \ | | ___ __| | ___"
|
||||||
@ -325,15 +349,17 @@ if [[ $ARGUMENTS = true ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $CHECK_KEYS = true ]; then
|
if [ $CHECK_KEYS = true ]; then
|
||||||
read -p "[?] path to the file with session key: (default: /etc/ghost/session-key) " seed_path
|
seed=$(extract_seed "wallet-key")
|
||||||
seed_path="${seed_path:-/etc/ghost/session-key}"
|
sanity_check "sr25519" $seed "wallet"
|
||||||
if [ ! -f $seed_path ]; then
|
echo "[+] local wallet key found in 'ghosties' with correct key type"
|
||||||
echo "[-] path to session keys not valid"
|
echo
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "[+] path $seed_path is valid"
|
|
||||||
seed=$(cat $seed_path)
|
|
||||||
|
|
||||||
|
seed=$(extract_seed "stash-key")
|
||||||
|
sanity_check "sr25519" $seed "stash"
|
||||||
|
echo "[+] local stash key from found in 'ghosties' with correct key type"
|
||||||
|
echo
|
||||||
|
|
||||||
|
seed=$(extract_seed "session-key")
|
||||||
if [ $INSERT_KEYS = true ]; then
|
if [ $INSERT_KEYS = true ]; then
|
||||||
read -p "[?] JSON RPC endpoint to the node: (default: localhost:9945) " rpc_endpoint
|
read -p "[?] JSON RPC endpoint to the node: (default: localhost:9945) " rpc_endpoint
|
||||||
rpc_endpoint="${rpc_endpoint:-localhost:9945}"
|
rpc_endpoint="${rpc_endpoint:-localhost:9945}"
|
||||||
@ -346,17 +372,7 @@ if [ $CHECK_KEYS = true ]; then
|
|||||||
scheme="ed25519"
|
scheme="ed25519"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
secret_seed=$(ghost key inspect --scheme="$scheme" "$seed//$type" | grep "Secret seed" | awk '{ print $3 }')
|
sanity_check $scheme "$seed//$type" $type
|
||||||
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"
|
echo "[+] inspected account id found in 'ghosties' file with correct key type"
|
||||||
|
|
||||||
if [ $INSERT_KEYS = true ]; then
|
if [ $INSERT_KEYS = true ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user