diff --git a/init.sh b/init.sh index 48ca68d..0a3ac11 100755 --- a/init.sh +++ b/init.sh @@ -13,72 +13,74 @@ echo -e "${GREEN}${ULINE}Environment${RESET}" if [ -f .env ]; then grep -v '^#' .env export $(grep -v '^#' .env | xargs) -else +else echo "No .env file found, initializing" echo "ALCHEMY=true" > .env fi echo "" -echo -e "${GREEN}${ULINE}System Basics${RESET}" +echo -e "${GREEN}${ULINE}System Basics${RESET}" if [[ $ISA && $DISTRO && $UPDATED ]]; then echo "Nothing to do!" fi if [[ ! $ISA ]]; then - ISA=$(uname -m) - if [ $ISA == 'x86_64' ]; then - echo -e "Ayyy you got yourself an ${GREEN}x86${RESET} processor, cool" - elif [ $ISA == 'armv7l' ]; then - echo -e "I see you rockin an ${GREEN}ARM${RESET} processor, neato" - fi + ISA=$(uname -m) + if [ $ISA == 'x86_64' ]; then + echo -e "Ayyy you got yourself an ${GREEN}x86${RESET} processor, cool" + elif [ $ISA == 'armv7l' ]; then + echo -e "I see you rockin an ${GREEN}ARM${RESET} processor, neato" + fi echo "ISA=$ISA" >> .env fi if [[ ! $DISTRO ]]; then - if [ -f "/etc/debian_version" ]; then - DISTRO="debian" - echo -e "${GREEN}Debian${RESET}, Ubuntu, or Raspbian OS detected." - elif [ -f "/etc/arch-release" ]; then - DISTRO="arch" - echo -e "${GREEN}Arch or Manjaro-based${RESET} OS detected." - elif [ -f "/etc/fedora-release" ]; then - DISTRO="fedora" - echo -e "${GREEN}Fedora${RESET} detected as the Operating System" - elif [ $(uname | grep -c "Darwin") -eq 1 ]; then - DISTRO="mac" - echo -e "${GREEN}MacOS${RESET} detected." - else - echo -e "I don't know ${RED}what OS you're running${RESET}! Cancelling this operation." - exit 1 + if [ -f "/etc/debian_version" ]; then + DISTRO="debian" + echo -e "${GREEN}Debian${RESET}, Ubuntu, or Raspbian OS detected." + elif [ -f "/etc/arch-release" ]; then + DISTRO="arch" + echo -e "${GREEN}Arch or Manjaro-based${RESET} OS detected." + elif [ -f "/etc/fedora-release" ]; then + DISTRO="fedora" + echo -e "${GREEN}Fedora${RESET} detected as the Operating System" + elif [ $(uname | grep -c "Darwin") -eq 1 ]; then + DISTRO="mac" + echo -e "${GREEN}MacOS${RESET} detected." + else + echo -e "I don't know ${RED}what OS you're running${RESET}! Cancelling this operation." + exit 1 fi echo "DISTRO=$DISTRO" >> .env fi if [[ ! $UPDATED ]]; then echo "" - echo "Updating the repositories..." - echo -e "(you'll probably need to input ${BLUE}your 'sudo' password${RESET} here)" - case $DISTRO in - "debian") - sudo apt update - sudo apt autoremove - sudo apt upgrade - ;; - "arch") - sudo pacman -Syu - ;; - "fedora") - sudo dnf update - sudo dnf upgrade - ;; - "mac") - install - sudo brew update - ;; - esac + echo "Updating the repositories..." + echo -e "(you'll probably need to input ${BLUE}your 'sudo' password${RESET} here)" + case $DISTRO in + "debian") + sudo apt update + sudo apt autoremove + sudo apt upgrade + sudo apt install build-essential + ;; + "arch") + sudo pacman -Syu --noconfirm + sudo pacman -S base-devel --noconfirm + ;; + "fedora") + sudo dnf update + sudo dnf upgrade + ;; + "mac") + install + sudo brew update + ;; + esac echo "UPDATED=true" >> .env fi echo "" -echo -e "${GREEN}${ULINE}Base Dependencies${RESET}" -install_if_needed make git wget +echo -e "${GREEN}${ULINE}Core Dependencies${RESET}" +install_if_needed git wget diff --git a/resources/ao-config b/resources/ao-config index f5d8f07..7ee2f90 100644 --- a/resources/ao-config +++ b/resources/ao-config @@ -1,35 +1,35 @@ -export default { - bitcoind: { +export default { + bitcoind: { network: 'mainnet', username: 'ao', password: 'PASSLINE' - }, - bitcoinAverage: { - pub: '', - secret: '' - }, - clightning: { - // default is '~/.lightning/bitcoin' - dir: 'CLIGHTNING_DIR' - }, - tor: { - //hostname: '$TORHOSTNAME' - hostname: 'TOR_HOSTNAME' - }, - sqlite3: { + }, + bitcoinAverage: { + pub: '', + secret: '' + }, + clightning: { + // default is '~/.lightning/bitcoin' + dir: 'CLIGHTNING_DIR' + }, + tor: { + //hostname: '$TORHOSTNAME' + hostname: 'TOR_HOSTNAME' + }, + sqlite3: { // default is '~/.ao/database.sqlite3' - file: 'SQLITE_DATABASE' - }, - hostnames: [] + file: 'SQLITE_DATABASE' + }, + hostnames: [], privateKey: 'PRIVATEKEY', - memes: { + memes: { // default is ~/.ao/memes' - dir: 'MEMES_DIR' - }, - jitsi: { - domain: 'meet.dctrl.ca' - }, - socketUrl: 'http://localhost:8003' // development - // socketUrl: null // production -} - + dir: 'MEMES_DIR' + }, + jitsi: { + domain: 'meet.dctrl.ca' + }, + socketUrl: 'http://localhost:8003' // development + // socketUrl: null // production +} + diff --git a/resources/ao.nginx.conf b/resources/ao.nginx.conf index 1ca6fac..926fe20 100644 --- a/resources/ao.nginx.conf +++ b/resources/ao.nginx.conf @@ -2,10 +2,10 @@ server { listen 80 default_server; listen [::]:80 default_server; - server_name SERVER_NAME; + server_name SERVER_NAME; root FILE_ROOT; index index.html; - + location = /favicon.ico { log_not_found off; access_log off; diff --git a/resources/bitcoin-service-template b/resources/bitcoin-service-template index 1559315..3985431 100644 --- a/resources/bitcoin-service-template +++ b/resources/bitcoin-service-template @@ -1,9 +1,9 @@ -[Unit] +[Unit] Description=Bitcoin daemon After=network.target - -[Service] -Type=notify + +[Service] +Type=notify NotifyAccess=all ExecStart=BITCOIND --daemon --server --pid=HOME/.bitcoin/bitcoind.pid @@ -11,17 +11,17 @@ Type=forking PIDFile=HOME/.bitcoin/bitcoind.pid Restart=on-failure -KillSignal=SIGINT +KillSignal=SIGINT TimeoutSec=60 WatchdogSec=60 LimitNOFILE=32768 -User=USER -Group=USER - +User=USER +Group=USER + # Hardening PrivateTmp=yes PrivateDevices=yes MemoryDenyWriteExecute=true - -[Install] + +[Install] WantedBy=multi-user.target diff --git a/resources/lightning-service-template b/resources/lightning-service-template index 20945fb..5d2a450 100644 --- a/resources/lightning-service-template +++ b/resources/lightning-service-template @@ -1,12 +1,12 @@ -[Unit] +[Unit] Description=C-Lightning daemon Requires=bitcoin.service After=bitcoin.service Wants=network.target After=network.target - -[Service] -Type=forking + +[Service] +Type=forking NotifyAccess=all ExecStart=LIGHTNINGD --daemon --log-file HOME/.lightning/log --conf HOME/.lightning/config --pid-file=HOME/.lightning/lightningd.pid User=USER @@ -15,17 +15,17 @@ Type=forking PIDFile=HOME/.lightning/lightningd.pid Restart=on-failure -KillSignal=SIGINT +KillSignal=SIGINT TimeoutSec=60 WatchdogSec=60 LimitNOFILE=32768 - + # Hardening PrivateTmp=yes PrivateDevices=yes ProtectSystem=true MemoryDenyWriteExecute=true NoNewPrivileges=true - -[Install] + +[Install] WantedBy=multi-user.target diff --git a/resources/solarized.vim b/resources/solarized.vim index 70f5223..72c9ed5 100644 --- a/resources/solarized.vim +++ b/resources/solarized.vim @@ -19,9 +19,9 @@ " --------------------------------------------------------------------- " OPTIONS: " --------------------------------------------------------------------- -" See the "solarized.txt" help file included with this colorscheme (in the -" "doc" subdirectory) for information on options, usage, the Toggle Background -" function and more. If you have already installed Solarized, this is available +" See the "solarized.txt" help file included with this colorscheme (in the +" "doc" subdirectory) for information on options, usage, the Toggle Background +" function and more. If you have already installed Solarized, this is available " from the Solarized menu and command line as ":help solarized" " " --------------------------------------------------------------------- @@ -36,7 +36,7 @@ " and unarchive the file. " 2. Move `solarized.vim` to your `.vim/colors` directory. " 3. Move each of the files in each subdirectories to the corresponding .vim -" subdirectory (e.g. autoload/togglebg.vim goes into your .vim/autoload +" subdirectory (e.g. autoload/togglebg.vim goes into your .vim/autoload " directory as .vim/autoload/togglebg.vim). " " RECOMMENDED PATHOGEN INSTALLATION OPTION: @@ -131,7 +131,7 @@ " " }}} " Environment Specific Overrides "{{{ -" Allow or disallow certain features based on current terminal emulator or +" Allow or disallow certain features based on current terminal emulator or " environment. " Terminals that support italics @@ -159,8 +159,8 @@ endif " }}} " Default option values"{{{ " --------------------------------------------------------------------- -" s:options_list is used to autogenerate a list of all non-default options -" using "call SolarizedOptions()" or with the "Generate .vimrc commands" +" s:options_list is used to autogenerate a list of all non-default options +" using "call SolarizedOptions()" or with the "Generate .vimrc commands" " Solarized menu option. See the "Menus" section below for the function itself. let s:options_list=[ \'" this block of commands has been autogenerated by solarized.vim and', @@ -484,8 +484,8 @@ exe "let s:fmt_ital = ' ".s:vmode."=NONE".s:i. " term=NONE".s:i."'" exe "let s:fmt_stnd = ' ".s:vmode."=NONE".s:s. " term=NONE".s:s."'" exe "let s:fmt_revr = ' ".s:vmode."=NONE".s:r. " term=NONE".s:r."'" exe "let s:fmt_revb = ' ".s:vmode."=NONE".s:r.s:b. " term=NONE".s:r.s:b."'" -" revbb (reverse bold for bright colors) is only set to actual bold in low -" color terminals (t_co=8, such as OS X Terminal.app) and should only be used +" revbb (reverse bold for bright colors) is only set to actual bold in low +" color terminals (t_co=8, such as OS X Terminal.app) and should only be used " with colors 8-15. exe "let s:fmt_revbb = ' ".s:vmode."=NONE".s:r.s:bb. " term=NONE".s:r.s:bb."'" exe "let s:fmt_revbbu = ' ".s:vmode."=NONE".s:r.s:bb.s:u." term=NONE".s:r.s:bb.s:u."'" @@ -729,7 +729,7 @@ hi! link diffLine Identifier "exe "hi! gitDiffAdded" "exe "hi! gitDiffRemoved" "gitcommit -"exe "hi! gitcommitSummary" +"exe "hi! gitcommitSummary" exe "hi! gitcommitComment" .s:fmt_ital .s:fg_base01 .s:bg_none hi! link gitcommitUntracked gitcommitComment hi! link gitcommitDiscarded gitcommitComment @@ -972,19 +972,19 @@ hi! link pandocMetadataTitle pandocMetadata "}}} " Utility autocommand "{{{ " --------------------------------------------------------------------- -" In cases where Solarized is initialized inside a terminal vim session and -" then transferred to a gui session via the command `:gui`, the gui vim process -" does not re-read the colorscheme (or .vimrc for that matter) so any `has_gui` +" In cases where Solarized is initialized inside a terminal vim session and +" then transferred to a gui session via the command `:gui`, the gui vim process +" does not re-read the colorscheme (or .vimrc for that matter) so any `has_gui` " related code that sets gui specific values isn't executed. " -" Currently, Solarized sets only the cterm or gui values for the colorscheme -" depending on gui or terminal mode. It's possible that, if the following -" autocommand method is deemed excessively poor form, that approach will be +" Currently, Solarized sets only the cterm or gui values for the colorscheme +" depending on gui or terminal mode. It's possible that, if the following +" autocommand method is deemed excessively poor form, that approach will be " used again and the autocommand below will be dropped. " -" However it seems relatively benign in this case to include the autocommand -" here. It fires only in cases where vim is transferring from terminal to gui -" mode (detected with the script scope s:vmode variable). It also allows for +" However it seems relatively benign in this case to include the autocommand +" here. It fires only in cases where vim is transferring from terminal to gui +" mode (detected with the script scope s:vmode variable). It also allows for " other potential terminal customizations that might make gui mode suboptimal. " autocmd GUIEnter * if (s:vmode != "gui") | exe "colorscheme " . g:colors_name | endif @@ -998,7 +998,7 @@ function! s:SolarizedHiTrail() syn match solarizedTrailingSpace "\s*$" exe "hi! solarizedTrailingSpace " .s:fmt_undr .s:fg_red .s:bg_none .s:sp_red endif -endfunction +endfunction augroup SolarizedHiTrail autocmd! if g:solarized_hitrail==1 diff --git a/resources/tmux.conf b/resources/tmux.conf index 27db9f5..41edfd1 100644 --- a/resources/tmux.conf +++ b/resources/tmux.conf @@ -20,7 +20,7 @@ bind l select-pane -R # reloading for faster tmux configuration bind r source-file ~/.tmux.conf \; display ​"Reloaded!" -# a e s t h e t i c s +# a e s t h e t i c s set -g default-terminal "tmux-256color" set -g default-shell /bin/zsh set-option -g status on diff --git a/resources/tor-service-template b/resources/tor-service-template index 54b5acf..14954e1 100644 --- a/resources/tor-service-template +++ b/resources/tor-service-template @@ -1,23 +1,23 @@ -[Unit] -Description=Anonymizing overlay network for TCP (multi-instance-master) +[Unit] +Description=Anonymizing overlay network for TCP (multi-instance-master) After=syslog.target network.target nss-lookup.target - -[Service] -Type=notify + +[Service] +Type=notify NotifyAccess=all -ExecStartPre=+/bin/chown USER:USER /var/lib/tor +ExecStartPre=+/bin/chown USER:USER /var/lib/tor ExecStartPre=TORPATH -f TORRCPATH --verify-config ExecStart=TORPATH -f TORRCPATH ExecReload=/bin/kill -HUP ${MAINPID} -KillSignal=SIGINT +KillSignal=SIGINT TimeoutSec=60 Restart=on-failure WatchdogSec=60 LimitNOFILE=32768 -User=root -Group=USER - +User=root +Group=USER + # Hardening PrivateTmp=yes PrivateDevices=yes @@ -29,6 +29,6 @@ ReadWriteDirectories=-/var/log/tor ReadWriteDirectories=-HOME/.tor NoNewPrivileges=no CapabilityBoundingSet=CAP_SETUID CAP_SETGID CAP_NET_BIND_SERVICE CAP_DAC_READ_SEARCH - -[Install] + +[Install] WantedBy=multi-user.target diff --git a/resources/vimrc b/resources/vimrc index 0887776..75c83da 100644 --- a/resources/vimrc +++ b/resources/vimrc @@ -23,7 +23,7 @@ set expandtab " Searching -- press '/' to search in vim (or '?' to search backwards) set incsearch " Highlights as you type -set ignorecase +set ignorecase set smartcase " ignore case, unless you capitalise set hlsearch set showmatch diff --git a/resources/wordpress.nginx.conf b/resources/wordpress.nginx.conf index a655753..f84a734 100644 --- a/resources/wordpress.nginx.conf +++ b/resources/wordpress.nginx.conf @@ -2,10 +2,10 @@ server { listen 80 default_server; listen [::]:80 default_server; - server_name SERVER_NAME; + server_name SERVER_NAME; root FILE_ROOT; index index.php; - + location = /favicon.ico { log_not_found off; access_log off; diff --git a/resources/wordpress.tar.gz b/resources/wordpress.tar.gz index 8f23bea..5507ad9 100644 Binary files a/resources/wordpress.tar.gz and b/resources/wordpress.tar.gz differ diff --git a/resources/zshrc-extras b/resources/zshrc-extras index d21fb7e..356f8d7 100644 --- a/resources/zshrc-extras +++ b/resources/zshrc-extras @@ -1,10 +1,10 @@ # Extra Aliases alias b='cd ..' - -# Checks for active tmux -tmux ls &> /dev/null -if [ $? -eq 0 ] && [ -z "$TMUX" ]; then - echo "\nYou have an active tmux session! Run 'tmux attach' to restore it.\n" + +# Checks for active tmux +tmux ls &> /dev/null +if [ $? -eq 0 ] && [ -z "$TMUX" ]; then + echo "\nYou have an active tmux session! Run 'tmux attach' to restore it.\n" elif [ -z "$TMUX" ]; then tmux new -s "tmux" -fi +fi diff --git a/scripts/ao.sh b/scripts/ao.sh index dab7b89..168075b 100755 --- a/scripts/ao.sh +++ b/scripts/ao.sh @@ -16,7 +16,7 @@ echo ' d88P 888 888 888 888 888 888 "Y8888b. 888 .d888888 88 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 '' - + # ------------------- Step 1 - Baseline Setup ------------------- @@ -26,7 +26,7 @@ echo -e "This script is designed to ask you just enough questions to keep you in read # echo -e "${ULINE}System Basics${RESET}" -# +# # if [ -f "/etc/debian_version" ]; then # DISTRO="debian" # echo -e "${GREEN}Debian${RESET}, Ubuntu, or Raspbian OS detected." @@ -43,31 +43,31 @@ read # echo -e "I don't know ${RED}what OS you're running${RESET}! Cancelling this operation." # exit 1 # fi -# +# # ARCHY=$(uname -m) -# +# # if [ $ARCHY == 'x86_64' ]; then # echo -e "Ayyy you got yourself an ${GREEN}x86${RESET} processor, cool" # elif [ $ARCHY == 'armv7l' ]; then # echo -e "I see you rockin an ${GREEN}ARM${RESET} processor, neato" # fi -# +# # echo "" # export ALCHEMY_DISTRO=$DISTRO # export ALCHEMY_ARCH=$ARCHY # echo "" -# -# echo -e "Got it! Next we're going to make sure the system's repositories (where they get their data from)\nare updated and that you have all the basic command line utilities we need to continue. \n\n${BLUE}(enter)${RESET}" +# +# echo -e "Got it! Next we're going to make sure the system's repositories (where they get their data from)\nare updated and that you have all the basic command line utilities we need to continue. \n\n${BLUE}(enter)${RESET}" # read -# +# # # Coding Moment: generally, whenever you see something with brackets at the end of it, like this() # # or like(this), it's a function! It takes inputs and gives (or does) something as an output -# install_if_needed() { +# install_if_needed() { # for package in "$@" # do # if [ -z $(which $package 2>/dev/null) ]; then # echo "installing" $package -# +# # case $DISTRO in # "debian") # sudo apt install -y $package @@ -82,13 +82,13 @@ read # brew install $package # ;; # esac -# +# # else # echo $package 'already installed!' # fi # done # } -# +# # echo "Updating the repositories..." # echo -e "(you'll probably need to input ${BLUE}your 'sudo' password${RESET} here)" # case $DISTRO in @@ -126,7 +126,7 @@ case $DISTRO in fi install_if_needed wget python gmp sqlite3 \ - python-mako python-pip net-tools zlib libsodium gettext dnsutil nginx + python-mako python-pip net-tools zlib libsodium gettext dnsutils nginx ;; "mac") # install_if_needed better-computer @@ -146,7 +146,7 @@ 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} " - read -n1 ao_select + read -n1 ao_select echo "" echo "" @@ -233,16 +233,16 @@ if [ $AO = "3" ] || [ $AO = 'react' ]; then echo -e "${BOLD}Bitcoin installed!${RESET} Let's make sure it's configured now." mkdir -p ~/.bitcoin - AUTHDEETS=$(python3 scripts/rpcauth.py ao) - AUTHLINE=$(echo $AUTHDEETS | grep -o rpcauth=ao:[^[:space:]]*[[:space:]]) - PASSLINE=$(echo $AUTHDEETS | grep -o [^[:space:]]*\$) + AUTHDEETS=$(python3 scripts/rpcauth.py ao) + AUTHLINE=$(echo $AUTHDEETS | grep -o rpcauth=ao:[^[:space:]]*[[:space:]]) + PASSLINE=$(echo $AUTHDEETS | grep -o [^[:space:]]*\$) - 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 + 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 sed -i "s/BTC_LOGIN/${AUTHLINE}/" $HOME/.bitcoin/bitcoin.conf @@ -262,12 +262,12 @@ if [ $AO = "3" ] || [ $AO = 'react' ]; then mkdir -p $HOME/.lightning - 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 + 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 fi echo '' @@ -277,7 +277,7 @@ if [ $AO = "3" ] || [ $AO = 'react' ]; then if [ -e /usr/local/etc/tor/torrc ]; then TORRCPATH='/usr/local/etc/tor/torrc' - elif [ -e /etc/tor/torrc ]; then + elif [ -e /etc/tor/torrc ]; then TORRCPATH='/etc/tor/torrc' fi @@ -300,14 +300,28 @@ fi echo -e "${BOLD}Configuring AO Core${RESET}\n" -mkdir -p $HOME/.ao +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 -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 +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 "" case $AO in @@ -317,23 +331,12 @@ case $AO in pushd ~/ao-3 npm install npm run build - - if [ -f "$HOME/ao-3/configuration.js" ]; then - echo configuration.js already exists - else - cp resources/ao-config $HOME/ao-react/configuration.js - sed -i "s#SQLITE_DATABASE#${HOME}/.ao/database.sqlite3#" $HOME/ao-react/configuration.js - sed -i "s#CLIGHTNING_DIR#${HOME}/.lightning/bitcoin#" $HOME/ao-react/configuration.js - sed -i "s#MEMES_DIR#${HOME}/.ao/memes#" $HOME/ao-react/configuration.js - fi - npm run checkconfig popd ;; "react") echo -e "Installing ${BLUE}ao-react${RESET}" git clone 'https://github.com/coalition-of-invisible-colleges/ao-react.git' ~/ao-react - pushd ~/ao-react npm install npm run webpack @@ -341,24 +344,10 @@ case $AO in ;; esac -# TODO this is kind of janky/fragile, it would be better to store this in ~/.ao -CONFIG_FILE=$HOME/ao-$AO/configuration.js - -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 - # ------------------- Step 4 - NGINX Setup ------------------- echo "" - echo -e "You still there? I need to ask you some questions! \n\n${BLUE}(enter)${RESET}" + echo -e "You still there? I need to ask you some questions! \n\n${BLUE}(enter)${RESET}" read echo "" read -p "Do you have a domain name pointing to this computer? (y/n): " dns @@ -375,13 +364,13 @@ fi echo "Try accessing this AO from either localhost, 127.0.0.1, or ${domain}" ;; esac - + if [ "$anywhere" -eq 1 ]; then ACCESS_POINT=http://localhost else ACCESS_POINT=https://$domain fi - + echo "" # Making sure this version of NGINX supports sites-enabled @@ -395,13 +384,13 @@ fi AO_NGINX_CONF=/etc/nginx/sites-available/ao sudo cp resources/ao.nginx.conf $AO_NGINX_CONF - + 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 - + sudo sed -i "s#FILE_ROOT#${HOME}/ao-react/dist#" $AO_NGINX_CONF if [ ! -e /etc/nginx/sites-enabled/ao ]; then @@ -410,7 +399,7 @@ fi echo "" echo "Excellent! We've configured $AO_NGINX_CONF to serve your AO from $domain" echo "" - + read -p "Would you like to enable SSL via Certbot? (y/n): " -n1 ssl echo "" case $ssl in @@ -432,7 +421,7 @@ 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." while [[ -z $READY ]]; do echo -en "${BLUE}You ready? (y/n):${RESET} " - read -n1 ao_select + read -n1 ao_select echo "" echo "" @@ -488,7 +477,7 @@ else fi echo -e "Enabling and starting ${GREEN}Bitcoin${RESET}" sudo systemctl enable bitcoin -sudo systemctl start bitcoin +sudo systemctl start bitcoin echo "" echo "Creating lightning.service..." @@ -505,7 +494,7 @@ else fi echo -e "Enabling and starting ${GREEN}lightning${RESET} " sudo systemctl enable lightning -sudo systemctl start lightning +sudo systemctl start lightning echo "" echo "Creating ao.service..." @@ -522,7 +511,7 @@ else fi echo -e "Enabling and starting the ${GREEN}AO${RESET}'s backend" sudo systemctl enable ao -sudo systemctl start ao +sudo systemctl start ao echo "" echo -e "Enabling and starting ${GREEN}NGINX${RESET} as the webserver" @@ -564,37 +553,37 @@ fi echo '*********************************************************' echo -e "* ${BOLD}Version Information${RESET} *" echo '*********************************************************' - + echo ' ' echo 'make Version' echo '*********************************************************' make --version - + echo ' ' echo 'node Version' echo '*********************************************************' node --version - + echo ' ' echo 'sqlite3 Version' echo '*********************************************************' sqlite3 --version - + echo ' ' echo 'tor Version' echo '*********************************************************' tor --version - + echo ' ' echo 'bitcoind Version' echo '*********************************************************' bitcoind --version - + echo ' ' echo 'lightningd Version' echo '*********************************************************' lightningd --version - + echo ' ' echo 'clboss Version' echo '*********************************************************' diff --git a/scripts/ingredients b/scripts/ingredients index 74d1048..f7c5319 100644 --- a/scripts/ingredients +++ b/scripts/ingredients @@ -1,49 +1,49 @@ #!/bin/bash -# Font decoration for better a e s t h e t i c -RED="\e[0;31m" -GREEN="\e[0;32m" -BLUE="\e[0;34m" -BOLD="\e[1m" -ULINE="\e[4m" -RESET="\e[0m" +# Font decoration for better a e s t h e t i c +RED="\e[0;31m" +GREEN="\e[0;32m" +BLUE="\e[0;34m" +BOLD="\e[1m" +ULINE="\e[4m" +RESET="\e[0m" -# Make sure that ctrl+C actually exits the script -trap "exit" INT +# Make sure that ctrl+C actually exits the script +trap "exit" INT # Give informative error messages -trap 'echo "Oops! Something went wrong on line $LINENO of this script. Exit code was $?" >&2' ERR +trap 'echo -e "${RED}Oops!${RESET} Something went wrong on line $LINENO of this script. Exit code was $?" >&2' ERR # --------------- Functions --------------- -# Coding Moment: generally, whenever you see something with brackets at the end of it, like this() -# or like(this), it's a function! It takes inputs and gives (or does) something as an output +# Coding Moment: generally, whenever you see something with brackets at the end of it, like this() +# or like(this), it's a function! It takes inputs and gives (or does) something as an output -install_if_needed() { - for package in "$@" - do +install_if_needed() { + for package in "$@" + do # TODO Better installation detection than "which" - if [ -z $(which $package 2>/dev/null) ]; then - echo "installing" $package + if [ -z $(which $package 2>/dev/null) ]; then + echo "installing" $package - case $DISTRO in - "debian") - sudo apt install -y $package - ;; - "arch") - sudo pacman -S $package --noconfirm --needed - ;; - "fedora") - sudo dnf install -y $package - ;; - "mac") - brew install $package - ;; - esac - else - echo $package 'already installed!' - fi - done -} + case $DISTRO in + "debian") + sudo apt install -y $package + ;; + "arch") + sudo pacman -S $package --noconfirm --needed + ;; + "fedora") + sudo dnf install -y $package + ;; + "mac") + brew install $package + ;; + esac + else + echo $package 'already installed!' + fi + done +} # --------------- Environment Setup --------------- if [ -f .env ]; then diff --git a/scripts/wordpress.sh b/scripts/wordpress.sh index 7b36ceb..7c11d91 100755 --- a/scripts/wordpress.sh +++ b/scripts/wordpress.sh @@ -79,7 +79,7 @@ while [[ MATCH -eq 0 ]]; do sudo mariadb -e "CREATE DATABASE wordpress;" sudo mariadb -e "GRANT ALL ON wordpress.* TO '${USER}'@'localhost' IDENTIFIED BY '${pass}' WITH GRANT OPTION;" sudo mariadb -e "FLUSH PRIVILEGES;" - else + else echo "Passwords did not match :(" echo "" fi diff --git a/scripts/write-image.sh b/scripts/write-image.sh index 293a675..16ba3b7 100755 --- a/scripts/write-image.sh +++ b/scripts/write-image.sh @@ -74,7 +74,7 @@ esac echo "" echo -e "Getting ready to write ${GREEN}$image${NC} to ${BLUE}$target${NC}" echo "" -read -p "Press Enter to continue (ctrl+C to cancel):" +read -p "Press Enter to continue (ctrl+C to cancel):" case $image in *.iso)