2020-03-18 05:06:01 +01:00
|
|
|
#!/bin/bash
|
2020-03-18 15:49:46 +01:00
|
|
|
################################################################################
|
|
|
|
# Author: Poka (poka@p2p.legal)
|
|
|
|
# Author: Fred (support@qo-op.com)
|
|
|
|
# Version: 0.1
|
|
|
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
|
|
# Git: https://git.p2p.legal/axiom-team/astroport
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
## Check if root user
|
|
|
|
if [ "$EUID" -eq 0 ]
|
|
|
|
then echo -e "${c_red}Please do not execute this script in root user.$c_"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-03-18 05:06:01 +01:00
|
|
|
|
|
|
|
echo -e "Installing Astroport"
|
|
|
|
|
2020-03-18 15:49:46 +01:00
|
|
|
MY_PATH="`dirname \"$0\"`"
|
|
|
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`"
|
|
|
|
now=$(date +%Y-%m-%d)
|
|
|
|
|
|
|
|
## Get profile
|
|
|
|
[[ -f $MY_PATH/.profile ]] && source $MY_PATH/.profile || touch $MY_PATH/.profile
|
|
|
|
|
|
|
|
help() {
|
|
|
|
clear
|
|
|
|
echo -e "${c_light}Welcome onboard !$c_
|
|
|
|
- No arguments yet
|
|
|
|
"
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
## Get arguments
|
|
|
|
args="$@"
|
|
|
|
[[ $args =~ all ]] && all=true
|
|
|
|
|
|
|
|
## Vérifie le type de système
|
|
|
|
[[ $(uname -a | grep arm) ]] && ARM=yes || unset isARM
|
|
|
|
if [[ $(grep -E 'stretch|18.|19.' /etc/os-release) ]]; then OS=stretch;
|
|
|
|
elif [[ $(grep buster /etc/os-release) ]]; then OS=buster;
|
|
|
|
else echo "${c_red}Votre OS n'est pas supporté$c_"; exit 1; fi
|
|
|
|
sed -i 's/_OS/$OS/g' $MY_PATH/.profile
|
|
|
|
sed -i 's/_ARM/$ARM/g' $MY_PATH/.profile
|
|
|
|
sed -i 's/_GPATH/$MY_PATH/g' $MY_PATH/.profile
|
|
|
|
|
|
|
|
chmod u+x $MY_PATH/.install/*.sh
|
|
|
|
$MY_PATH/.install/export_colors.sh
|
|
|
|
[[ -f ~/.bash_aliases ]] && source ~/.bash_aliases
|
|
|
|
|
|
|
|
|
|
|
|
# --------------------------------------------
|
|
|
|
|
2020-03-18 05:06:01 +01:00
|
|
|
# Install IPFS
|
|
|
|
ipfs() {
|
|
|
|
echo -e "${c_yellow}Onboarding IPFS...$c_"
|
|
|
|
[[ -f /usr/local/bin/ipfs ]] && sudo service ipfs stop
|
|
|
|
if [[ $ARM == "yes" ]]; then
|
|
|
|
wget https://dist.ipfs.io/ipfs-update/v1.5.2/ipfs-update_v1.5.2_linux-arm.tar.gz -O $MY_PATH/ipfs-update.tar.gz || err+="Download ipfs-update"
|
|
|
|
else
|
|
|
|
wget https://dist.ipfs.io/ipfs-update/v1.5.2/ipfs-update_v1.5.2_linux-amd64.tar.gz -O $MY_PATH/ipfs-update.tar.gz || err+="Download ipfs-update"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "INSTALL ipfs-update"
|
|
|
|
sudo tar -xvzf $MY_PATH/ipfs-update.tar.gz -C /usr/src/ || err+="Untar ipfs-update"
|
|
|
|
rm $MY_PATH/ipfs-update.tar.gz
|
|
|
|
cd /usr/src/ipfs-update/
|
|
|
|
sudo ./install.sh || err+="Install ipfs-update"
|
|
|
|
cd $MY_PATH
|
|
|
|
|
|
|
|
echo "INSTALL latest ipfs"
|
|
|
|
sudo ipfs-update install latest || err+="Install IPFS"
|
|
|
|
|
|
|
|
echo "CREATE SYSTEMD ipfs SERVICE"
|
|
|
|
[[ -f /etc/systemd/system/ipfs.service ]] && sudo rm /etc/systemd/system/ipfs.service
|
|
|
|
sudo cp -f $MY_PATH/templates/1/ipfs.service /etc/systemd/system/
|
|
|
|
sudo sed -i "s/_USER/$USER/g" /etc/systemd/system/ipfs.service
|
|
|
|
|
|
|
|
sudo systemctl daemon-reload || err+="Restart IPFS"
|
|
|
|
sudo systemctl enable ipfs || err+="Enable IPFS daemon"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Install ScuttleButt
|
|
|
|
scuttlebutt() {
|
2020-03-18 15:49:46 +01:00
|
|
|
echo "TODO"
|
2020-03-18 05:06:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Install IPTubes
|
|
|
|
iptubes() {
|
2020-03-18 15:49:46 +01:00
|
|
|
cd $MY_PATH/iptubes
|
2020-03-18 05:06:01 +01:00
|
|
|
## Install GO
|
2020-03-18 15:49:46 +01:00
|
|
|
wget https://dl.google.com/go/go1.13.4.linux-amd64.tar.gz -P /tmp/
|
|
|
|
sudo tar -C /usr/local -xzf /tmp/go1.13.4.linux-amd64.tar.gz
|
2020-03-18 05:06:01 +01:00
|
|
|
export PATH=$PATH:/usr/local/go/bin
|
|
|
|
source ~/.profile
|
|
|
|
|
|
|
|
## Install torrengo
|
|
|
|
go get github.com/juliensalinas/torrengo
|
|
|
|
go build github.com/juliensalinas/torrengo
|
|
|
|
go get github.com/juliensalinas/torrengo/ygg
|
|
|
|
|
|
|
|
sudo chmod ug+x torrengo
|
2020-03-18 15:49:46 +01:00
|
|
|
pathTorrengo=$(realpath torrengo)
|
|
|
|
cd /usr/bin
|
|
|
|
sudo ln -sf $pathTorrengo .
|
|
|
|
|
|
|
|
|
|
|
|
cd $MY_PATH
|
|
|
|
rm /tmp/go1.13.4.linux-amd64.tar.gz
|
2020-03-18 05:06:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Check installs
|
|
|
|
## Check IPFS install
|
2020-03-18 15:49:46 +01:00
|
|
|
[[ -z $(which ipfs) ]] && ipfs
|
|
|
|
|
2020-03-18 05:06:01 +01:00
|
|
|
|
2020-03-18 15:49:46 +01:00
|
|
|
echo -e "${c_green}Astroport UP$c_"
|
|
|
|
echo -e "Select a gate to install:"
|
|
|
|
#read gate
|
|
|
|
gate="iptubes"
|
|
|
|
case $gate in
|
|
|
|
iptubes) iptubes;;
|
|
|
|
# flattg) flattg;;
|
|
|
|
*) echo -e "${c_yellow}Bye !$c_";;
|
|
|
|
esac
|
2020-03-18 05:06:01 +01:00
|
|
|
|
2020-03-18 15:49:46 +01:00
|
|
|
echo -e "${c_green}Good trip !$c_"
|
2020-03-18 05:06:01 +01:00
|
|
|
|
|
|
|
exit 0
|