This commit is contained in:
rootzoll 2022-01-07 22:33:35 +01:00
commit 1e158e76e4
3 changed files with 49 additions and 29 deletions

View File

@ -268,7 +268,7 @@ case $CHOICE in
/home/admin/config.scripts/bonus.specter.sh menu
;;
JM)
sudo /home/admin/config.scripts/bonus.joinmarket.sh menu
/home/admin/config.scripts/bonus.joinmarket.sh menu
;;
FARADAY)
sudo /home/admin/config.scripts/bonus.faraday.sh menu

View File

@ -5,7 +5,8 @@
# https://github.com/openoms/bitcoin-tutorials/tree/master/joinmarket
# https://github.com/openoms/joininbox
JBVERSION="v0.6.5" # with JoinMarket v0.9.4
# JBVERSION="v0.6.5" # with JoinMarket v0.9.4
JBVERSION="b0efe45" # dev
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
@ -15,18 +16,6 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
exit 1
fi
PGPsigner="openoms"
PGPpubkeyLink="https://github.com/openoms.gpg"
PGPpubkeyFingerprint="13C688DB5B9C745DE4D2E4545BFB77609B081B65"
# check if sudo
if [ "$EUID" -ne 0 ]
then echo "Please run as root (with sudo)"
exit
fi
source /mnt/hdd/raspiblitz.conf
# show info menu
if [ "$1" = "menu" ]; then
whiptail --title " JoinMarket info " --msgbox "
@ -38,6 +27,18 @@ https://github.com/openoms/bitcoin-tutorials/blob/master/joinmarket/README.md
exit 0
fi
# check if sudo
if [ "$EUID" -ne 0 ]
then echo "Please run as root (with sudo)"
exit
fi
PGPsigner="openoms"
PGPpubkeyLink="https://github.com/openoms.gpg"
PGPpubkeyFingerprint="13C688DB5B9C745DE4D2E4545BFB77609B081B65"
source /mnt/hdd/raspiblitz.conf
# switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "# INSTALL JOINMARKET"
@ -123,7 +124,6 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "AllowOutboundLocalhost 1" | sudo tee -a /etc/tor/torsocks.conf
sudo systemctl reload tor@default
fi
# joinin.conf settings
sudo -u joinmarket touch /home/joinmarket/joinin.conf
# add default Tor value to joinin.conf if needed
@ -134,6 +134,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
if grep -Eq "^runBehindTor=on" /mnt/hdd/raspiblitz.conf; then
sudo -u joinmarket sed -i "s/^runBehindTor=.*/runBehindTor=on/g" /home/joinmarket/joinin.conf
fi
echo
echo "##########"
echo "# Extras #"
@ -166,10 +167,11 @@ if [ -z \"\$TMUX\" ]; then
fi
" | sudo -u joinmarket tee -a /home/joinmarket/.bashrc
echo "######################"
echo "# Install JoinMarket #"
echo "######################"
sudo -u joinmarket /home/joinmarket/install.joinmarket.sh install
echo "##############################################"
echo "# Install JoinMarket and configure JoininBox #"
echo "##############################################"
echo
sudo -u joinmarket /home/joinmarket/start.joininbox.sh
else
echo "JoinMarket is already installed"

View File

@ -49,7 +49,7 @@ function install() {
fi
}
if [ $1 = on ];then
if [ "$1" = on ];then
install
@ -74,6 +74,15 @@ if [ $1 = on ];then
--lightning-dir /home/bitcoin/.lightning/${CLNETWORK} \
file:///home/bitcoin/${netprefix}lightningd.sqlite3.backup
if [ $(crontab -u admin -l | grep -c "backup-compact $CHAIN") -eq 0 ]; then
echo "Add weekly backup-compact as a cronjob"
cronjob="@weekly /home/admin/cl-plugin.backup.sh backup-compact $CHAIN"
(crontab -u admin -l; echo "$cronjob" ) | crontab -u admin -
fi
echo "# The crontab for admin now is:"
crontab -u admin -l
echo
source <(/home/admin/_cache.sh get state)
if [ "${state}" == "ready" ]; then
sudo systemctl start ${netprefix}lightningd
@ -81,7 +90,7 @@ if [ $1 = on ];then
fi
elif [ $1 = off ];then
elif [ "$1" = off ];then
echo "# Removing the backup plugin"
sudo rm -f /home/bitcoin/${netprefix}cl-plugins-enabled/backup.py
echo "# Backup the existing old backup on the SDcard"
@ -92,7 +101,7 @@ elif [ $1 = off ];then
sudo rm -f /home/bitcoin/.lightning/${CLNETWORK}/backup.lock
elif [ $1 = restore ];then
elif [ "$1" = restore ];then
install
@ -128,15 +137,24 @@ elif [ $1 = restore ];then
fi
elif [ $1 = backup-compact ];then
if sudo ls /home/bitcoin/.lightning/${CLNETWORK}/lightningd.sqlite3;then
# https://github.com/lightningd/plugins/tree/master/backup#performing-backup-compaction
echo "# Running $lightning-cli backup-compact ..."
$lightningcli_alias backup-compact
elif [ "$1" = backup-compact ];then
# https://github.com/lightningd/plugins/tree/master/backup#performing-backup-compaction
dbPath="/home/bitcoin/.lightning/${CLNETWORK}/lightningd.sqlite3"
backupPath="/home/bitcoin/${netprefix}lightningd.sqlite3.backup"
if sudo ls "${dbPath}" >/dev/null; then
dbSize=$(sudo du -m "${dbPath}" | awk '{print $1}')
echo "$dbSize MB $dbPath"
backupSize=$(sudo du -m "${backupPath}" | awk '{print $1}')
echo "$backupSize MB $backupPath"
if [ "$backupSize" -gt $((dbSize+200)) ] ; then
echo "# The backup is 200MB+ larger than the db, running '${netprefix}lightning-cli backup-compact' ..."
$lightningcli_alias backup-compact
else
echo "The backup is not significantly larger than the db, there is no need to compact."
fi
else
echo "# No /home/bitcoin/.lightning/${CLNETWORK}/lightningd.sqlite3 is present"
echo "# No ${dbPath} is present"
echo "# Run 'config.scripts/cl-plugin.backup.sh on ${CLNETWORK}' first"
fi