From c39fa7f66a1067adea9849818f3b19774df66549 Mon Sep 17 00:00:00 2001 From: Zen Date: Tue, 22 Feb 2022 21:36:02 -0600 Subject: [PATCH] pushing --- Makefile | 7 +- ingredients/copper | 6 +- ingredients/gold | 179 +++++++++++++++++++++++++++++++++------------ ingredients/lead | 3 +- ingredients/tin | 2 +- recipes/ao.sh | 89 +++------------------- 6 files changed, 154 insertions(+), 132 deletions(-) diff --git a/Makefile b/Makefile index 71a3510..3aa3af6 100644 --- a/Makefile +++ b/Makefile @@ -84,7 +84,12 @@ cool: arcana: $(eval MOD = cd 🜍;) - @cd 🜍 + @cd ~ curiosus: @$(MOD) ls + +signum: + @$(MOD) pwd + + diff --git a/ingredients/copper b/ingredients/copper index f85a010..11282a8 100644 --- a/ingredients/copper +++ b/ingredients/copper @@ -1,2 +1,4 @@ -internet connections? -using yggdrasil could maybe fit in here +# internet connections? copper wires etc. +# using yggdrasil could maybe fit in here +# nginx setup +# port checking diff --git a/ingredients/gold b/ingredients/gold index c29e754..4549a06 100644 --- a/ingredients/gold +++ b/ingredients/gold @@ -13,57 +13,144 @@ # the Bitcoin ecosystem install_bitcoin() { - echo -e "${BOLD}Installing Bitcoin Ecosystem${RESET}" + echo -e "${BOLD}Installing Bitcoin Core${RESET}" - if [ $ISA == 'x86_64' ] && [ ! -e 🜍/bitcoin-22.0* ]; then - wget https://bitcoincore.org/bin/bitcoin-core-22.0/bitcoin-22.0-x86_64-linux-gnu.tar.gz -P 🜍/ - elif [ $ISA == 'armv7l' ] && [ ! -e 🜍/bitcoin-22.0* ]; then - wget https://bitcoincore.org/bin/bitcoin-core-22.0/bitcoin-22.0-arm-linux-gnueabihf.tar.gz -P 🜍/ + # We're building bitcoin from source here. It might be slower than + # downloading the pre-built binaries but this is more reliable + if [ ! -e 🜍/bitcoin-22.0* ]; then + wget https://bitcoincore.org/bin/bitcoin-core-22.0/bitcoin-22.0.tar.gz -P 🜍/ fi + # This still relies on package management though + install_if_needed boost + tar -xvf 🜍/bitcoin-22.0.tar.gz sleep 1 cd bitcoin-22.0 - ./contrib/install_db4.sh `pwd` + chmod +x autogen.sh + ./autogen.sh + ./configure --without-bdb # Someday, someone will complain here + make + sudo make install + rm -rf bitcoin-22.0 +} + +install_lightning() { + echo -e "${BOLD}Installing lightningd${RESET}" + git clone https://github.com/ElementsProject/lightning.git ./lightning + pushd ./lightning + git checkout v0.10.2 + ./configure + + # The latest version of mistune breaks lightning install + pip uninstall mistune + pip install --user mistune==0.8.4 + pip install --user mrkd + make + sudo make install + popd + rm -rf lightning +} + +install_clboss() { + echo -e "${BOLD}Installing clboss${RESET}" + git clone https://github.com/ZmnSCPxj/clboss.git ./clboss + pushd ./clboss + git checkout 0.11B + mkdir -p m4 + autoreconf -fi + ./configure + make + sudo make install + popd + rm -rf clboss +} + +configure_bitcoin() { + mkdir -p ~/.bitcoin + + 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 -e "Looks like you already have a ${BLUE}bitcoin.conf${RESET} file!" + echo "" + cat $HOME/.bitcoin/bitcoin.conf + echo "" + echo -n "Would you like to reset it? (y/n): " + read btc_reconf + case $btc_reconf in + "y" | "Y") + cp resources/sample_bitcoin.conf $HOME/.bitcoin/bitcoin.conf + echo 'Reset bitcoin configuration file' + ;; + "n" | "N") + echo "Cool, we'll leave it as is then". + ;; + esac + 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 + echo "" + + echo -n "Next question - do you have 500GB of open memory on this device? (y/n): " + read prune + echo "" + case $prune in + y | Y) + echo "Okay great! We'll leave the bitcoin config it as it is." + ;; + *) + echo "Let's enable pruning to keep the file size down, then." + sed -i "s/txindex=1/prune=550/" $HOME/.bitcoin/bitcoin.conf + ;; + esac +} + +configure_lightning() { + mkdir -p $HOME/.lightning + + if [ -f $HOME/.lightning/config ]; then + echo -e "Looks like you already have a ${BLUE}lightning config${RESET} file!" + echo "" + cat $HOME/.lightning/config + echo "" + echo -n "Would you like to reset it? (y/n): " + read ln_reconf + case $ln_reconf in + "y" | "Y") + cp resources/sample_lightning_config $HOME/.lightning/config + echo -e "${GREEN}Reset lightning configuration file${RESET}" + ;; + "n" | "N") + echo "Cool, we'll leave it as is then". + ;; + esac + else + cp resources/sample_lightning_config $HOME/.lightning/config + echo -e "${GREEN}Created default lightning config${RESET}" + fi + + echo "" + echo -n "Would you like to use clboss to automatically open lightning channels? (y/n): " + read clboss_enable + case $clboss_enable in + "y" | "Y") + install_clboss + sed -i "s/#plugin/plugin/" $HOME/.lightning/config + sed -i "s/#log/log/" $HOME/.lightning/config + echo "" + echo -e "${GREEN}clboss successfully configured!${RESET}" + ;; + "n" | "N") + echo "" + echo "Sounds good. You might want to open some channels manually to participate in the network!". + ;; + esac } -#sudo cp bitcoin-22.0/bin/* /usr/local/bin/ -#rm -rf bitcoin-22.0 - - -#echo -e "${BOLD}Installing lightningd${RESET}" -#git clone https://github.com/ElementsProject/lightning.git ~/lightning -#pushd ~/lightning -#git checkout v0.10.2 -#./configure -# -## The latest version of mistune breaks lightning install -#pip uninstall mistune -#pip install --user mistune==0.8.4 -#pip install --user mrkd -#sudo make -#sudo make install -#popd -# -#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 -# -#echo "" -#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:]]*\$) -# -#if [ -f $HOME/.bitcoin/bitcoin.conf ]; then -# +GOLD=1 diff --git a/ingredients/lead b/ingredients/lead index f8440d6..c342227 100644 --- a/ingredients/lead +++ b/ingredients/lead @@ -57,7 +57,6 @@ check_exists() { install_if_needed() { for package in "$@" # $@ means "all the arguments you passed do - case $DISTRO in "debian") # TODO Better installation detection than check_exists @@ -98,4 +97,4 @@ install_if_needed() { done } - +LEAD=1 diff --git a/ingredients/tin b/ingredients/tin index 49cd4ee..21550b6 100644 --- a/ingredients/tin +++ b/ingredients/tin @@ -44,4 +44,4 @@ http_get() { sha256_check "${3}" "${2}" } - +TIN=1 diff --git a/recipes/ao.sh b/recipes/ao.sh index c0c1051..0260c09 100755 --- a/recipes/ao.sh +++ b/recipes/ao.sh @@ -36,10 +36,6 @@ if [ "$EUID" -eq 0 ]; then exit 1 fi -# Testing -install_bitcoin -exit 0 - echo -e "Making sure we've got the basics..." echo -e "(you'll probably need to input ${BLUE}your 'sudo' password${RESET} here)" case $DISTRO in @@ -115,89 +111,22 @@ if [ $AO = "3" ] || [ $AO = 'react' ]; then nvm use default fi - -# 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) if [ $AO = "3" ] || [ $AO = 'react' ]; then echo -e "${BOLD}Installing Bitcoin Ecosystem${RESET}" - - if [ $ISA == 'x86_64' ] && [ ! -e images/bitcoin-22.0* ]; then - wget https://bitcoincore.org/bin/bitcoin-core-22.0/bitcoin-22.0-x86_64-linux-gnu.tar.gz -P images/ - elif [ $ISA == 'armv7l' ] && [ ! -e images/bitcoin-22.0* ]; then - 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 - sleep 1 - - sudo cp bitcoin-22.0/bin/* /usr/local/bin/ - rm -rf bitcoin-22.0 - - - echo -e "${BOLD}Installing lightningd${RESET}" - git clone https://github.com/ElementsProject/lightning.git ~/lightning - pushd ~/lightning - git checkout v0.10.2 - ./configure - - # The latest version of mistune breaks lightning install - pip uninstall mistune - pip install --user mistune==0.8.4 - pip install --user mrkd - sudo make - sudo make install - popd - - 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 - echo "" - 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:]]*\$) - 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' + if ! check_exists bitcoind; then + echo -e "Building bitcoind from source... might take a while!" + install_bitcoin fi - sed -i "s/BTC_LOGIN/${AUTHLINE}/" $HOME/.bitcoin/bitcoin.conf - - 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 "" - - 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' + if ! check_exists lightningd; then + echo -e "Building lightningd from source... here we go again" + install_lightning fi + + configure_bitcoin + configure_lightning fi echo ''