Browse Source

fixed some small bugs with remembering BTC_PASS

main
Zen 3 years ago
parent
commit
1795378628
  1. 2
      ingredients/copper
  2. 91
      ingredients/gold
  3. 30
      ingredients/lead
  4. 23
      recipes/ao.sh
  5. 2
      resources/sample_bitcoin.conf

2
ingredients/copper

@ -246,7 +246,7 @@ check_ports() {
ADDR=$DOMAIN ADDR=$DOMAIN
fi fi
echo -e "Querying this computer from ${BLUE}${ADDR}${RESET}" echo -e "Querying this computer's network from ${BLUE}${ADDR}${RESET}"
echo "" echo ""
install_if_needed nmap install_if_needed nmap
nmap -Pn $EXTERNAL_IP > nmap.txt nmap -Pn $EXTERNAL_IP > nmap.txt

91
ingredients/gold

@ -13,7 +13,7 @@
# the Bitcoin ecosystem # the Bitcoin ecosystem
install_bitcoin() { install_bitcoin() {
echo -e "${BOLD}Installing Bitcoin Core${RESET}" say "${BOLD}Installing Bitcoin Core${RESET}"
# We're building bitcoin from source here. It might be slower than # We're building bitcoin from source here. It might be slower than
# downloading the pre-built binaries but this is more reliable # downloading the pre-built binaries but this is more reliable
@ -36,7 +36,7 @@ install_bitcoin() {
} }
install_lightning() { install_lightning() {
echo -e "${BOLD}Installing lightningd${RESET}" say "${BOLD}Installing lightningd${RESET}"
git clone https://github.com/ElementsProject/lightning.git ./lightning git clone https://github.com/ElementsProject/lightning.git ./lightning
pushd ./lightning pushd ./lightning
git checkout v0.10.2 git checkout v0.10.2
@ -53,7 +53,7 @@ install_lightning() {
} }
install_clboss() { install_clboss() {
echo -e "${BOLD}Installing clboss${RESET}" say "${BOLD}Installing clboss${RESET}"
git clone https://github.com/ZmnSCPxj/clboss.git ./clboss git clone https://github.com/ZmnSCPxj/clboss.git ./clboss
pushd ./clboss pushd ./clboss
git checkout 0.11B git checkout 0.11B
@ -70,43 +70,49 @@ configure_bitcoin() {
mkdir -p ~/.bitcoin mkdir -p ~/.bitcoin
AUTHDEETS=$(python3 scripts/rpcauth.py ao) AUTHDEETS=$(python3 scripts/rpcauth.py ao)
AUTHLINE=$(echo $AUTHDEETS | grep -o rpcauth=ao:[^[:space:]]*[[:space:]]) AUTHLINE=$(say "$AUTHDEETS" | sed '2q;d' )
PASSLINE=$(echo $AUTHDEETS | grep -o [^[:space:]]*\$) PASSLINE=$(say "$AUTHDEETS" | sed '4q;d' )
remember "BTC_PASS=${PASSLINE}"
if [ -f $HOME/.bitcoin/bitcoin.conf ]; then if [ -f $HOME/.bitcoin/bitcoin.conf ]; then
echo -e "Looks like you already have a ${BLUE}bitcoin.conf${RESET} file!" say "Looks like you already have a ${BLUE}bitcoin.conf${RESET} file!"
echo "" say ""
cat $HOME/.bitcoin/bitcoin.conf cat $HOME/.bitcoin/bitcoin.conf
echo "" say ""
echo -en "Would you like to reset it? ${BLUE}(y/n)${RESET}: " ask_for btc_reconf "Would you like to reset it? ${BLUE}(y/n)${RESET}: "
read btc_reconf
case $btc_reconf in case $btc_reconf in
"y" | "Y") "y" | "Y")
cp resources/sample_bitcoin.conf $HOME/.bitcoin/bitcoin.conf cp resources/sample_bitcoin.conf $HOME/.bitcoin/bitcoin.conf
echo 'Reset bitcoin configuration file' say 'Reset bitcoin configuration file'
;; ;;
"n" | "N") "n" | "N")
echo "Cool, we'll leave it as is then". say "Cool, we'll leave it as is then".
;; ;;
esac esac
else else
cp resources/sample_bitcoin.conf $HOME/.bitcoin/bitcoin.conf cp resources/sample_bitcoin.conf $HOME/.bitcoin/bitcoin.conf
echo 'Created default bitcoin config' say 'Created default bitcoin config'
fi fi
sed -i "s/BTC_LOGIN/${AUTHLINE}/" $HOME/.bitcoin/bitcoin.conf sed -i "s/BTC_LOGIN/${AUTHLINE}/" $HOME/.bitcoin/bitcoin.conf
echo "" say ""
echo -en "Next question - do you have 500GB of open memory on this device? ${BLUE}(y/n)${RESET}: " ask_for prune "Next question - would you like to operate bitcoin in pruned mode? \
read prune This reduces its file size from ~500GB to something more portable ${BLUE}(y/n)${RESET}: "
echo "" say ""
case $prune in case $prune in
y | Y) y | Y)
echo "Okay great! We'll leave the bitcoin config it as it is." say "Let's ${GREEN}enable pruning${RESET} to keep the file size down, then."
prune_size=0
while [ "$prune_size" -lt 550 ]; do
ask_for prune_size "How many Mb are you willing to put towards btc? Min 550: "
done
sed -i "s/txindex=1/prune=${prune_size}/" $HOME/.bitcoin/bitcoin.conf
;; ;;
*) *)
echo -e "Let's ${GREEN}enable pruning${RESET} to keep the file size down, then." say "Okay great! We'll leave the bitcoin config it as it is."
sed -i "s/txindex=1/prune=550/" $HOME/.bitcoin/bitcoin.conf
;; ;;
esac esac
} }
@ -115,29 +121,27 @@ configure_lightning() {
mkdir -p $HOME/.lightning mkdir -p $HOME/.lightning
if [ -f $HOME/.lightning/config ]; then if [ -f $HOME/.lightning/config ]; then
echo -e "Looks like you already have a ${BLUE}lightning config${RESET} file!" say "Looks like you already have a ${BLUE}lightning config${RESET} file!"
echo "" say ""
cat $HOME/.lightning/config cat $HOME/.lightning/config
echo "" say ""
echo -en "Would you like to reset it? ${BLUE}(y/n)${RESET}: " ask_for ln_reconf "Would you like to reset it? ${BLUE}(y/n)${RESET}: "
read ln_reconf
case $ln_reconf in case $ln_reconf in
"y" | "Y") "y" | "Y")
cp resources/sample_lightning_config $HOME/.lightning/config cp resources/sample_lightning_config $HOME/.lightning/config
echo -e "${GREEN}Reset lightning configuration file${RESET}" say "${GREEN}Reset lightning configuration file${RESET}"
;; ;;
"n" | "N") "n" | "N")
echo "Cool, we'll leave it as is then". say "Cool, we'll leave it as is then".
;; ;;
esac esac
else else
cp resources/sample_lightning_config $HOME/.lightning/config cp resources/sample_lightning_config $HOME/.lightning/config
echo -e "${GREEN}Created default lightning config${RESET}" say "${GREEN}Created default lightning config${RESET}"
fi fi
echo "" say ""
echo -en "Would you like to use clboss to automatically open lightning channels? ${BLUE}(y/n)${RESET}: " ask_for clboss_enable "Would you like to use clboss to automatically open lightning channels? ${BLUE}(y/n)${RESET}: "
read clboss_enable
case $clboss_enable in case $clboss_enable in
"y" | "Y") "y" | "Y")
if ! check_for clboss; then if ! check_for clboss; then
@ -146,13 +150,32 @@ configure_lightning() {
sed -i "s/#plugin/plugin/" $HOME/.lightning/config sed -i "s/#plugin/plugin/" $HOME/.lightning/config
sed -i "s/#log/log/" $HOME/.lightning/config sed -i "s/#log/log/" $HOME/.lightning/config
echo "" echo ""
echo -e "${GREEN}clboss successfully configured!${RESET}" say "${GREEN}clboss successfully configured!${RESET}"
;; ;;
"n" | "N") "n" | "N")
echo "" say ""
echo "Sounds good. You might want to open some channels manually to participate in the network!". say "Sounds good. You might want to open some channels manually to participate in the network!".
;; ;;
esac esac
} }
bitcoin_is_synced() {
if [ -f "$HOME/.bitcoin/debug.log" ]; then
progress=$(tac ~/.bitcoin/debug.log | grep -m1 UpdateTip | awk '{print $10}')
case $progress in
*"=1"*)
say "Bitcoin is synced!"
return 0
;;
*)
say "Bitcoin is not synced yet"
return 1
;;
esac
else
say "Not sure where your bitcoin log is!"
return 2
fi
}
GOLD=1 GOLD=1

