diff --git a/.install/update_bashrc.sh b/.install/update_bashrc.sh index ca322b20e..6d4744bfb 100755 --- a/.install/update_bashrc.sh +++ b/.install/update_bashrc.sh @@ -8,24 +8,26 @@ # Add $YOU $IPFSNODEID $G1PUB to ~/.bashrc source ~/.bashrc + -[[ $YOU != "" && $IPFSNODEID != "" && $G1PUB != "" ]] && er+="bashrc already updated" - -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" +newYOU=$(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" +newIPFSNODEID=$(ipfs id -f='\n') || er+=" ipfs id problem" +[[ -f ~/.zen/secret.dunikey ]] && newG1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) || er+=" ~/.zen/secret.dunikey missing cannot find G1PUB" [[ $er != "" ]] && echo "$er" && exit 1 -echo "### ASTROPORT IDENTITY ###" >> ~/.bashrc -echo "YOU=$YOU" >> ~/.bashrc -echo "G1PUB=$G1PUB" >> ~/.bashrc -echo "IPFSNODEID=$IPFSNODEID" >> ~/.bashrc -## Add jaklis/.env ? -# cat ~/.zen/astrXbian/zen/jaklis/.env >> ~/.bashrc - +if [[ $YOU != "" && $IPFSNODEID != "" && $G1PUB != "" ]]; then +# UPDATE + sed -i "s/YOU=$YOU/YOU=$newYOU/g" ~/.bashrc + sed -i "s/$G1PUB/$newG1PUB/g" ~/.bashrc + sed -i "s/$IPFSNODEID/$newIPFSNODEID/g" ~/.bashrc +else +# CREATE + echo "### ASTROPORT IDENTITY ###" >> ~/.bashrc + echo "YOU=$newYOU" >> ~/.bashrc + echo "G1PUB=$newG1PUB" >> ~/.bashrc + echo "IPFSNODEID=$newIPFSNODEID" >> ~/.bashrc +fi source ~/.bashrc echo "UPDATE ~/.bashrc OK"