#2891 Prepare JAM install scripts for WebUI (#3545)

* webapi branches

* add thunderhub off

* webui JAM & joinmarket

* fix joinmarket menu

* comment output

* add debug

* remove user delete JAM

* pipe outputs

* add to fatpack

* pipe more debug

* dont remove app

* force https

* #3544 manual merge

* separate install and on option for joinmarket (#3544)

* fix call

* adapt api/webui branches

Co-authored-by: openoms <43343391+openoms@users.noreply.github.com>
This commit is contained in:
/rootzoll 2022-12-19 12:28:56 +01:00 committed by GitHub
parent 19cb9fdbc5
commit 334792abda
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 216 additions and 149 deletions

View file

@ -804,11 +804,13 @@ if ${fatpack}; then
/home/admin/config.scripts/bonus.btc-rpc-explorer.sh install || exit 1
echo "* Adding Code&Compile for WEBUI-APP: LNBITS"
/home/admin/config.scripts/bonus.lnbits.sh install || exit 1
echo "* Adding Code&Compile for WEBUI-APP: JAM"
/home/admin/config.scripts/bonus.jam.sh install || exit 1
echo "* Adding Raspiblitz API ..."
sudo /home/admin/config.scripts/blitz.web.api.sh on "${defaultAPIuser}" "${defaultAPIrepo}" "${branch}" || exit 1
sudo /home/admin/config.scripts/blitz.web.api.sh on "${defaultAPIuser}" "${defaultAPIrepo}" "blitz-${branch}" || exit 1
echo "* Adding Raspiblitz WebUI ..."
sudo /home/admin/config.scripts/blitz.web.ui.sh on "${defaultWEBUIuser}" "${defaultWEBUIrepo}" "${branch}" || exit 1
sudo /home/admin/config.scripts/blitz.web.ui.sh on "${defaultWEBUIuser}" "${defaultWEBUIrepo}" "release/${branch}" || exit 1
# set build code as new default
sudo rm -r /home/admin/assets/nginx/www_public

View file

@ -7,7 +7,7 @@
# NORMALLY user/repo/version will be defined by calling script - see build_sdcard.sh
# the following is just a fallback to try during development if script given branch does not exist
FALLACK_BRANCH="main"
FALLACK_BRANCH="refactor_system"
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ]; then

View file

