Browse Source

updating autonomy for posix compatibility

main
Zen 3 years ago
parent
commit
cac43a9ef2
  1. 2
      ingredients/copper
  2. 214
      recipes/ao.sh

2
ingredients/copper

@ -78,7 +78,7 @@ initialize_nginx() {
install_if_needed nginx install_if_needed nginx
# Making sure this version of NGINX supports sites-enabled # Making sure this version of NGINX supports sites-enabled
if [ -z $(sudo cat /etc/nginx/nginx.conf | grep sites-enabled) ]; then 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-available
sudo mkdir -p /etc/nginx/sites-enabled sudo mkdir -p /etc/nginx/sites-enabled
sudo cp resources/nginx/base.nginx.conf /etc/nginx/nginx.conf sudo cp resources/nginx/base.nginx.conf /etc/nginx/nginx.conf

214
recipes/ao.sh

@ -9,39 +9,39 @@ source ingredients/iron
source ingredients/gold source ingredients/gold
clear clear
echo '' say ''
echo ' d8888 .d88888b. 8888888 888 888 888 ' say ' d8888 .d88888b. 8888888 888 888 888 '
echo ' d88888 d88P" "Y88b 888 888 888 888 ' say ' d88888 d88P" "Y88b 888 888 888 888 '
echo ' d88P888 888 888 888 888 888 888 ' say ' d88P888 888 888 888 888 888 888 '
echo ' d88P 888 888 888 888 88888b. .d8888b 888888 8888b. 888 888 .d88b. 888d888 ' say ' 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" ' say ' 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 ' say ' 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 ' say ' 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 ' say 'd88P 888 "Y88888P" 8888888 888 888 88888P" "Y888 "Y888888 888 888 "Y8888 888 '
echo '' say ''
# ------------------- Step 1 - Baseline Setup ------------------- # ------------------- Step 1 - Baseline Setup -------------------
echo -e "${BOLD}Hiya!${RESET} We're going to get you set up with your very own Autonomous Engine." say "${BOLD}Hiya!${RESET} We're going to get you set up with your very own Autonomous Engine."
echo "" say ""
echo -e "This script is designed to ask you just enough questions to keep you involved in the process," say "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." say "while making it as easy as possible for you to get it going."
echo "" say ""
echo -e "${BLUE}press enter to continue${RESET}" say "${BLUE}press enter to continue${RESET}"
read read
if [ "$EUID" -eq 0 ]; then if [ "$EUID" -eq 0 ]; then
echo -e "${RED}Woah there!${RESET} Seems you're running this script as a superuser." say "${RED}Woah there!${RESET} Seems you're running this script as a superuser."
echo "" say ""
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" say "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 "" say ""
exit 1 exit 1
fi fi
# TODO: dependencies should not be frontloaded, they should be installed as needed # TODO: dependencies should not be frontloaded, they should be installed as needed
echo -e "Making sure we've got the basics..." say "Making sure we've got the basics..."
echo -e "(you'll probably need to input ${BLUE}your 'sudo' password${RESET} here)" say "(you'll probably need to input ${BLUE}your 'sudo' password${RESET} here)"
case $DISTRO in case $DISTRO in
"debian") "debian")
# Note -- I'm not sure if these are all needed but I'm not in the mood to check # Note -- I'm not sure if these are all needed but I'm not in the mood to check
@ -65,109 +65,107 @@ case $DISTRO in
python python3 python3-mako pkg-config fakeroot devscripts python python3 python3-mako pkg-config fakeroot devscripts
;; ;;
esac esac
echo "" say ""
# ------------------- Step 2 - AO Environment Setup ------------------- # ------------------- Step 2 - AO Environment Setup -------------------
if [ ! -z $AO ]; then if [ ! -z $AO ]; then
echo "You're currently using ao-$AO" say "You're currently using ao-$AO"
echo -en "Would you like to re-install? ${BLUE}(y/n): ${RESET}" ask_for reinstall_ao "Would you like to re-install? ${BLUE}(y/n): ${RESET}"
read reinstall_ao say ""
echo ""
case $reinstall_ao in case $reinstall_ao in
"Y" | "y") "Y" | "y")
forget AO forget AO
;; ;;
*) *)
echo "Okay, we'll keep using this version of AO" say "Okay, we'll keep using this version of AO"
;; ;;
esac esac
fi fi
if [ -z $AO ]; then if [ -z $AO ]; then
AO='' AO=''
echo -e "${BOLD}Hey!${RESET} I was wondering which ${BLUE}version of AO${RESET} you wanted to install. \n" say "${BOLD}Hey!${RESET} I was wondering which ${BLUE}version of AO${RESET} you wanted to install. \n"
echo -e "${BOLD}1.${RESET} ao-3 (Vue)" say "${BOLD}1.${RESET} ao-3 (Vue)"
echo -e "${BOLD}2.${RESET} ao-react (React)" say "${BOLD}2.${RESET} ao-react (React)"
fi fi
while [[ -z $AO ]]; do while [[ -z $AO ]]; do
echo -en "${BLUE}(number):${RESET} " ask_for ao-select "${BLUE}(number):${RESET} "
read -n1 ao_select say ""
echo "" say ""
echo ""
case $ao_select in case $ao_select in
"1") "1")
echo -e "Minimalism, I like it! Proceeding with ${BLUE}ao-3${RESET} installation" say "Minimalism, I like it! Proceeding with ${BLUE}ao-3${RESET} installation"
AO='3' AO='3'
;; ;;
"2") "2")
echo -e "It's got community! Proceeding with ${BLUE}ao-react${RESET} installation" say "It's got community! Proceeding with ${BLUE}ao-react${RESET} installation"
AO='react' AO='react'
;; ;;
*) *)
echo "that aint no AO i ever heard of, try again" say "that aint no AO i ever heard of, try again"
;; ;;
esac esac
done; done;
remember "AO=${AO}" remember "AO=${AO}"
echo "" say ""
if [ $AO = "3" ] || [ $AO = 'react' ]; then if [ $AO = "3" ] || [ $AO = 'react' ]; then
if [ -z $NVM_DIR ]; then if [ -z $NVM_DIR ]; then
install_nvm install_nvm
source ingredients/iron source ingredients/iron
else else
echo -e "${BLUE}Node${RESET} already installed!" say "${BLUE}Node${RESET} already installed!"
fi fi
echo -e "Setting Node to ${BLUE}v16.13.0${RESET} for compatibility" say "Setting Node to ${BLUE}v16.13.0${RESET} for compatibility"
set_node_to v16.13.0 set_node_to v16.13.0
echo "" say ""
echo -e "${GREEN}Done!${RESET}" say "${GREEN}Done!${RESET}"
echo "" say ""
fi fi
if [ $AO = "3" ] || [ $AO = 'react' ]; then if [ $AO = "3" ] || [ $AO = 'react' ]; then
echo -e "${BOLD}Installing Bitcoin Ecosystem${RESET}" say "${BOLD}Installing Bitcoin Ecosystem${RESET}"
echo "" say ""
if ! check_for bitcoind; then if ! check_for bitcoind; then
echo -e "Building bitcoind from source... might take a while!" say "Building bitcoind from source... might take a while!"
install_bitcoin install_bitcoin
fi fi
if ! check_for lightningd; then if ! check_for lightningd; then
echo -e "Building lightningd from source... here we go again" say "Building lightningd from source... here we go again"
install_lightning install_lightning
fi fi
configure_bitcoin configure_bitcoin
configure_lightning configure_lightning
fi fi
echo '' say ''
if [ $AO = "3" ] || [ $AO = 'react' ]; then if [ $AO = "3" ] || [ $AO = 'react' ]; then
echo -e "${BOLD}Installing and configuring Tor${RESET}\n" say "${BOLD}Installing and configuring Tor${RESET}\n"
install_if_needed tor install_if_needed tor
configure_tor configure_tor
echo "" say ""
fi fi
# ------------------- Step 3 - AO Installation ------------------- # ------------------- Step 3 - AO Installation -------------------
echo -e "${BOLD}Configuring AO Core${RESET}\n" say "${BOLD}Configuring AO Core${RESET}\n"
mkdir -p $HOME/.ao mkdir -p $HOME/.ao
if [ -f $HOME/.ao/key ]; then if [ -f $HOME/.ao/key ]; then
echo 'We already have a private key for this AO, sweet!' say 'We already have a private key for this AO, sweet!'
else else
node scripts/createPrivateKey.js >> $HOME/.ao/key node scripts/createPrivateKey.js >> $HOME/.ao/key
echo -e "Just made a fresh private key and put it in ${GREEN}~/.ao${RESET}" say "Just made a fresh private key and put it in ${GREEN}~/.ao${RESET}"
fi fi
echo "" say ""
# TODO this is really janky/fragile, it would be better to store this in ~/.ao # TODO this is really janky/fragile, it would be better to store this in ~/.ao
CONFIG_FILE=$HOME/ao-$AO/configuration.js CONFIG_FILE=$HOME/ao-$AO/configuration.js
@ -190,11 +188,11 @@ read
case $AO in case $AO in
"3") "3")
if [ ! -d ~/ao-3 ]; then if [ ! -d ~/ao-3 ]; then
echo -e "Installing ${BLUE}ao-3${RESET}" say "Installing ${BLUE}ao-3${RESET}"
git clone 'https://github.com/AutonomousOrganization/ao-3.git' ~/ao-3 git clone 'https://github.com/AutonomousOrganization/ao-3.git' ~/ao-3
fi fi
if [ -f "$CONFIG_FILE" ]; then if [ -f "$CONFIG_FILE" ]; then
echo configuration.js already exists say configuration.js already exists
else else
cp resources/ao-config $CONFIG_FILE cp resources/ao-config $CONFIG_FILE
sed -i "s#SQLITE_DATABASE#${HOME}/.ao/database.sqlite3#" $CONFIG_FILE sed -i "s#SQLITE_DATABASE#${HOME}/.ao/database.sqlite3#" $CONFIG_FILE
@ -204,7 +202,7 @@ case $AO in
sed -i "s#MEMES_DIR#${HOME}/.ao/memes#" $CONFIG_FILE sed -i "s#MEMES_DIR#${HOME}/.ao/memes#" $CONFIG_FILE
fi fi
echo "" say ""
pushd ~/ao-3 pushd ~/ao-3
npm install npm install
npm run build npm run build
@ -214,12 +212,12 @@ case $AO in
NODE_PARAMS='' NODE_PARAMS=''
;; ;;
"react") "react")
echo -e "Installing ${BLUE}ao-react${RESET}" say "Installing ${BLUE}ao-react${RESET}"
if [ ! -d ~/ao-react ]; then if [ ! -d ~/ao-react ]; then
git clone 'https://github.com/coalition-of-invisible-colleges/ao-react.git' ~/ao-react git clone 'https://github.com/coalition-of-invisible-colleges/ao-react.git' ~/ao-react
fi fi
if [ -f "$CONFIG_FILE" ]; then if [ -f "$CONFIG_FILE" ]; then
echo configuration.js already exists say configuration.js already exists
else else
cp resources/ao-config $CONFIG_FILE cp resources/ao-config $CONFIG_FILE
sed -i "s#SQLITE_DATABASE#${HOME}/.ao/database.sqlite3#" $CONFIG_FILE sed -i "s#SQLITE_DATABASE#${HOME}/.ao/database.sqlite3#" $CONFIG_FILE
@ -229,7 +227,7 @@ case $AO in
sed -i "s#MEMES_DIR#${HOME}/.ao/memes#" $CONFIG_FILE sed -i "s#MEMES_DIR#${HOME}/.ao/memes#" $CONFIG_FILE
fi fi
echo "" say ""
pushd ~/ao-react pushd ~/ao-react
npm install npm install
@ -242,35 +240,33 @@ esac
# ------------------- Step 4 - NGINX Setup ------------------- # ------------------- Step 4 - NGINX Setup -------------------
echo "" say ""
echo -en "You still there? I might need your input here! \n\n${BLUE}(enter)${RESET}" ask_for nothing "You still there? I might need your input here! \n\n${BLUE}(enter)${RESET}"
read
initialize_nginx initialize_nginx
make_site ao "FILE_ROOT=${HOME}/ao-${AO}/dist" make_site ao "FILE_ROOT=${HOME}/ao-${AO}/dist"
echo "" say ""
configure_domain_for_site ao configure_domain_for_site ao
enable_ssl enable_ssl
echo -e "Excellent! We've configured this computer to serve your AO from ${BLUE}${ACCESS_POINT}${RESET}" say "Excellent! We've configured this computer to serve your AO from ${BLUE}${ACCESS_POINT}${RESET}"
# ------------------- Step 7 - Systemd Setup ------------------- # ------------------- Step 7 - Systemd Setup -------------------
READY='' READY=''
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." say "\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 while [[ -z "$READY" ]]; do
echo -en "${BLUE}You ready? (y/n):${RESET} " ask_for ready "${BLUE}You ready? (y/n):${RESET} "
read -n1 ao_select say ""
echo "" say ""
echo ""
case $ao_select in case $ready in
"y" | "Y") "y" | "Y")
echo -e "Nice, let's do it.\n" say "Nice, let's do it.\n"
READY=1 READY=1
;; ;;
*) *)
echo -e "wrong answer, fren\n" say "wrong answer, fren\n"
;; ;;
esac esac
done done
@ -285,71 +281,71 @@ sudo chmod 770 $HOME/.tor
activate_service tor activate_service tor
echo "" say ""
build_service_from_template bitcoin "BITCOIND=`which bitcoind`" build_service_from_template bitcoin "BITCOIND=`which bitcoind`"
activate_service bitcoin activate_service bitcoin
echo "" say ""
build_service_from_template lightning "LIGHTNINGD=`which lightningd`" build_service_from_template lightning "LIGHTNINGD=`which lightningd`"
activate_service lightning activate_service lightning
echo "" say ""
build_service_from_template ao "NODE=`which node`" "AO=$AO" "NODE_PARAMS=$NODE_PARAMS" build_service_from_template ao "NODE=`which node`" "AO=$AO" "NODE_PARAMS=$NODE_PARAMS"
activate_service ao activate_service ao
echo "this should be nginx" say "this should be nginx"
activate_service nginx activate_service nginx
# ------------------- Step 8 - Port Testing ------------------- # ------------------- Step 8 - Port Testing -------------------
echo "" say ""
echo -e "${BOLD}One more thing!${RESET} We need to make sure that your ports are open." say "${BOLD}One more thing!${RESET} We need to make sure that your ports are open."
echo "" say ""
check_ports check_ports
# ------------------- Step 9 - Health Check ------------------- # ------------------- Step 9 - Health Check -------------------
echo '*********************************************************' say '*********************************************************'
echo -e "* ${BOLD}Version Information${RESET} *" say "* ${BOLD}Version Information${RESET} *"
echo '*********************************************************' say '*********************************************************'
echo ' ' say ' '
echo 'make Version' say 'make Version'
echo '*********************************************************' say '*********************************************************'
make --version make --version
echo ' ' say ' '
echo 'node Version' say 'node Version'
echo '*********************************************************' say '*********************************************************'
node --version node --version
echo ' ' say ' '
echo 'sqlite3 Version' say 'sqlite3 Version'
echo '*********************************************************' say '*********************************************************'
sqlite3 --version sqlite3 --version
echo ' ' say ' '
echo 'tor Version' say 'tor Version'
echo '*********************************************************' say '*********************************************************'
tor --version tor --version
echo ' ' say ' '
echo 'bitcoind Version' say 'bitcoind Version'
echo '*********************************************************' say '*********************************************************'
bitcoind --version bitcoind --version
echo ' ' say ' '
echo 'lightningd Version' say 'lightningd Version'
echo '*********************************************************' say '*********************************************************'
lightningd --version lightningd --version
echo ' ' say ' '
echo 'clboss Version' say 'clboss Version'
echo '*********************************************************' say '*********************************************************'
clboss --version clboss --version
echo "" say ""
echo -e "$BOLD\nOkay, well that's everything!${RESET}\n\nAs long as everything worked properly, \ say "$BOLD\nOkay, well that's everything!${RESET}\n\nAs long as everything worked properly, \
you should be ready to continue your journey\ntowards autonomy by opening ${BLUE}$ACCESS_POINT${RESET} in your browser." you should be ready to continue your journey\ntowards autonomy by opening ${BLUE}$ACCESS_POINT${RESET} in your browser."
echo -e "The default login is ${BLUE}dctrl/dctrl${RESET}, have fun!" say "The default login is ${BLUE}dctrl/dctrl${RESET}, have fun!"
exit 0 exit 0

Loading…
Cancel
Save