forked from axiom-team/astrXbian
38 lines
1.5 KiB
Bash
38 lines
1.5 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
astroVars="OS ARM YOU ipfsnodeid ASTROZEN ASTRONODE myProfile"
|
||
|
|
||
|
export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1)
|
||
|
export ipfsnodeid=$(ipfs id -f='<id>\n')
|
||
|
export ASTROZEN="/home/$YOU/.zen"
|
||
|
export ASTRONODE="$ASTROZEN/ipfs/.$ipfsnodeid"
|
||
|
export myProfile="$ASTRONODE/profile"
|
||
|
|
||
|
[[ ! -d $ASTRONODE ]] && mkdir -p $ASTRONODE
|
||
|
|
||
|
## Check system kind
|
||
|
[[ $(uname -a | grep arm) ]] && export ARM=yes || unset ARM
|
||
|
if [[ $(grep -E '19.3|19.4' /etc/os-release) ]]; then export OS=buster;
|
||
|
elif [[ $(grep -E 'stretch|18.|19.' /etc/os-release) ]]; then export OS=stretch;
|
||
|
else export OS=buster;
|
||
|
fi
|
||
|
|
||
|
[[ -e $myProfile ]] && rm $myProfile
|
||
|
touch $myProfile
|
||
|
|
||
|
for i in $astroVars; do
|
||
|
[[ ! $(grep "$i=" $myProfile) && -n ${!i} ]] && echo "export $i=${!i}" >> $myProfile
|
||
|
done
|
||
|
|
||
|
# Export for user
|
||
|
[[ -n $(grep "/.zen/ipfs/" ~/.bashrc) ]] && sed -i -n '/\/.zen\/ipfs/!p' ~/.bashrc
|
||
|
[[ -n $(grep "# ASTROPORT " ~/.bashrc) ]] && sed -i -n '/# ASTROPORT /!p' ~/.bashrc
|
||
|
echo -e "# ASTROPORT ENVIRONMENT VARIABLE\n. /home/$YOU/.zen/ipfs/.$ipfsnodeid/profile" >> ~/.bashrc
|
||
|
|
||
|
# Export for root (obsolete)
|
||
|
#[[ -n $(sudo grep "/.zen/ipfs/" /root/.bashrc) ]] && sudo sed -i -n '/\/.zen\/ipfs/!p' /root/.bashrc
|
||
|
#[[ -n $(sudo grep "# ASTROPORT " /root/.bashrc) ]] && sudo sed -i -n '/# ASTROPORT /!p' /root/.bashrc
|
||
|
#echo -e "# ASTROPORT ENVIRONMENT VARIABLE\n. /home/$YOU/.zen/ipfs/.$ipfsnodeid/profile" | sudo tee -a /root/.bashrc
|
||
|
|
||
|
[[ $1 != "noexec" ]] && exec bash
|