@ -17,7 +17,9 @@ PGPpubkeyFingerprint="89C4A25E69A5DE7F"
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "config script to switch Jam on or off"
echo "bonus.jam.sh [on|off|menu|update|update commit|precheck]"
echo "bonus.jam.sh [install|uninstall]"
echo "bonus.jam.sh [on|off|status|menu]"
echo "bonus.jam.sh [update|update commit|precheck]"
exit 1
fi
@ -25,12 +27,34 @@ fi
source $RASPIBLITZ_INFO
source $RASPIBLITZ_CONF
# check if already installed & active
isInstalled=$(compgen -u | grep -c ${USERNAME})
isActive=$(sudo ls /etc/systemd/system/joinmarket-api.service 2>/dev/null | grep -c 'joinmarket-api.service')
localip=$(hostname -I | awk '{print $1}')
if [ "$1" = "status" ]; then
toraddress=$(sudo cat /mnt/hdd/tor/${USERNAME}/hostname 2>/dev/null)
httpPort="3010"
httpsPort="3011"
echo "version='${WEBUI_VERSION}'"
echo "installed='${isActive}'"
echo "localIP='${localip}'"
echo "httpPort='7500'"
echo "httpsPort='7501'"
echo "httpsForced='1'"
echo "httpsSelfsigned='1'"
echo "authMethod='password_b'"
echo "toraddress='${toraddress}'"
exit 0
fi
# show info menu
if [ "$1" = "menu" ]; then
isInstalled=$(sudo ls $HOME_DIR 2>/dev/null | grep -c "$APP_DIR")
if [ ${isInstalled} -eq 1 ]; then
if [ ${isActive} -eq 1 ]; then
# get network info
localip=$(hostname -I | awk '{print $1}')
toraddress=$(sudo cat /mnt/hdd/tor/jam/hostname 2>/dev/null)
fingerprint=$(openssl x509 -in /mnt/hdd/app-data/nginx/tls.cert -fingerprint -noout | cut -d"=" -f2)
@ -53,94 +77,134 @@ ${fingerprint}\n
Activate Tor to access the web interface from outside your local network.
" 15 57
fi
echo "please wait ..."
echo "# please wait ..."
else
echo "*** JAM NOT INSTALLED ***"
echo "# *** JAM NOT INSTALLED ***"
fi
exit 0
fi
# install (code & compile)
if [ "$1" = "install" ]; then
if [ "${isInstalled}" != "0" ]; then
echo "result='already installed'"
exit 0
fi
# make sure joinmarket is installed
sudo /home/admin/config.scripts/bonus.joinmarket.sh install || exit 1
echo "# *** INSTALL JAM (user & code) ***"
echo "# Creating the ${USERNAME} user"
sudo adduser --disabled-password --gecos "" ${USERNAME}
# install nodeJS
/home/admin/config.scripts/bonus.nodejs.sh on
# install
cd $HOME_DIR || exit 1
sudo -u $USERNAME git clone https://github.com/$REPO
cd jam || exit 1
sudo -u $USERNAME git reset --hard v${WEBUI_VERSION}
sudo -u $USERNAME /home/admin/config.scripts/blitz.git-verify.sh "${PGPsigner}" "${PGPpubkeyLink}" "${PGPpubkeyFingerprint}" "v${WEBUI_VERSION}" || exit 1
cd $HOME_DIR || exit 1
sudo -u $USERNAME mv jam $APP_DIR
cd $APP_DIR || exit 1
sudo -u $USERNAME rm -rf docker
if ! sudo -u $USERNAME npm install; then
echo "# FAIL - npm install did not run correctly, aborting"
echo "result='fail - npm install did not run correctly'"
exit 1
fi
sudo -u $USERNAME npm run build
echo "# OK JAM user/codebase installed"
exit 0
fi
# remove from system
if [ "$1" = "uninstall" ]; then
# check if still active
if [ "${isActive}" != "0" ]; then
echo "result='still in use'"
exit 1
fi
echo "# *** UNINSTALL JAM ***"
# always delete user and home directory
sudo userdel -rf $USERNAME
exit 0
fi
# switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
isInstalled=$(sudo ls $HOME_DIR 2>/dev/null | grep -c "$APP_DIR")
# check if already ON
echo "# isActive(${isActive})" 1>&2
if [ ${isActive} -gt 1 ]; then
echo "# JAM already installed."
echo "result='OK'"
exit 0
fi
# check if user/codebase is already installed
echo "# isInstalled(${isInstalled})" 1>&2
if [ ${isInstalled} -eq 0 ]; then
# check if joinmarket is installed
if [ -f "/home/joinmarket/.joinmarket/joinamrket.cfg" ]; then
echo "# JoinMarket is already installed and configured."
else
sudo /home/admin/config.scripts/bonus.joinmarket.sh on
fi
sudo /home/admin/config.scripts/bonus.jam.sh install 1>&2 || exit 1
fi
echo "*** INSTALL JAM ***"
# make sure joinmarket base is also activated
sudo /home/admin/config.scripts/bonus.joinmarket.sh on 1>&2 || exit 1
echo "# Creating the ${USERNAME} user"
echo
sudo adduser --disabled-password --gecos "" ${USERNAME}
echo "# *** ACTIVATING JAM ***"
# install nodeJS
/home/admin/config.scripts/bonus.nodejs.sh on
##################
# NGINX
##################
# remove legacy nginx symlinks and configs
sudo rm -f /etc/nginx/sites-enabled/joinmarket_webui_* 1>&2
sudo rm -f /etc/nginx/sites-available/joinmarket_webui_* 1>&2
# setup nginx symlinks
sudo cp -f /home/admin/assets/nginx/sites-available/jam_ssl.conf /etc/nginx/sites-available/jam_ssl.conf 1>&2
sudo cp -f /home/admin/assets/nginx/sites-available/jam_tor.conf /etc/nginx/sites-available/jam_tor.conf 1>&2
sudo cp -f /home/admin/assets/nginx/sites-available/jam_tor_ssl.conf /etc/nginx/sites-available/jam_tor_ssl.conf 1>&2
sudo ln -sf /etc/nginx/sites-available/jam_ssl.conf /etc/nginx/sites-enabled/ 1>&2
sudo ln -sf /etc/nginx/sites-available/jam_tor.conf /etc/nginx/sites-enabled/ 1>&2
sudo ln -sf /etc/nginx/sites-available/jam_tor_ssl.conf /etc/nginx/sites-enabled/ 1>&2
sudo nginx -t 1>&2
sudo systemctl reload nginx 1>&2
# install
cd $HOME_DIR || exit 1
# open the firewall
echo "# *** Updating Firewall ***" 1>&2
sudo ufw allow from any to any port 7500 comment 'allow Jam HTTP' 1>&2
sudo ufw allow from any to any port 7501 comment 'allow Jam HTTPS' 1>&2
sudo -u $USERNAME git clone https://github.com/$REPO
#########################
## JOINMARKET-API SERVICE
#########################
# SSL
if [ -d /home/joinmarket/.joinmarket/ssl ]; then
sudo -u joinmarket rm -rf /home/joinmarket/.joinmarket/ssl 1>&2
fi
subj="/C=US/ST=Utah/L=Lehi/O=Your Company, Inc./OU=IT/CN=example.com"
sudo -u joinmarket mkdir -p /home/joinmarket/.joinmarket/ssl/ 1>&2 \
&& pushd "$_" 1>&2 \
&& sudo -u joinmarket openssl req -newkey rsa:4096 -x509 -sha256 -days 3650 -nodes -out cert.pem -keyout key.pem -subj "$subj" 1>&2 \
&& popd 1>&2 || exit 1
cd jam || exit 1
sudo -u $USERNAME git reset --hard v${WEBUI_VERSION}
sudo -u $USERNAME /home/admin/config.scripts/blitz.git-verify.sh \
"${PGPsigner}" "${PGPpubkeyLink}" "${PGPpubkeyFingerprint}" "v${WEBUI_VERSION}" || exit 1
cd $HOME_DIR || exit 1
sudo -u $USERNAME mv jam $APP_DIR
cd $APP_DIR || exit 1
sudo -u $USERNAME rm -rf docker
if ! sudo -u $USERNAME npm install; then
echo "FAIL - npm install did not run correctly, aborting"
exit 1
fi
sudo -u $USERNAME npm run build
##################
# NGINX
##################
# remove legacy nginx symlinks and configs
sudo rm -f /etc/nginx/sites-enabled/joinmarket_webui_*
sudo rm -f /etc/nginx/sites-available/joinmarket_webui_*
# setup nginx symlinks
sudo cp -f /home/admin/assets/nginx/sites-available/jam_ssl.conf /etc/nginx/sites-available/jam_ssl.conf
sudo cp -f /home/admin/assets/nginx/sites-available/jam_tor.conf /etc/nginx/sites-available/jam_tor.conf
sudo cp -f /home/admin/assets/nginx/sites-available/jam_tor_ssl.conf /etc/nginx/sites-available/jam_tor_ssl.conf
sudo ln -sf /etc/nginx/sites-available/jam_ssl.conf /etc/nginx/sites-enabled/
sudo ln -sf /etc/nginx/sites-available/jam_tor.conf /etc/nginx/sites-enabled/
sudo ln -sf /etc/nginx/sites-available/jam_tor_ssl.conf /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
# open the firewall
echo "*** Updating Firewall ***"
sudo ufw allow from any to any port 7500 comment 'allow Jam HTTP'
sudo ufw allow from any to any port 7501 comment 'allow Jam HTTPS'
echo ""
#########################
## JOINMARKET-API SERVICE
#########################
# SSL
if [ -d /home/joinmarket/.joinmarket/ssl ]; then
sudo -u joinmarket rm -rf /home/joinmarket/.joinmarket/ssl
fi
subj="/C=US/ST=Utah/L=Lehi/O=Your Company, Inc./OU=IT/CN=example.com"
sudo -u joinmarket mkdir -p /home/joinmarket/.joinmarket/ssl/ \
&& pushd "$_" \
&& sudo -u joinmarket openssl req -newkey rsa:4096 -x509 -sha256 -days 3650 -nodes -out cert.pem -keyout key.pem -subj "$subj" \
&& popd || exit 1
# SYSTEMD SERVICE
echo "# Install JoinMarket API systemd"
echo "\
# SYSTEMD SERVICE
echo "# Install JoinMarket API systemd" 1>&2
echo "\
# Systemd unit for JoinMarket API
[Unit]
@ -165,43 +229,36 @@ PrivateDevices=true
[Install]
WantedBy=multi-user.target
" | sudo tee /etc/systemd/system/joinmarket-api.service
sudo systemctl enable joinmarket-api
" | sudo tee /etc/systemd/system/joinmarket-api.service 1>&2
sudo systemctl enable joinmarket-api 1>&2
# remove legacy name
/home/admin/config.scripts/blitz.conf.sh delete joinmarketWebUI $RASPIBLITZ_CONF
# setting value in raspiblitz config
/home/admin/config.scripts/blitz.conf.sh set jam on $RASPIBLITZ_CONF
# remove legacy name
/home/admin/config.scripts/blitz.conf.sh delete joinmarketWebUI $RASPIBLITZ_CONF 1>&2
# setting value in raspiblitz config
/home/admin/config.scripts/blitz.conf.sh set jam on $RASPIBLITZ_CONF 1>&2
# Hidden Service for jam if Tor is active
if [ "${runBehindTor}" = "on" ]; then
# Hidden Service for jam if Tor is active
if [ "${runBehindTor}" = "on" ]; then
# remove legacy
/home/admin/config.scripts/tor.onion-service.sh off joinmarket-webui
/home/admin/config.scripts/tor.onion-service.sh off joinmarket-webui 1>&2
# add jam
/home/admin/config.scripts/tor.onion-service.sh jam 80 7502 443 7503
fi
source $RASPIBLITZ_INFO
if [ "${state}" == "ready" ]; then
/home/admin/config.scripts/tor.onion-service.sh jam 80 7502 443 7503 1>&2
fi
source $RASPIBLITZ_INFO
if [ "${state}" == "ready" ]; then
echo "# OK - the joinmarket-api.service is enabled, system is ready so starting service"
sudo systemctl start joinmarket-api
else
echo "# OK - the joinmarket-api.service is enabled, to start manually use: 'sudo systemctl start joinmarket-api'"
fi
else
echo "*** JAM IS ALREADY INSTALLED ***"
echo "# OK - the joinmarket-api.service is enabled, to start manually use: 'sudo systemctl start joinmarket-api'"
fi
echo
echo "# Start the joinmarket ob-watcher.service"
sudo -u joinmarket /home/joinmarket/menu.orderbook.sh startOrderBookService
echo
echo "# For the connection details run:"
echo "/home/admin/config.scripts/bonus.jam.sh menu"
echo
sudo -u joinmarket /home/joinmarket/menu.orderbook.sh startOrderBookService 1>&2
echo "# For the connection details run: /home/admin/config.scripts/bonus.jam.sh menu"
echo "result='OK'"
exit 0
fi
# precheck
if [ "$1" = "precheck" ]; then
if [ $(/usr/local/bin/bitcoin-cli -conf=/mnt/hdd/bitcoin/bitcoin.conf listwallets | grep -c wallet.dat) -eq 0 ];then
@ -285,47 +342,39 @@ fi
# switch off
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "*** UNINSTALL JAM ***"
if [ -d /home/$USERNAME ]; then
sudo userdel -rf $USERNAME 2>/dev/null
echo "Removed the $USERNAME user"
else
echo "There is no /home/$USERNAME present"
fi
echo "# *** DEACTIVATE JAM ***"
echo "Cleaning up Jam install ..."
echo "# Cleaning up Jam install ..."
# remove systemd service
sudo systemctl stop joinmarket-api 2>/dev/null
sudo systemctl disable joinmarket-api 2>/dev/null
sudo rm -f /etc/systemd/system/joinmarket-api.service
# close ports on firewall
sudo ufw delete allow from any to any port 7500
sudo ufw delete allow from any to any port 7501
sudo ufw delete allow from any to any port 7500 1>&2
sudo ufw delete allow from any to any port 7501 1>&2
# remove nginx symlinks and configs
sudo rm -f /etc/nginx/sites-enabled/jam_*
sudo rm -f /etc/nginx/sites-available/jam_*
sudo nginx -t
sudo systemctl reload nginx
sudo rm -f /etc/nginx/sites-enabled/jam_* 1>&2
sudo rm -f /etc/nginx/sites-available/jam_* 1>&2
sudo rm /var/log/nginx/error_jam.log 1>/dev/null 2/dev/null
sudo rm /var/log/nginx/access_jam.log 1>/dev/null 2/dev/null
sudo nginx -t 1>&2
sudo systemctl reload nginx 1>&2
# Hidden Service if Tor is active
if [ "${runBehindTor}" = "on" ]; then
/home/admin/config.scripts/tor.onion-service.sh off jam
/home/admin/config.scripts/tor.onion-service.sh off jam 1>&2
fi
# remove the app
sudo rm -rf $HOME_DIR/$APP_DIR 2>/dev/null
# remove SSL
sudo rm -rf $HOME_DIR/.joinmarket/ssl
sudo rm -rf $HOME_DIR/.joinmarket/ssl 1>&2
# setting value in raspi blitz config
/home/admin/config.scripts/blitz.conf.sh delete jam $RASPIBLITZ_CONF
echo "OK, Jam is removed"
echo "# OK, Jam is removed"
exit 0
fi

