astrXbian/zen/tools/switch_ssb_identity.sh

42 lines
1.7 KiB
Bash
Raw Normal View History

2020-12-12 01:26:39 +01:00
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 2020.03.21
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
echo '
########################################################################
# \\///
# qo-op
############# '$MY_PATH/$ME'
########################################################################
__ __ _
(_ (_ |_) __ o _| _ ._ _|_ o _|_
__) __) |_) | (_| (/_ | | |_ | |_ \/
/ SWITCHing
########################################################################
'
# Taking care of 1st backup and linking
[ ! -L ~/.ssb ] && [ ! -d ~/.ssb_1st ] && echo "Making 1st backup" && mv ~/.ssb ~/.ssb_1st && ln -s ~/.ssb_1st ~/.ssb
# Choose Loop
for dir in $(ls -d ~/.ssb* | cut -d '_' -f 2); do
[ ! -e $dir ] && echo '
__
(_ _ _|_ _|_ | _ |_ _|_ _|_
__) (_ |_| |_ |_ | (/_ |_) |_| |_ |_ ID
' || continue
echo "Do you want to become $dir Identity ? (y)/n" && read isok
[[ "$isok" == "y" ]] && [ -L ~/.ssb ] && rm ~/.ssb && ln -s ~/.ssb_$dir ~/.ssb && echo "Welcome $dir" && break
done
echo 'Your SSB Identity is now linked to'
ls -l ~/.ssb
[ ! -f ~/.ssb/secret.dunikey ] && [ -f $MY_PATH/secret2dunikey.sh ] && $MY_PATH/secret2dunikey.sh
[ -f ~/.ssb/secret.dunikey ] && g1pub=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) && echo "G1SSB Wallet pubkey : $g1pub"