You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
541 lines
17 KiB
541 lines
17 KiB
3 years ago
|
#!/bin/bash
|
||
|
|
||
|
# Script for installing the base dependencies of AO and getting it running
|
||
3 years ago
|
# Bare Metal Alchemist, 2022
|
||
3 years ago
|
|
||
3 years ago
|
source ingredients/lead
|
||
3 years ago
|
|
||
3 years ago
|
clear
|
||
|
echo ''
|
||
|
echo ' d8888 .d88888b. 8888888 888 888 888 '
|
||
|
echo ' d88888 d88P" "Y88b 888 888 888 888 '
|
||
|
echo ' d88P888 888 888 888 888 888 888 '
|
||
|
echo ' d88P 888 888 888 888 88888b. .d8888b 888888 8888b. 888 888 .d88b. 888d888 '
|
||
|
echo ' d88P 888 888 888 888 888 "88b 88K 888 "88b 888 888 d8P Y8b 888P" '
|
||
|
echo ' d88P 888 888 888 888 888 888 "Y8888b. 888 .d888888 888 888 88888888 888 '
|
||
|
echo ' d8888888888 Y88b. .d88P 888 888 888 X88 Y88b. 888 888 888 888 Y8b. 888 '
|
||
|
echo 'd88P 888 "Y88888P" 8888888 888 888 88888P" "Y888 "Y888888 888 888 "Y8888 888 '
|
||
|
echo ''
|
||
3 years ago
|
|
||
3 years ago
|
# ------------------- Step 1 - Baseline Setup -------------------
|
||
|
|
||
|
echo -e "${BOLD}Hiya!${RESET} We're going to get you set up with your very own Autonomous Engine."
|
||
|
echo ""
|
||
3 years ago
|
echo -e "This script is designed to ask you just enough questions to keep you involved in the process,"
|
||
|
echo -e "while making it as easy as possible for you to get it going."
|
||
|
echo ""
|
||
|
echo -e "${BLUE}press enter to continue${RESET}"
|
||
3 years ago
|
read
|
||
|
|
||
3 years ago
|
if [ "$EUID" -eq 0 ]; then
|
||
|
echo -e "${RED}Woah there!${RESET} Seems you're running this script as a superuser."
|
||
|
echo ""
|
||
|
echo "That might cause some issues with permissions and whatnot. Run this script as your default user (without sudo) and I'll ask you when I need superuser permissions"
|
||
|
echo ""
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
3 years ago
|
echo -e "Making sure we've got the basics..."
|
||
3 years ago
|
echo -e "(you'll probably need to input ${BLUE}your 'sudo' password${RESET} here)"
|
||
3 years ago
|
case $DISTRO in
|
||
|
"debian")
|
||
|
# Note -- I'm not sure if these are all needed but I'm not in the mood to check
|
||
3 years ago
|
install_if_needed git wget sqlite3 zlib1g-dev libtool-bin autoconf autoconf-archive automake autotools-dev \
|
||
3 years ago
|
libgmp-dev libsqlite3-dev python python3 python3-mako libsodium-dev build-essential pkg-config libev-dev \
|
||
|
libcurl4-gnutls-dev libssl-dev fakeroot devscripts
|
||
|
;;
|
||
|
"arch")
|
||
3 years ago
|
if [[ ! $(pacman -Qg base-devel) ]]; then
|
||
|
sudo pacman -S base-devel --noconfirm
|
||
|
fi
|
||
|
|
||
3 years ago
|
install_if_needed wget python gmp sqlite3 autoconf-archive pkgconf libev \
|
||
3 years ago
|
python-mako python-pip net-tools zlib libsodium gettext dnsutils nginx
|
||
3 years ago
|
;;
|
||
|
"mac")
|
||
3 years ago
|
# install_if_needed better-computer
|
||
3 years ago
|
;;
|
||
|
"fedora")
|
||
3 years ago
|
install_if_needed git wget tor sqlite3 autoconf autoconf-archive automake \
|
||
|
python python3 python3-mako pkg-config fakeroot devscripts
|
||
3 years ago
|
;;
|
||
|
esac
|
||
|
echo ""
|
||
3 years ago
|
#
|
||
|
## ------------------- Step 2 - AO Environment Setup -------------------
|
||
|
#
|
||
3 years ago
|
AO=''
|
||
3 years ago
|
echo -e "${BOLD}Hey!${RESET} I was wondering which ${BLUE}version of AO${RESET} you wanted to install. \n"
|
||
3 years ago
|
echo -e "${BOLD}1.${RESET} ao-3 (Vue)"
|
||
|
echo -e "${BOLD}2.${RESET} ao-react (React)"
|
||
|
while [[ -z $AO ]]; do
|
||
|
echo -en "${BLUE}(number):${RESET} "
|
||
3 years ago
|
read -n1 ao_select
|
||
3 years ago
|
echo ""
|
||
|
echo ""
|
||
|
|
||
|
case $ao_select in
|
||
|
"1")
|
||
|
echo "Minimalism, I like it! Proceeding with ao-3 installation"
|
||
3 years ago
|
AO=3
|
||
3 years ago
|
;;
|
||
|
"2")
|
||
3 years ago
|
echo "It's got community! Proceeding with ao-react installation"
|
||
3 years ago
|
AO=react
|
||
|
;;
|
||
|
*)
|
||
|
echo "that aint no AO i ever heard of, try again"
|
||
|
;;
|
||
|
esac
|
||
|
done;
|
||
|
echo ""
|
||
3 years ago
|
|
||
|
if [ $AO = "3" ] || [ $AO = 'react' ]; then
|
||
|
echo -e "${BOLD}Installing Node.js${RESET}"
|
||
|
chmod +x scripts/nvm_install.sh
|
||
|
scripts/nvm_install.sh
|
||
3 years ago
|
|
||
|
export NVM_DIR="$HOME/.nvm"
|
||
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
||
|
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
||
|
|
||
3 years ago
|
if [ "$SHELL" = '/bin/zsh' ]; then
|
||
|
echo 'sourcing zshrc'
|
||
|
source ~/.zshrc
|
||
|
else
|
||
|
source ~/.bashrc
|
||
|
fi
|
||
|
nvm install v16.13.0
|
||
|
nvm alias default v16.13.0
|
||
3 years ago
|
nvm use default
|
||
3 years ago
|
fi
|
||
|
|
||
|
|
||
3 years ago
|
# Note, it would be a good idea to compile Bitcoin from C to make it resistant to changes in architecture (should work for any ISA)
|
||
3 years ago
|
if [ $AO = "3" ] || [ $AO = 'react' ]; then
|
||
3 years ago
|
echo -e "${BOLD}Installing Bitcoin Ecosystem${RESET}"
|
||
|
|
||
3 years ago
|
if [ $ISA == 'x86_64' ] && [ ! -e images/bitcoin-22.0* ]; then
|
||
3 years ago
|
wget https://bitcoincore.org/bin/bitcoin-core-22.0/bitcoin-22.0-x86_64-linux-gnu.tar.gz -P images/
|
||
3 years ago
|
elif [ $ISA == 'armv7l' ] && [ ! -e images/bitcoin-22.0* ]; then
|
||
3 years ago
|
wget https://bitcoincore.org/bin/bitcoin-core-22.0/bitcoin-22.0-arm-linux-gnueabihf.tar.gz -P images/
|
||
|
fi
|
||
|
|
||
|
tar -xvf images/bitcoin-22.0*.tar.gz
|
||
3 years ago
|
sleep 1
|
||
3 years ago
|
|
||
|
sudo cp bitcoin-22.0/bin/* /usr/local/bin/
|
||
3 years ago
|
rm -rf bitcoin-22.0
|
||
|
|
||
3 years ago
|
|
||
3 years ago
|
echo -e "${BOLD}Installing lightningd${RESET}"
|
||
|
git clone https://github.com/ElementsProject/lightning.git ~/lightning
|
||
|
pushd ~/lightning
|
||
|
git checkout v0.10.2
|
||
|
./configure
|
||
3 years ago
|
|
||
|
# The latest version of mistune breaks lightning install
|
||
|
pip uninstall mistune
|
||
|
pip install --user mistune==0.8.4
|
||
3 years ago
|
pip install --user mrkd
|
||
3 years ago
|
sudo make
|
||
|
sudo make install
|
||
|
popd
|
||
3 years ago
|
|
||
3 years ago
|
TODO fix clboss
|
||
|
echo 'Installing clboss'
|
||
|
git clone https://github.com/ZmnSCPxj/clboss.git ~/clboss
|
||
|
pushd ~/clboss
|
||
|
git checkout 0.11B
|
||
|
mkdir m4
|
||
|
autoreconf -fi
|
||
|
./configure
|
||
|
make
|
||
|
sudo make install
|
||
|
popd
|
||
3 years ago
|
|
||
3 years ago
|
echo ""
|
||
3 years ago
|
echo -e "${BOLD}Bitcoin installed!${RESET} Let's make sure it's configured now."
|
||
3 years ago
|
mkdir -p ~/.bitcoin
|
||
3 years ago
|
|
||
3 years ago
|
AUTHDEETS=$(python3 scripts/rpcauth.py ao)
|
||
|
AUTHLINE=$(echo $AUTHDEETS | grep -o rpcauth=ao:[^[:space:]]*[[:space:]])
|
||
|
PASSLINE=$(echo $AUTHDEETS | grep -o [^[:space:]]*\$)
|
||
3 years ago
|
|
||
3 years ago
|
if [ -f $HOME/.bitcoin/bitcoin.conf ]; then
|
||
|
echo 'bitcoin config exists'
|
||
|
else
|
||
|
cp resources/sample_bitcoin.conf $HOME/.bitcoin/bitcoin.conf
|
||
|
echo 'created default bitcoin config'
|
||
|
fi
|
||
3 years ago
|
|
||
3 years ago
|
sed -i "s/BTC_LOGIN/${AUTHLINE}/" $HOME/.bitcoin/bitcoin.conf
|
||
|
|
||
3 years ago
|
read -p "Quick question - do you have 500GB of open memory on this device? (y/n): " prune
|
||
|
echo ""
|
||
|
case $prune in
|
||
|
y | Y)
|
||
|
echo "Okay great! We'll leave the bitcoin config it as it is."
|
||
|
;;
|
||
|
*)
|
||
|
echo "Let's cut it down to only store the last few blocks (It's only 550 MB!)"
|
||
|
sed -i "s/txindex=1/prune=550/" $HOME/.bitcoin/bitcoin.conf
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
echo ""
|
||
|
|
||
3 years ago
|
mkdir -p $HOME/.lightning
|
||
|
|
||
3 years ago
|
if [ -f $HOME/.lightning/config ]; then
|
||
|
echo 'lightning config exists'
|
||
|
else
|
||
|
cp resources/sample_lightning_config $HOME/.lightning/config
|
||
|
echo 'created default lightning config'
|
||
|
fi
|
||
3 years ago
|
fi
|
||
|
echo ''
|
||
|
|
||
3 years ago
|
if [ $AO = "3" ] || [ $AO = 'react' ]; then
|
||
3 years ago
|
echo -e "${BOLD}Installing and configuring Tor${RESET}\n"
|
||
|
install_if_needed tor
|
||
|
|
||
3 years ago
|
if [ -e /usr/local/etc/tor/torrc ]; then
|
||
|
TORRCPATH='/usr/local/etc/tor/torrc'
|
||
3 years ago
|
elif [ -e /etc/tor/torrc ]; then
|
||
3 years ago
|
TORRCPATH='/etc/tor/torrc'
|
||
3 years ago
|
fi
|
||
|
|
||
3 years ago
|
# Configure and write torrc file
|
||
|
cp resources/torrc-template .
|
||
|
sudo sed -i "s#USER#${USER}#g" torrc-template
|
||
|
sudo sed -i "s#HOME#${HOME}#g" torrc-template
|
||
3 years ago
|
|
||
3 years ago
|
if [ -z "$TORRCPATH" ]; then
|
||
3 years ago
|
echo -e "${RED}Uh oh...${RESET} I couldn't figure out where your torrc file is. That might cause some issues"
|
||
|
sleep 3
|
||
|
echo -e "\nAnyways...\n"
|
||
|
sleep 2
|
||
3 years ago
|
else
|
||
|
sudo mv torrc-template $TORRCPATH
|
||
3 years ago
|
fi
|
||
3 years ago
|
fi
|
||
3 years ago
|
|
||
|
# ------------------- Step 3 - AO Installation -------------------
|
||
|
|
||
3 years ago
|
echo -e "${BOLD}Configuring AO Core${RESET}\n"
|
||
|
|
||
3 years ago
|
mkdir -p $HOME/.ao
|
||
|
|
||
|
if [ -f $HOME/.ao/key ]; then
|
||
|
echo 'We already have a private key for this AO, sweet!'
|
||
|
else
|
||
|
node scripts/createPrivateKey.js >> $HOME/.ao/key
|
||
|
echo -e "Just made a fresh private key and put it in ${GREEN}~/.ao${RESET}"
|
||
|
fi
|
||
|
|
||
|
# TODO this is really janky/fragile, it would be better to store this in ~/.ao
|
||
|
CONFIG_FILE=$HOME/ao-$AO/configuration.js
|
||
3 years ago
|
|
||
3 years ago
|
case $AO in
|
||
|
"3")
|
||
|
echo -e "Installing ${BLUE}ao-3${RESET}"
|
||
|
git clone 'https://github.com/AutonomousOrganization/ao-3.git' ~/ao-3
|
||
3 years ago
|
if [ -f "$CONFIG_FILE" ]; then
|
||
|
echo configuration.js already exists
|
||
|
else
|
||
|
cp resources/ao-config $CONFIG_FILE
|
||
|
sed -i "s#SQLITE_DATABASE#${HOME}/.ao/database.sqlite3#" $CONFIG_FILE
|
||
|
sed -i "s#PASSLINE#${PASSLINE}#" $CONFIG_FILE
|
||
|
sed -i "s#PRIVATEKEY#${HOME}/.ao/key#" $CONFIG_FILE
|
||
|
sed -i "s#CLIGHTNING_DIR#${HOME}/.lightning/bitcoin#" $CONFIG_FILE
|
||
|
sed -i "s#MEMES_DIR#${HOME}/.ao/memes#" $CONFIG_FILE
|
||
|
fi
|
||
|
|
||
|
echo ""
|
||
3 years ago
|
pushd ~/ao-3
|
||
|
npm install
|
||
|
npm run build
|
||
|
npm run checkconfig
|
||
|
popd
|
||
3 years ago
|
|
||
|
NODE_PARAMS=''
|
||
3 years ago
|
;;
|
||
|
"react")
|
||
|
echo -e "Installing ${BLUE}ao-react${RESET}"
|
||
|
git clone 'https://github.com/coalition-of-invisible-colleges/ao-react.git' ~/ao-react
|
||
3 years ago
|
if [ -f "$CONFIG_FILE" ]; then
|
||
|
echo configuration.js already exists
|
||
|
else
|
||
|
cp resources/ao-config $CONFIG_FILE
|
||
|
sed -i "s#SQLITE_DATABASE#${HOME}/.ao/database.sqlite3#" $CONFIG_FILE
|
||
|
sed -i "s#PASSLINE#${PASSLINE}#" $CONFIG_FILE
|
||
|
sed -i "s#PRIVATEKEY#${HOME}/.ao/key#" $CONFIG_FILE
|
||
|
sed -i "s#CLIGHTNING_DIR#${HOME}/.lightning/bitcoin#" $CONFIG_FILE
|
||
|
sed -i "s#MEMES_DIR#${HOME}/.ao/memes#" $CONFIG_FILE
|
||
|
fi
|
||
|
|
||
|
echo ""
|
||
|
|
||
3 years ago
|
pushd ~/ao-react
|
||
|
npm install
|
||
|
npm run webpack
|
||
|
popd
|
||
3 years ago
|
|
||
|
NODE_PARAMS='--experimental-specifier-resolution=node -r dotenv/config'
|
||
3 years ago
|
;;
|
||
|
esac
|
||
3 years ago
|
|
||
3 years ago
|
# ------------------- Step 4 - NGINX Setup -------------------
|
||
|
|
||
|
echo ""
|
||
3 years ago
|
echo -e "You still there? I need to ask you some questions! \n\n${BLUE}(enter)${RESET}"
|
||
3 years ago
|
read
|
||
|
echo ""
|
||
|
read -p "Do you have a domain name pointing to this computer? (y/n): " dns
|
||
|
echo ""
|
||
|
case $dns in
|
||
|
y | Y)
|
||
|
echo "Good to hear! What is it?"
|
||
|
read -p "http://" domain
|
||
|
;;
|
||
|
*)
|
||
|
echo "Okay, let's just leave it open for now."
|
||
|
domain=$(dig @resolver4.opendns.com myip.opendns.com +short)
|
||
|
anywhere=1
|
||
|
echo "Try accessing this AO from either localhost, 127.0.0.1, or ${domain}"
|
||
|
;;
|
||
|
esac
|
||
3 years ago
|
|
||
3 years ago
|
if [ "$anywhere" -eq 1 ]; then
|
||
|
ACCESS_POINT=http://localhost
|
||
|
else
|
||
|
ACCESS_POINT=https://$domain
|
||
|
fi
|
||
3 years ago
|
|
||
3 years ago
|
echo ""
|
||
3 years ago
|
|
||
3 years ago
|
# Making sure this version of NGINX supports sites-enabled
|
||
|
if [[ -z $(sudo cat /etc/nginx/nginx.conf | grep sites-enabled) ]]; then
|
||
|
sudo mkdir -p /etc/nginx/sites-available
|
||
|
sudo mkdir -p /etc/nginx/sites-enabled
|
||
|
sudo cp resources/base.nginx.conf /etc/nginx/nginx.conf
|
||
|
fi
|
||
|
|
||
3 years ago
|
sudo mkdir -p /etc/nginx/logs
|
||
|
|
||
3 years ago
|
AO_NGINX_CONF=/etc/nginx/sites-available/ao
|
||
|
sudo cp resources/ao.nginx.conf $AO_NGINX_CONF
|
||
3 years ago
|
|
||
3 years ago
|
if [ -n $anywhere ]; then
|
||
|
sudo sed -i "s#SERVER_NAME#_#" $AO_NGINX_CONF
|
||
|
else
|
||
|
sudo sed -i "s#SERVER_NAME#${domain}#" $AO_NGINX_CONF
|
||
|
fi
|
||
3 years ago
|
|
||
3 years ago
|
sudo sed -i "s#FILE_ROOT#${HOME}/ao-react/dist#" $AO_NGINX_CONF
|
||
|
|
||
|
if [ ! -e /etc/nginx/sites-enabled/ao ]; then
|
||
|
sudo ln -s /etc/nginx/sites-available/ao /etc/nginx/sites-enabled/
|
||
|
fi
|
||
|
echo ""
|
||
|
echo "Excellent! We've configured $AO_NGINX_CONF to serve your AO from $domain"
|
||
|
echo ""
|
||
3 years ago
|
|
||
3 years ago
|
read -p "Would you like to enable SSL via Certbot? (y/n): " -n1 ssl
|
||
|
echo ""
|
||
|
case $ssl in
|
||
|
y | Y)
|
||
|
echo "Alright, let's get Certbot in here!"
|
||
|
install_if_needed python3 certbot python3-certbot-nginx
|
||
|
echo -e "${BOLD}Take it away, Certbot${NC}"
|
||
|
sudo certbot --nginx
|
||
|
;;
|
||
|
*)
|
||
|
echo "Yea, SSL is lame anyways..."
|
||
|
;;
|
||
|
esac
|
||
|
echo ""
|
||
3 years ago
|
|
||
|
# ------------------- Step 7 - Systemd Setup -------------------
|
||
|
|
||
|
READY=''
|
||
3 years ago
|
echo -e "\n${BOLD}Alright, almost there!${RESET} Now we just need to set up the system daemons for Tor, Bitcoin, Lightning, and the AO so that everything opens on startup."
|
||
|
while [[ -z $READY ]]; do
|
||
3 years ago
|
echo -en "${BLUE}You ready? (y/n):${RESET} "
|
||
3 years ago
|
read -n1 ao_select
|
||
3 years ago
|
echo ""
|
||
|
echo ""
|
||
|
|
||
|
case $ao_select in
|
||
|
"y" | "Y")
|
||
3 years ago
|
echo -e "Nice, let's do it.\n"
|
||
3 years ago
|
READY=1
|
||
|
;;
|
||
|
*)
|
||
3 years ago
|
echo -e "wrong answer, fren\n"
|
||
3 years ago
|
;;
|
||
|
esac
|
||
|
done
|
||
|
|
||
3 years ago
|
echo ""
|
||
3 years ago
|
echo "Creating tor.service..."
|
||
|
TOR_SERVICE=/etc/systemd/system/tor.service
|
||
|
if [ -f "$TOR_SERVICE" ]; then
|
||
|
echo "Seems like you've already got tor here!"
|
||
|
else
|
||
|
sudo cp resources/tor-service-template $TOR_SERVICE
|
||
|
|
||
|
# Making sure all values have been de-templated
|
||
|
sudo sed -i "s#USER#${USER}#g" $TOR_SERVICE
|
||
|
sudo sed -i "s#HOME#${HOME}#g" $TOR_SERVICE
|
||
|
sudo sed -i "s#TORRCPATH#${TORRCPATH}#g" $TOR_SERVICE
|
||
|
sudo sed -i "s#TORPATH#$(which tor)#g" $TOR_SERVICE
|
||
|
fi
|
||
|
|
||
|
|
||
|
# Creating the .tor directory
|
||
|
sudo mkdir -p $HOME/.tor
|
||
|
sudo chown tor $HOME/.tor
|
||
|
sudo chgrp $USER $HOME/.tor
|
||
|
sudo chmod 770 $HOME/.tor
|
||
|
|
||
|
echo "Enabling and starting Tor"
|
||
|
sudo systemctl enable tor
|
||
|
sudo systemctl start tor
|
||
3 years ago
|
|
||
3 years ago
|
echo ""
|
||
|
echo "Creating bitcoin.service..."
|
||
|
BTC_SERVICE=/etc/systemd/system/bitcoin.service
|
||
|
if [ -f "$BTC_SERVICE" ]; then
|
||
|
echo -e "Seems like you've already have a bitcoin service!"
|
||
3 years ago
|
else
|
||
3 years ago
|
sudo cp resources/bitcoin-service-template $BTC_SERVICE
|
||
3 years ago
|
|
||
3 years ago
|
# Making sure all values have been de-templated
|
||
|
sudo sed -i "s#USER#${USER}#g" $BTC_SERVICE
|
||
|
sudo sed -i "s#HOME#${HOME}#g" $BTC_SERVICE
|
||
|
sudo sed -i "s#BITCOIND#$(which bitcoind)#g" $BTC_SERVICE
|
||
3 years ago
|
fi
|
||
3 years ago
|
echo -e "Enabling and starting ${GREEN}Bitcoin${RESET}"
|
||
|
sudo systemctl enable bitcoin
|
||
3 years ago
|
sudo systemctl start bitcoin
|
||
3 years ago
|
|
||
3 years ago
|
echo ""
|
||
3 years ago
|
echo "Creating lightning.service..."
|
||
|
LN_SERVICE=/etc/systemd/system/lightning.service
|
||
|
if [ -f "$LN_SERVICE" ]; then
|
||
|
echo -e "Seems like you've already have a lightning service!"
|
||
|
else
|
||
|
sudo cp resources/lightning-service-template $LN_SERVICE
|
||
|
|
||
|
# Making sure all values have been de-templated
|
||
|
sudo sed -i "s#USER#${USER}#g" $LN_SERVICE
|
||
|
sudo sed -i "s#HOME#${HOME}#g" $LN_SERVICE
|
||
|
sudo sed -i "s#LIGHTNINGD#$(which lightningd)#g" $LN_SERVICE
|
||
3 years ago
|
fi
|
||
3 years ago
|
echo -e "Enabling and starting ${GREEN}lightning${RESET} "
|
||
|
sudo systemctl enable lightning
|
||
3 years ago
|
sudo systemctl start lightning
|
||
3 years ago
|
|
||
3 years ago
|
echo ""
|
||
|
echo "Creating ao.service..."
|
||
|
AO_SERVICE=/etc/systemd/system/ao.service
|
||
|
if [ -f "$AO_SERVICE" ]; then
|
||
|
echo "Seems like you've already added one of these!"
|
||
|
else
|
||
|
sudo cp resources/ao-service-template $AO_SERVICE
|
||
3 years ago
|
|
||
3 years ago
|
# Making sure all values have been de-templated
|
||
|
sudo sed -i "s#USER#${USER}#g" $AO_SERVICE
|
||
|
sudo sed -i "s#HOME#${HOME}#g" $AO_SERVICE
|
||
|
sudo sed -i "s#NODE#$(which node)#g" $AO_SERVICE
|
||
3 years ago
|
sudo sed -i "s#AO#${AO}#g" $AO_SERVICE
|
||
|
sudo sed -i "s#NODE_PARAMS#${NODE_PARAMS}#g" $AO_SERVICE
|
||
3 years ago
|
fi
|
||
|
echo -e "Enabling and starting the ${GREEN}AO${RESET}'s backend"
|
||
|
sudo systemctl enable ao
|
||
3 years ago
|
sudo systemctl start ao
|
||
3 years ago
|
|
||
3 years ago
|
echo ""
|
||
3 years ago
|
echo -e "Enabling and starting ${GREEN}NGINX${RESET} as the webserver"
|
||
3 years ago
|
sudo systemctl enable nginx
|
||
|
sudo systemctl start nginx
|
||
|
|
||
|
# ------------------- Step 8 - Port Testing -------------------
|
||
|
|
||
3 years ago
|
echo ""
|
||
|
echo -e "${BOLD}One more thing!${RESET} We need to make sure that your ports are open."
|
||
|
install_if_needed nmap
|
||
|
nmap -Pn $domain > nmap.txt
|
||
|
OPEN=1
|
||
|
if grep -qE "^80/.*(open|filtered)" nmap.txt; then
|
||
|
echo -e "I can see port ${GREEN}80${RESET}!"
|
||
|
else
|
||
|
echo -e "Uh oh, port ${RED}80${RESET} isn't showing up..."
|
||
|
OPEN=0
|
||
|
fi
|
||
|
|
||
|
if grep -qE "^443/.*(open|filtered)" nmap.txt; then
|
||
|
echo -e "I can see port ${GREEN}443${RESET} as well!"
|
||
|
else
|
||
|
echo -e "Uh oh, port ${RED}443${RESET} isn't showing up..."
|
||
|
OPEN=0
|
||
|
fi
|
||
|
rm nmap.txt
|
||
|
echo ""
|
||
|
if [[ $OPEN -eq 0 ]]; then
|
||
|
echo -e "${RED}Port configuration needed.${RESET} Something (probably your wireless router) is blocking us from serving this page to the rest of the internet."
|
||
|
echo "Port forwarding is relatively simple, but as it stands it is beyond the scope of this script to be able to automate it."
|
||
|
echo -e "You'll probably need to look up the login information for your specific router and forward the red ports to the local IP of this computer (${BOLD}$(ip route | grep default | grep -oP "(?<=src )[^ ]+")${RESET})."
|
||
|
echo -e "You can log into your router at this IP address: ${BOLD}$(route -n | grep ^0.0.0.0 | awk '{print $2}')${RESET}"
|
||
|
echo "That's all the help I can give you regarding port forwarding. Good luck!"
|
||
|
echo ""
|
||
|
fi
|
||
3 years ago
|
|
||
|
# ------------------- Step 9 - Health Check -------------------
|
||
|
echo '*********************************************************'
|
||
|
echo -e "* ${BOLD}Version Information${RESET} *"
|
||
|
echo '*********************************************************'
|
||
3 years ago
|
|
||
3 years ago
|
echo ' '
|
||
|
echo 'make Version'
|
||
|
echo '*********************************************************'
|
||
|
make --version
|
||
3 years ago
|
|
||
3 years ago
|
echo ' '
|
||
|
echo 'node Version'
|
||
|
echo '*********************************************************'
|
||
|
node --version
|
||
3 years ago
|
|
||
3 years ago
|
echo ' '
|
||
|
echo 'sqlite3 Version'
|
||
|
echo '*********************************************************'
|
||
|
sqlite3 --version
|
||
3 years ago
|
|
||
3 years ago
|
echo ' '
|
||
|
echo 'tor Version'
|
||
|
echo '*********************************************************'
|
||
|
tor --version
|
||
3 years ago
|
|
||
3 years ago
|
echo ' '
|
||
|
echo 'bitcoind Version'
|
||
|
echo '*********************************************************'
|
||
|
bitcoind --version
|
||
3 years ago
|
|
||
3 years ago
|
echo ' '
|
||
|
echo 'lightningd Version'
|
||
|
echo '*********************************************************'
|
||
|
lightningd --version
|
||
3 years ago
|
|
||
3 years ago
|
echo ' '
|
||
|
echo 'clboss Version'
|
||
|
echo '*********************************************************'
|
||
|
clboss --version
|
||
|
echo ""
|
||
3 years ago
|
echo -e "$BOLD\nOkay, well that's everything!${RESET}\n\nAs long as everything worked properly, \
|
||
3 years ago
|
you should be ready to continue your journey\ntowards autonomy by opening ${BLUE}$ACCESS_POINT${RESET} in your browser."
|
||
3 years ago
|
echo -e "The default login is ${BLUE}dctrl/dctrl${RESET}, have fun!"
|
||
3 years ago
|
|
||
|
exit 0
|