View file

@ -10,10 +10,11 @@ JBTAG="v0.7.4" # installs JoinMarket v0.9.8
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "JoinMarket install script to switch JoinMarket on or off"
echo "sudo /home/admin/config.scrips/bonus.joinmarket.sh on|off"
echo "Installs JoininBox $JBTAG with JoinMarket v0.9.5"
exit 1
echo "JoinMarket install script to install and switch JoinMarket on or off"
echo "sudo /home/admin/config.scrips/bonus.joinmarket.sh install"
echo "sudo /home/admin/config.scrips/bonus.joinmarket.sh on|off"
echo "Installs JoininBox $JBTAG with JoinMarket v0.9.5"
exit 1
fi
# show info menu
@ -46,7 +47,7 @@ PGPpubkeyFingerprint="13C688DB5B9C745DE4D2E4545BFB77609B081B65"
source /mnt/hdd/raspiblitz.conf
# switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
if [ "$1" = "install" ]; then
echo "# INSTALL JOINMARKET"
# check if running Tor
@ -77,8 +78,9 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
fi
fi
if [ ! -f "/home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate" ] ; then
if [ -f "/home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate" ]; then
echo "JoinMarket is already installed"
else
echo "# cleaning before install"
sudo userdel -rf joinmarket 2>/dev/null
@ -193,27 +195,38 @@ fi
echo "# Install JoinMarket and configure JoininBox #"
echo "##############################################"
echo
sudo -u joinmarket /home/joinmarket/start.joininbox.sh
if sudo -u joinmarket /home/joinmarket/install.joinmarket.sh -i install; then
echo "# Installed JoinMarket"
echo "# Run: 'sudo /home/admin/config.scrips/bonus.joinmarket.sh on' to configure and switch on"
else
echo " Failed to install JoinMarket"
exit 1
fi
fi
exit 0
fi
# switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
if [ -f /home/joinmarket/start.joininbox.sh ]; then
echo "# Ok, Joininbox is present"
else
echo "JoinMarket is already installed"
echo
sudo /home/admin/config.scrips/bonus.joinmarket.sh install
fi
if [ -f "/home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate" ] ; then
# setting value in raspi blitz config
/home/admin/config.scripts/blitz.conf.sh set joinmarket "on"
# starting info
echo
# configure joinmarket (includes a check if it is installed)
if sudo -u joinmarket /home/joinmarket/start.joininbox.sh; then
echo "# Start to use by logging in to the 'joinmarket' user with:"
echo "# 'sudo su joinmarket' or use the shortcut 'jm'"
echo
else
echo " Failed to install JoinMarket"
echo "# There was an error running 'bonus.joinmarket.sh on', see above"
exit 1
fi
# set the raspiblitz.conf
/home/admin/config.scripts/blitz.conf.sh set joinmarket "on"
exit 0
fi