30
ingredients/lead

@ -195,6 +195,13 @@ forget() {
} }
remember() { remember() {
# Optionally choose to output somewhere other than Alchemy/
if [ "${2}" = "to" ]; then
ENV_LOCATION=${3}
else
ENV_LOCATION="$ALCHEMY/.env"
fi
KEY=$(say ${1} | cut -d'=' -f 1) KEY=$(say ${1} | cut -d'=' -f 1)
VALUE=$(say ${1} | cut -d'=' -f 2) VALUE=$(say ${1} | cut -d'=' -f 2)
@ -202,39 +209,46 @@ remember() {
say "Keys must consist only of capital letters and underscores" say "Keys must consist only of capital letters and underscores"
fi fi
if [[ ! $VALUE =~ ^[A-Za-z0-9/_.:-]+$ ]]; then VALID_CHARS='A-Za-z0-9/_.:=-'
if [[ ! $VALUE =~ ^[$VALID_CHARS]+$ ]]; then
say "illegal VALUE: $VALUE"
say "for key $KEY"
say "Valid characters for env values: letters, numbers, \".\",\"/\",\"_\"",\":\", \"-\" say "Valid characters for env values: letters, numbers, \".\",\"/\",\"_\"",\":\", \"-\"
fi fi
# If we're setting a valid key/value pair # If we're setting a valid key/value pair
if [[ ${1} =~ ^[A-Z_]+\=[A-Za-z0-9/._:-]*$ ]]; then if [[ ${1} =~ ^[A-Z_]+\=[$VALID_CHARS]+$ ]]; then
DOTENV_ENTRY=$(cat .env | grep ${KEY}) DOTENV_ENTRY=$(cat $ENV_LOCATION | grep "^${KEY}" )
# If something already exists and we're trying to set it to something new # If something already exists and we're trying to set it to something new
if [ -n "$DOTENV_ENTRY" ] && [ "$DOTENV_ENTRY" != "$1" ]; then if [ -n "$DOTENV_ENTRY" ] && [ "$DOTENV_ENTRY" != "$1" ]; then
say "I'm trying to remember ${BLUE}${1}${RESET}, but..." say "I'm trying to remember ${BLUE}${1}${RESET}, but..."
say "" say ""
say "${BLUE}${DOTENV_ENTRY}${RESET}" say "${BLUE}${DOTENV_ENTRY}${RESET}"
say "This has already been defined in the .env file!" say "This has already been defined in the $ENV_LOCATION file!"
say "" say ""
ask_for overwrite "would you like to overwrite it? ${BLUE}(y/n)${RESET} " ask_for overwrite "would you like to overwrite it? ${BLUE}(y/n)${RESET} "
case $overwrite in case $overwrite in
"y" | "Y") "y" | "Y")
unset ${KEY} unset ${KEY}
sed -i "/^${KEY}.*$/d" .env sed -i "/^${KEY}.*$/d" $ENV_LOCATION
echo "${1}" >> .env echo "${1}" >> $ENV_LOCATION
export ${1} export ${1}
;; ;;
esac esac
elif [ -z "$DOTENV_ENTRY" ]; then elif [ -z "$DOTENV_ENTRY" ]; then
unset ${KEY} unset ${KEY}
echo "${1}" >> .env echo "${1}" >> $ENV_LOCATION
export ${1} export ${1}
fi fi
fi fi
# Once we've made changes, we need to make sure we're up to date # Once we've made changes to the Alchemy .env,
# we need to make sure we're up to date
if [ -z "$2" ]; then
source_env source_env
fi
} }
LEAD=1 LEAD=1

