From 19b747ae7f1bdf17c798f3ffc11be503c255b8e2 Mon Sep 17 00:00:00 2001 From: qo-op Date: Sun, 6 Dec 2020 02:38:19 +0100 Subject: [PATCH] better code --- .install/update_bashrc.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.install/update_bashrc.sh b/.install/update_bashrc.sh index 4973eb0..814f947 100755 --- a/.install/update_bashrc.sh +++ b/.install/update_bashrc.sh @@ -8,11 +8,14 @@ # Add $YOU $IPFSNODEID $G1PUB to ~/.bashrc source ~/.bashrc + [[ $YOU != "" && $IPFSNODEID != "" && $G1PUB != "" ]] && er+="bashrc already updated" -export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) || er+=" ipfs daemon not running" -export IPFSNODEID=$(ipfs id -f='\n') || er+=" ipfs id problem" -export G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) || er+=" ~/.zen/secret.dunikey not found" +YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) || er+=" ipfs daemon not running" + +IPFSNODEID=$(ipfs id -f='\n') || er+=" ipfs id problem" + +[[ -f ~/.zen/secret.dunikey ]] && G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) || er+=" ~/.zen/secret.dunikey missing cannot find G1PUB" [[ $er != "" ]] && echo "$er" && exit 1 @@ -20,8 +23,10 @@ echo "### ASTROPORT IDENTITY ###" >> ~/.bashrc echo "YOU=$YOU" >> ~/.bashrc echo "G1PUB=$G1PUB" >> ~/.bashrc echo "IPFSNODEID=$IPFSNODEID" >> ~/.bashrc + source ~/.bashrc echo "UPDATE ~/.bashrc OK" tail -n 4 ~/.bashrc + exit 0