View file

@ -359,6 +359,9 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# disable balance sharing server side
/home/admin/config.scripts/blitz.conf.sh set DISABLE_BALANCE_PUSHES true /mnt/hdd/app-data/thunderhub/.env.local noquotes
# setting value in raspiblitz config
/home/admin/config.scripts/blitz.conf.sh set thunderhub "off"
# needed for API/WebUI as signal that install ran thru
echo "result='OK'"
exit 0

View file

@ -39,23 +39,23 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# specify wallet.dat for mainnet to avoid error on testnet
sudo sed -i "s/^wallet=wallet.dat/main.wallet=wallet.dat/g" /mnt/hdd/${network}/${network}.conf
if ! grep -Eq "^${chain}.wallet=wallet.dat" /mnt/hdd/${network}/${network}.conf; then
echo "Enable the multiwallet feature in ${network} core ${chain}net and specify wallet.dat"
echo "# Enable the multiwallet feature in ${network} core ${chain}net and specify wallet.dat"
echo "${chain}.wallet=wallet.dat" | sudo tee -a /mnt/hdd/${network}/${network}.conf >/dev/null
restartService=1
else
echo "Multiwallet is active and wallet.dat is used."
echo "# Multiwallet is active and wallet.dat is used."
restartService=0
fi
if [ ${disablewallet} == 1 ]; then
sudo sed -i "s/^disablewallet=.*/disablewallet=0/g" /mnt/hdd/${network}/${network}.conf
echo "Switching the ${network} core wallet on"
echo "# Switching the ${network} core wallet on"
restartService=1
else
echo "The ${network} core wallet is already on"
echo "# The ${network} core wallet is already on"
fi
source <(/home/admin/_cache.sh get state)
if [ ${restartService} == 1 ] && [ ${state} != "recovering" ]; then
echo "Restarting ${network}d"
echo "# Restarting ${network}d"
sudo systemctl restart ${network}d
fi
exit 0