23
recipes/ao.sh

@ -98,11 +98,11 @@ while [[ -z $AO ]]; do
case $ao_select in case $ao_select in
"1") "1")
echo -e "Minimalism, I like it! Proceeding with ${BLUE}ao-3${RESET} installation" echo -e "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" echo -e "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" echo "that aint no AO i ever heard of, try again"
@ -169,7 +169,22 @@ echo ""
# 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
UNIFIED_CONFIG=$HOME/.ao/env
if [ ! -f "$UNIFIED_CONFIG" ]; then
touch $UNIFIED_CONFIG
fi
remember "SQLITE_DATABASE=${HOME}/.ao/database.sqlite3" to "$UNIFIED_CONFIG"
remember "PASSLINE=${BTC_PASS}" to "$UNIFIED_CONFIG"
remember "PRIVATEKEY=${HOME}/.ao/key" to "$UNIFIED_CONFIG"
remember "CLIGHTNING_DIR=${HOME}/.lightning/bitcoin" to "$UNIFIED_CONFIG"
remember "MEMES_DIR=${HOME}/.ao/memes" to "$UNIFIED_CONFIG"
remember "RENT=0" to "$UNIFIED_CONFIG"
remember "LIGHTNINGDIR=0" to "$UNIFIED_CONFIG"
say "!!!!!!! WARNING !!!!!! I'm exaggerating but this is not going to \
configure AO properly. It's time that we build out the unified config"
read
case $AO in case $AO in
"3") "3")
if [ ! -d ~/ao-3 ]; then if [ ! -d ~/ao-3 ]; then
@ -181,7 +196,7 @@ case $AO in
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
sed -i "s#PASSLINE#${PASSLINE}#" $CONFIG_FILE sed -i "s#PASSLINE#${BTC_PASS}#" $CONFIG_FILE
sed -i "s#PRIVATEKEY#${HOME}/.ao/key#" $CONFIG_FILE sed -i "s#PRIVATEKEY#${HOME}/.ao/key#" $CONFIG_FILE
sed -i "s#CLIGHTNING_DIR#${HOME}/.lightning/bitcoin#" $CONFIG_FILE sed -i "s#CLIGHTNING_DIR#${HOME}/.lightning/bitcoin#" $CONFIG_FILE
sed -i "s#MEMES_DIR#${HOME}/.ao/memes#" $CONFIG_FILE sed -i "s#MEMES_DIR#${HOME}/.ao/memes#" $CONFIG_FILE
@ -206,7 +221,7 @@ case $AO in
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
sed -i "s#PASSLINE#${PASSLINE}#" $CONFIG_FILE sed -i "s#PASSLINE#${BTC_PASS}#" $CONFIG_FILE
sed -i "s#PRIVATEKEY#${HOME}/.ao/key#" $CONFIG_FILE sed -i "s#PRIVATEKEY#${HOME}/.ao/key#" $CONFIG_FILE
sed -i "s#CLIGHTNING_DIR#${HOME}/.lightning/bitcoin#" $CONFIG_FILE sed -i "s#CLIGHTNING_DIR#${HOME}/.lightning/bitcoin#" $CONFIG_FILE
sed -i "s#MEMES_DIR#${HOME}/.ao/memes#" $CONFIG_FILE sed -i "s#MEMES_DIR#${HOME}/.ao/memes#" $CONFIG_FILE

2
resources/sample_bitcoin.conf

@ -1,8 +1,8 @@
proxy=127.0.0.1:9050 proxy=127.0.0.1:9050
txindex=1 txindex=1
#prune=550
listen=1 listen=1
bind=127.0.0.1 bind=127.0.0.1
disablewallet=1 disablewallet=1
zmqpubrawblock=tcp://127.0.0.1:28332 zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333 zmqpubrawtx=tcp://127.0.0.1:28333
BTC_LOGIN

Loading…
Cancel
Save