2022-01-15 11:00:36 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-11-01 15:47:54 +00:00
|
|
|
# https://github.com/joinmarket-webui/jam
|
2022-01-15 11:00:36 +01:00
|
|
|
|
v1.9.0rc3 Merge (#3742)
* cln: use default normal feerate to withdraw all
* Bugfix: bad subsititution (#3668)
Fix for error:
/home/admin/config.scripts/bonus.go.sh: line 31: ${goOSversion{}: bad substitution
* whiptail one line
* fix syntax
* lnproxy: fix api access through nginx (#3671)
* lnproxy: fix api access through nginx
* fix tor config and fit the menu
* add to the menu and provision
* merge #3682
* cln update to v23.02, backup-plugin update, add poetry (#3684)
* cln backup-plugin update, add poetry
* fix mkdir error, remove commented code, fmt #3677
* poetry and path fixes
* add terminal feedback, format #3676
* detect the full name of the plugin
* install pyln-client tqdm with pip
* git-verify: add --keyid-format LONG
to recognise if the signing key is not the main key
* cln update to v23.02
* cln-grpc: add protobuf-compiler dep
* rtl update to v0.13.6 and formatting
* C-lightningREST update to v0.10.1
* CLN FAQ update (#3666)
* improve the detection of existing cln aliases
* add the emergencyrecover instructions to CLN FAQ
* update help entries
* Update Tallycoin to version 1.8.0 (#3693)
* add tallycoin update info to CHANGES
* Fix typo in README.md (#3699)
excepted -> accepted
* #3694 add LCD info
* #3664 att timeout 30s to ln monitor calls (#3665)
* fix setting LND_REST_ENDPOINT (#3689)
* btcpay update v1.8.2, postgres database fix (#3697)
* btcpay update v1.8.0, postgres database fix
* btcpayserver update to v1.8.2
* update lnbits to 0.10.2 and use poetry instead of venv (#3703)
* fix apt update Key error for influx repo (#3711)
Co-authored-by: Patrick Scheich <patrick.scheich@syscovery.de>
* fix missing timeout value for nc cmnd (#3712)
Co-authored-by: Patrick Scheich <patrick.scheich@syscovery.de>
* #3706 Update CLN v23.02.2 (#3716)
* used patched/rolledback 23.02.2 release
* check rusty sig
* fix typo
* fix default lightning setting
* #3683 Update LIT to 0.8.6 (#3717)
* update LIT to 0.8.6
* activate lnd rpcmiddleware
* CHANGES.md
* #3667 change all up/download from sftp tp scp (#3718)
* #3722 add no hostkeys available detection (#3723)
* #1186 FinTS/HBCI interface (#3704)
* #1186 FinTS install script first draft
* only start app when blitz is ready
* improve menu
* improve dit lnbits config
* preserve edit
* improve edit
* improve edit
* fix insertion
* dont use fingerprint
* now use main repo
* add port
* show local ip
* fix typo
* show port SSL
* Update bonus.lndg.sh (#3725)
* Update bonus.lndg.sh
Changes version to v1.6.0.
Fixes update menu bug.
Cleans up code a bit (removes tabs and changes to spaces to match raspiblitz formats).
* Update bonus.lndg.sh
Cleaned up code, added requirements.txt install to updates (needed for this update, may be needed in future).
* #3725 update lndg version in CHANGES
* #3692 update lnd to v0.16.0-beta (#3732)
* update SD CARD base image info
* Clenaup CHANGES info
* RTL install fix (#3739)
* c-lightning-REST update to 0.10.2, fmt
* rtl: npm insatll with --legacy-peer-deps
* purge c-lightning-REST as well with RTL
* jam update to v0.1.5 (#3736)
* 3733 CLN GRPC > JRPC (#3741)
* change exit code
* change to cln_jrpc
* deactivate the cln_grpc settings
* set v1.9.0rc3 version
---------
Co-authored-by: openoms <oms@tuta.io>
Co-authored-by: Metallicc <72348+metallicc@users.noreply.github.com>
Co-authored-by: openoms <43343391+openoms@users.noreply.github.com>
Co-authored-by: DJ Booth <djbooth007@gmail.com>
Co-authored-by: Yuck Fou <115867254+YuckFouBTC@users.noreply.github.com>
Co-authored-by: dni ⚡ <office@dnilabs.com>
Co-authored-by: PatrickScheich <50054697+PatrickScheich@users.noreply.github.com>
Co-authored-by: Patrick Scheich <patrick.scheich@syscovery.de>
Co-authored-by: allyourbankarebelongtous <100060902+allyourbankarebelongtous@users.noreply.github.com>
2023-04-08 23:10:01 +02:00
|
|
|
WEBUI_VERSION=0.1.5
|
2022-11-01 15:47:54 +00:00
|
|
|
REPO=joinmarket-webui/jam
|
|
|
|
USERNAME=jam
|
2022-01-15 11:00:36 +01:00
|
|
|
HOME_DIR=/home/$USERNAME
|
|
|
|
APP_DIR=webui
|
|
|
|
RASPIBLITZ_INFO=/home/admin/raspiblitz.info
|
|
|
|
RASPIBLITZ_CONF=/mnt/hdd/raspiblitz.conf
|
2022-11-01 15:47:54 +00:00
|
|
|
|
|
|
|
PGPsigner="dergigi"
|
|
|
|
PGPpubkeyLink="https://github.com/${PGPsigner}.gpg"
|
|
|
|
PGPpubkeyFingerprint="89C4A25E69A5DE7F"
|
2022-01-15 11:00:36 +01:00
|
|
|
|
|
|
|
# command info
|
|
|
|
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
2022-11-01 15:47:54 +00:00
|
|
|
echo "config script to switch Jam on or off"
|
2022-12-19 12:28:56 +01:00
|
|
|
echo "bonus.jam.sh [install|uninstall]"
|
|
|
|
echo "bonus.jam.sh [on|off|status|menu]"
|
|
|
|
echo "bonus.jam.sh [update|update commit|precheck]"
|
2022-01-15 11:00:36 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# check and load raspiblitz config to know which network is running
|
|
|
|
source $RASPIBLITZ_INFO
|
2022-12-20 01:37:36 +01:00
|
|
|
source $RASPIBLITZ_CONF 2>/dev/null
|
2022-01-15 11:00:36 +01:00
|
|
|
|
2022-12-19 12:28:56 +01:00
|
|
|
# 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
|
|
|
|
|
2022-01-15 11:00:36 +01:00
|
|
|
# show info menu
|
|
|
|
if [ "$1" = "menu" ]; then
|
2022-12-19 12:28:56 +01:00
|
|
|
|
|
|
|
if [ ${isActive} -eq 1 ]; then
|
2022-01-15 11:00:36 +01:00
|
|
|
# get network info
|
2022-11-01 15:47:54 +00:00
|
|
|
toraddress=$(sudo cat /mnt/hdd/tor/jam/hostname 2>/dev/null)
|
2022-01-15 11:00:36 +01:00
|
|
|
fingerprint=$(openssl x509 -in /mnt/hdd/app-data/nginx/tls.cert -fingerprint -noout | cut -d"=" -f2)
|
|
|
|
|
|
|
|
if [ "${runBehindTor}" = "on" ] && [ ${#toraddress} -gt 0 ]; then
|
2022-03-02 10:21:00 +00:00
|
|
|
# Info with Tor
|
2022-02-13 12:23:34 +00:00
|
|
|
sudo /home/admin/config.scripts/blitz.display.sh qr "${toraddress}"
|
2022-11-01 15:47:54 +00:00
|
|
|
whiptail --title " Jam (JoinMarket Web UI) " --msgbox "Open in your local web browser:
|
2022-02-18 22:01:38 +00:00
|
|
|
https://${localip}:7501\n
|
|
|
|
with Fingerprint:
|
2022-01-15 11:00:36 +01:00
|
|
|
${fingerprint}\n
|
2022-03-02 10:21:00 +00:00
|
|
|
Hidden Service address for Tor Browser (see LCD for QR):\n${toraddress}
|
2022-01-15 11:00:36 +01:00
|
|
|
" 16 67
|
2022-02-13 12:23:34 +00:00
|
|
|
sudo /home/admin/config.scripts/blitz.display.sh hide
|
2022-01-15 11:00:36 +01:00
|
|
|
else
|
2022-03-02 10:21:00 +00:00
|
|
|
# Info without Tor
|
2022-11-01 15:47:54 +00:00
|
|
|
whiptail --title " Jam (JoinMarket Web UI) " --msgbox "Open in your local web browser & accept self-signed cert:
|
2022-02-18 22:01:38 +00:00
|
|
|
https://${localip}:7501\n
|
|
|
|
with Fingerprint:
|
2022-01-15 11:00:36 +01:00
|
|
|
${fingerprint}\n
|
2022-03-02 10:21:00 +00:00
|
|
|
Activate Tor to access the web interface from outside your local network.
|
2022-01-15 11:00:36 +01:00
|
|
|
" 15 57
|
|
|
|
fi
|
2022-12-19 12:28:56 +01:00
|
|
|
echo "# please wait ..."
|
2022-01-15 11:00:36 +01:00
|
|
|
else
|
2022-12-19 12:28:56 +01:00
|
|
|
echo "# *** JAM NOT INSTALLED ***"
|
2022-01-15 11:00:36 +01:00
|
|
|
fi
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2022-12-19 12:28:56 +01:00
|
|
|
# install (code & compile)
|
|
|
|
if [ "$1" = "install" ]; then
|
2022-01-15 11:00:36 +01:00
|
|
|
|
2022-12-19 12:28:56 +01:00
|
|
|
if [ "${isInstalled}" != "0" ]; then
|
|
|
|
echo "result='already installed'"
|
|
|
|
exit 0
|
|
|
|
fi
|
2022-11-01 15:47:54 +00:00
|
|
|
|
2022-12-19 12:28:56 +01:00
|
|
|
# make sure joinmarket is installed
|
|
|
|
sudo /home/admin/config.scripts/bonus.joinmarket.sh install || exit 1
|
|
|
|
|
|
|
|
echo "# *** INSTALL JAM (user & code) ***"
|
2022-01-15 11:00:36 +01:00
|
|
|
|
2022-12-19 12:28:56 +01:00
|
|
|
echo "# Creating the ${USERNAME} user"
|
|
|
|
sudo adduser --disabled-password --gecos "" ${USERNAME}
|
2022-01-15 11:00:36 +01:00
|
|
|
|
2022-12-19 12:28:56 +01:00
|
|
|
# install nodeJS
|
|
|
|
/home/admin/config.scripts/bonus.nodejs.sh on
|
2022-03-02 10:21:00 +00:00
|
|
|
|
2022-12-19 12:28:56 +01:00
|
|
|
# install
|
|
|
|
cd $HOME_DIR || exit 1
|
2022-01-15 11:00:36 +01:00
|
|
|
|
2022-12-19 12:28:56 +01:00
|
|
|
sudo -u $USERNAME git clone https://github.com/$REPO
|
2022-01-15 11:00:36 +01:00
|
|
|
|
2022-12-19 12:28:56 +01:00
|
|
|
cd jam || exit 1
|
|
|
|
sudo -u $USERNAME git reset --hard v${WEBUI_VERSION}
|
2022-03-02 10:21:00 +00:00
|
|
|
|
2022-12-19 12:28:56 +01:00
|
|
|
sudo -u $USERNAME /home/admin/config.scripts/blitz.git-verify.sh "${PGPsigner}" "${PGPpubkeyLink}" "${PGPpubkeyFingerprint}" "v${WEBUI_VERSION}" || exit 1
|
2022-01-15 11:00:36 +01:00
|
|
|
|
2022-12-19 12:28:56 +01:00
|
|
|
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
|
2022-01-15 11:00:36 +01:00
|
|
|
|
2022-12-19 12:28:56 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
# 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
|
|
|
|
sudo /home/admin/config.scripts/bonus.jam.sh install 1>&2 || exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# make sure joinmarket base is also activated
|
|
|
|
sudo /home/admin/config.scripts/bonus.joinmarket.sh on 1>&2 || exit 1
|
|
|
|
|
|
|
|
echo "# *** ACTIVATING JAM ***"
|
|
|
|
|
|
|
|
##################
|
|
|
|
# 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
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
#########################
|
|
|
|
## 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
|
|
|
|
|
|
|
|
# SYSTEMD SERVICE
|
|
|
|
echo "# Install JoinMarket API systemd" 1>&2
|
|
|
|
echo "\
|
2022-01-15 11:00:36 +01:00
|
|
|
# Systemd unit for JoinMarket API
|
|
|
|
|
|
|
|
[Unit]
|
|
|
|
Description=JoinMarket API daemon
|
|
|
|
|
|
|
|
[Service]
|
2022-11-01 15:47:54 +00:00
|
|
|
WorkingDirectory=/home/joinmarket/joinmarket-clientserver/scripts/
|
|
|
|
ExecStartPre=-/home/admin/config.scripts/bonus.jam.sh precheck
|
|
|
|
ExecStart=/bin/sh -c '. /home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate && python jmwalletd.py'
|
2022-01-15 11:00:36 +01:00
|
|
|
User=joinmarket
|
|
|
|
Group=joinmarket
|
|
|
|
Restart=always
|
|
|
|
TimeoutSec=120
|
2022-11-01 15:47:54 +00:00
|
|
|
RestartSec=60
|
2022-12-12 14:29:51 +01:00
|
|
|
LogLevelMax=4
|
|
|
|
|
2022-01-15 11:00:36 +01:00
|
|
|
# Hardening measures
|
|
|
|
PrivateTmp=true
|
|
|
|
ProtectSystem=full
|
|
|
|
NoNewPrivileges=true
|
|
|
|
PrivateDevices=true
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
2022-12-19 12:28:56 +01:00
|
|
|
" | sudo tee /etc/systemd/system/joinmarket-api.service 1>&2
|
|
|
|
sudo systemctl enable joinmarket-api 1>&2
|
2022-01-15 11:00:36 +01:00
|
|
|
|
2022-12-19 12:28:56 +01:00
|
|
|
# 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
|
2022-01-15 11:00:36 +01:00
|
|
|
|
2022-12-19 12:28:56 +01:00
|
|
|
# Hidden Service for jam if Tor is active
|
|
|
|
if [ "${runBehindTor}" = "on" ]; then
|
2022-11-01 15:47:54 +00:00
|
|
|
# remove legacy
|
2022-12-19 12:28:56 +01:00
|
|
|
/home/admin/config.scripts/tor.onion-service.sh off joinmarket-webui 1>&2
|
2022-11-01 15:47:54 +00:00
|
|
|
# add jam
|
2022-12-19 12:28:56 +01:00
|
|
|
/home/admin/config.scripts/tor.onion-service.sh jam 80 7502 443 7503 1>&2
|
|
|
|
fi
|
|
|
|
source $RASPIBLITZ_INFO
|
|
|
|
if [ "${state}" == "ready" ]; then
|
2022-01-15 11:00:36 +01:00
|
|
|
echo "# OK - the joinmarket-api.service is enabled, system is ready so starting service"
|
|
|
|
sudo systemctl start joinmarket-api
|
|
|
|
else
|
2022-12-19 12:28:56 +01:00
|
|
|
echo "# OK - the joinmarket-api.service is enabled, to start manually use: 'sudo systemctl start joinmarket-api'"
|
2022-01-15 11:00:36 +01:00
|
|
|
fi
|
2022-12-19 12:28:56 +01:00
|
|
|
|
2022-11-01 15:47:54 +00:00
|
|
|
echo "# Start the joinmarket ob-watcher.service"
|
2022-12-19 12:28:56 +01:00
|
|
|
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'"
|
2022-01-15 11:00:36 +01:00
|
|
|
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
|
2022-07-28 15:14:44 +01:00
|
|
|
echo "# Create a non-descriptor wallet.dat"
|
|
|
|
/usr/local/bin/bitcoin-cli -conf=/mnt/hdd/bitcoin/bitcoin.conf -named createwallet wallet_name=wallet.dat descriptors=false
|
2022-01-15 11:00:36 +01:00
|
|
|
else
|
2022-07-28 15:14:44 +01:00
|
|
|
isDescriptor=$(/usr/local/bin/bitcoin-cli -conf=/mnt/hdd/bitcoin/bitcoin.conf -rpcwallet=wallet.dat getwalletinfo | grep -c '"descriptors": true,')
|
|
|
|
if [ "$isDescriptor" -gt 0 ]; then
|
|
|
|
# unload
|
|
|
|
/usr/local/bin/bitcoin-cli -conf=/mnt/hdd/bitcoin/bitcoin.conf unloadwallet wallet.dat
|
|
|
|
echo "# Move the wallet.dat with descriptors to /mnt/hdd/bitcoin/descriptors"
|
|
|
|
mv /mnt/hdd/bitcoin/wallet.dat /mnt/hdd/bitcoin/descriptors
|
|
|
|
echo "# Create a non-descriptor wallet.dat"
|
|
|
|
/usr/local/bin/bitcoin-cli -conf=/mnt/hdd/bitcoin/bitcoin.conf -named createwallet wallet_name=wallet.dat descriptors=false
|
|
|
|
else
|
|
|
|
echo "# The non-descriptor wallet.dat is loaded in bitcoind."
|
|
|
|
fi
|
2022-01-15 11:00:36 +01:00
|
|
|
fi
|
2022-11-01 15:47:54 +00:00
|
|
|
echo "# Make sure max_cj_fee_abs and max_cj_fee_rel are set"
|
|
|
|
# max_cj_fee_abs between 5000 - 10000 sats
|
|
|
|
sed -i "s/#max_cj_fee_abs = x/max_cj_fee_abs = $(shuf -i 5000-10000 -n1)/g" /home/joinmarket/.joinmarket/joinmarket.cfg
|
|
|
|
# max_cj_fee_rel between 0.01 - 0.03%
|
|
|
|
sed -i "s/#max_cj_fee_rel = x/max_cj_fee_rel = 0.000$((RANDOM%3+1))/g" /home/joinmarket/.joinmarket/joinmarket.cfg
|
2022-01-15 11:00:36 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# update
|
|
|
|
if [ "$1" = "update" ]; then
|
|
|
|
isInstalled=$(sudo ls $HOME_DIR 2>/dev/null | grep -c "$APP_DIR")
|
2022-11-01 15:47:54 +00:00
|
|
|
if [ ${isInstalled} -gt 0 ]; then
|
|
|
|
echo "*** UPDATE JAM ***"
|
|
|
|
cd $HOME_DIR || exit 1
|
2022-01-15 11:00:36 +01:00
|
|
|
|
|
|
|
if [ "$2" = "commit" ]; then
|
2022-11-01 15:47:54 +00:00
|
|
|
echo "# Remove old source code"
|
|
|
|
sudo rm -rf jam
|
|
|
|
sudo rm -rf $APP_DIR
|
|
|
|
echo "# Downloading the latest commit in the default branch of $REPO"
|
|
|
|
sudo -u $USERNAME git clone https://github.com/$REPO
|
2022-01-15 11:00:36 +01:00
|
|
|
else
|
2022-12-16 11:12:56 +01:00
|
|
|
version=$(curl --header "X-GitHub-Api-Version:2022-11-28" --silent "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
|
2022-11-01 15:47:54 +00:00
|
|
|
cd $APP_DIR || exit 1
|
2022-01-15 11:00:36 +01:00
|
|
|
current=$(node -p "require('./package.json').version")
|
|
|
|
cd ..
|
|
|
|
if [ "$current" = "$version" ]; then
|
2022-11-01 15:47:54 +00:00
|
|
|
echo "*** JAM IS ALREADY UPDATED TO LATEST RELEASE ***"
|
2022-01-15 11:00:36 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
2022-11-01 15:47:54 +00:00
|
|
|
|
|
|
|
echo "# Remove old source code"
|
|
|
|
sudo rm -rf jam
|
|
|
|
sudo rm -rf $APP_DIR
|
|
|
|
sudo -u $USERNAME git clone https://github.com/$REPO
|
|
|
|
cd jam || exit 1
|
|
|
|
sudo -u $USERNAME git reset --hard v${version}
|
|
|
|
|
|
|
|
sudo -u $USERNAME /home/admin/config.scripts/blitz.git-verify.sh \
|
|
|
|
"${PGPsigner}" "${PGPpubkeyLink}" "${PGPpubkeyFingerprint}" "v${version}" || exit 1
|
|
|
|
|
|
|
|
cd $HOME_DIR || exit 1
|
2022-01-15 11:00:36 +01:00
|
|
|
fi
|
|
|
|
|
2022-11-01 15:47:54 +00:00
|
|
|
sudo -u $USERNAME mv jam $APP_DIR
|
|
|
|
cd $APP_DIR || exit 1
|
2022-01-15 11:00:36 +01:00
|
|
|
sudo -u $USERNAME rm -rf docker
|
2022-11-01 15:47:54 +00:00
|
|
|
if ! sudo -u $USERNAME npm install; then
|
2022-01-15 11:00:36 +01:00
|
|
|
echo "FAIL - npm install did not run correctly, aborting"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
sudo -u $USERNAME npm run build
|
2022-11-01 15:47:54 +00:00
|
|
|
echo "*** JAM UPDATED to $version ***"
|
2022-01-15 11:00:36 +01:00
|
|
|
else
|
2022-11-01 15:47:54 +00:00
|
|
|
echo "*** JAM IS NOT INSTALLED ***"
|
2022-01-15 11:00:36 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# switch off
|
|
|
|
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
|
|
|
|
|
2022-12-19 12:28:56 +01:00
|
|
|
echo "# *** DEACTIVATE JAM ***"
|
2022-01-15 11:00:36 +01:00
|
|
|
|
2022-12-19 12:28:56 +01:00
|
|
|
echo "# Cleaning up Jam install ..."
|
2022-11-01 15:47:54 +00:00
|
|
|
# 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
|
2022-12-19 12:28:56 +01:00
|
|
|
sudo ufw delete allow from any to any port 7500 1>&2
|
|
|
|
sudo ufw delete allow from any to any port 7501 1>&2
|
2022-11-01 15:47:54 +00:00
|
|
|
|
|
|
|
# remove nginx symlinks and configs
|
2022-12-19 12:28:56 +01:00
|
|
|
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
|
2022-11-01 15:47:54 +00:00
|
|
|
|
|
|
|
# Hidden Service if Tor is active
|
|
|
|
if [ "${runBehindTor}" = "on" ]; then
|
2022-12-19 12:28:56 +01:00
|
|
|
/home/admin/config.scripts/tor.onion-service.sh off jam 1>&2
|
2022-11-01 15:47:54 +00:00
|
|
|
fi
|
2022-01-15 11:00:36 +01:00
|
|
|
|
2022-11-01 15:47:54 +00:00
|
|
|
# remove SSL
|
2022-12-19 12:28:56 +01:00
|
|
|
sudo rm -rf $HOME_DIR/.joinmarket/ssl 1>&2
|
2022-01-15 11:00:36 +01:00
|
|
|
|
2022-11-01 15:47:54 +00:00
|
|
|
# setting value in raspi blitz config
|
|
|
|
/home/admin/config.scripts/blitz.conf.sh delete jam $RASPIBLITZ_CONF
|
2022-01-15 11:00:36 +01:00
|
|
|
|
2022-12-19 12:28:56 +01:00
|
|
|
echo "# OK, Jam is removed"
|
2022-01-15 11:00:36 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "FAIL - Unknown Parameter $1"
|
|
|
|
exit 1
|