2020-01-26 03:39:55 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -x
|
|
|
|
#set -e
|
|
|
|
|
|
|
|
source /usr/share/mynode/mynode_config.sh
|
2020-09-07 21:13:45 +00:00
|
|
|
source /usr/share/mynode/mynode_app_versions.sh
|
2020-01-26 03:39:55 +00:00
|
|
|
|
|
|
|
# Make sure we have an app argument
|
|
|
|
if [ "$#" -ne 1 ]; then
|
|
|
|
echo "Usage: mynode_reinstall_app.sh <app_name>"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-03-04 18:51:34 +00:00
|
|
|
APP="$1"
|
|
|
|
|
|
|
|
# Shut down main services to save memory and CPU and stop app being reinstalled
|
|
|
|
/usr/bin/mynode_stop_critical_services.sh
|
2020-01-26 03:39:55 +00:00
|
|
|
|
|
|
|
# Delete the app's version file so it will be re-installed
|
|
|
|
if [ "$APP" = "bitcoin" ]; then
|
2020-09-07 21:13:45 +00:00
|
|
|
rm -f $BTC_VERSION_FILE
|
2020-01-26 03:39:55 +00:00
|
|
|
elif [ "$APP" = "lnd" ]; then
|
2020-09-07 21:13:45 +00:00
|
|
|
rm -f $LND_VERSION_FILE
|
2020-02-09 02:20:35 +00:00
|
|
|
elif [ "$APP" = "loopd" ]; then
|
2020-09-07 21:13:45 +00:00
|
|
|
rm -f $LOOP_VERSION_FILE
|
2020-02-13 03:04:26 +00:00
|
|
|
elif [ "$APP" = "btcrpcexplorer" ]; then
|
2020-09-09 02:20:29 +00:00
|
|
|
rm -f $BTCRPCEXPLORER_VERSION_FILE
|
2020-06-06 01:46:39 +00:00
|
|
|
elif [ "$APP" = "caravan" ]; then
|
2020-09-07 21:13:45 +00:00
|
|
|
rm -f $CARAVAN_VERSION_FILE
|
|
|
|
elif [ "$APP" = "corsproxy" ]; then
|
|
|
|
rm -f $CORSPROXY_VERSION_FILE
|
2020-02-13 03:04:26 +00:00
|
|
|
elif [ "$APP" = "joinmarket" ]; then
|
2020-09-07 21:13:45 +00:00
|
|
|
rm -f $JOINMARKET_VERSION_FILE
|
2020-06-26 04:30:17 +00:00
|
|
|
elif [ "$APP" = "lnbits" ]; then
|
2020-09-09 02:20:29 +00:00
|
|
|
rm -f $LNBITS_VERSION_FILE
|
2020-02-13 03:04:26 +00:00
|
|
|
elif [ "$APP" = "lndconnect" ]; then
|
2020-09-07 21:13:45 +00:00
|
|
|
rm -f $LNDCONNECT_VERSION_FILE
|
2020-01-26 19:59:38 +00:00
|
|
|
elif [ "$APP" = "lndhub" ]; then
|
2020-09-07 21:13:45 +00:00
|
|
|
rm -f $LNDHUB_VERSION_FILE
|
2020-03-21 02:53:38 +00:00
|
|
|
elif [ "$APP" = "netdata" ]; then
|
|
|
|
systemctl stop netdata
|
|
|
|
docker rmi netdata/netdata || true
|
2020-01-26 03:39:55 +00:00
|
|
|
elif [ "$APP" = "mempoolspace" ]; then
|
|
|
|
rm -f /mnt/hdd/mynode/settings/mempoolspace_url
|
2020-02-02 03:09:46 +00:00
|
|
|
systemctl stop mempoolspace
|
|
|
|
docker rmi mempoolspace
|
2020-10-30 03:19:48 +00:00
|
|
|
elif [ "$APP" = "btcpayserver" ]; then
|
|
|
|
. "/opt/mynode/btcpayserver/btcpay-env.sh" && cd "$BTCPAY_BASE_DIRECTORY" && . helpers.sh && btcpay_remove
|
|
|
|
cd ~
|
2020-02-13 03:04:26 +00:00
|
|
|
elif [ "$APP" = "rtl" ]; then
|
2020-09-07 21:13:45 +00:00
|
|
|
rm -f $RTL_VERSION_FILE
|
2020-07-09 03:10:26 +00:00
|
|
|
elif [ "$APP" = "specter" ]; then
|
2020-09-07 21:13:45 +00:00
|
|
|
rm -f $SPECTER_VERSION_FILE
|
2020-07-14 04:50:54 +00:00
|
|
|
elif [ "$APP" = "thunderhub" ]; then
|
2020-09-07 21:13:45 +00:00
|
|
|
rm -f $THUNDERHUB_VERSION_FILE
|
2020-02-13 03:04:26 +00:00
|
|
|
elif [ "$APP" = "tor" ]; then
|
|
|
|
apt-get remove -y tor
|
|
|
|
apt-get install -y tor
|
2020-03-03 05:26:29 +00:00
|
|
|
elif [ "$APP" = "ufw" ]; then
|
|
|
|
apt-get purge -y ufw
|
|
|
|
apt-get install -y ufw
|
2020-01-26 03:39:55 +00:00
|
|
|
elif [ "$APP" = "webssh2" ]; then
|
|
|
|
rm -f /mnt/hdd/mynode/settings/webssh2_url
|
2020-02-09 02:20:35 +00:00
|
|
|
systemctl stop webssh2
|
|
|
|
docker rmi webssh2
|
2020-02-13 03:04:26 +00:00
|
|
|
elif [ "$APP" = "whirlpool" ]; then
|
2020-09-07 21:13:45 +00:00
|
|
|
rm -f $WHIRLPOOL_VERSION_FILE
|
2020-03-01 18:40:59 +00:00
|
|
|
elif [ "$APP" = "dojo" ]; then
|
|
|
|
rm -f /mnt/hdd/mynode/settings/dojo_url
|
|
|
|
cd /opt/mynode/dojo/docker/my-dojo/
|
2020-03-15 19:36:38 +00:00
|
|
|
|
|
|
|
# Stop and uninstall
|
|
|
|
yes | ./dojo.sh uninstall
|
|
|
|
|
|
|
|
# Reset config files
|
2020-03-25 03:28:42 +00:00
|
|
|
cd ~
|
|
|
|
rm -rf /opt/mynode/.dojo
|
|
|
|
rm -rf /opt/mynode/dojo
|
2020-01-26 03:39:55 +00:00
|
|
|
else
|
|
|
|
echo "UNKNOWN APP: $APP"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Run post upgrade script
|
|
|
|
for i in {1..3}
|
|
|
|
do
|
|
|
|
/bin/bash /usr/bin/mynode_post_upgrade.sh > /home/admin/upgrade_logs/reinstall_app_${APP}_post_${i}.txt 2>&1
|
|
|
|
RC=$?
|
|
|
|
if [ "${RC}" -eq "0" ]; then
|
|
|
|
rm -f $UPGRADE_ERROR_FILE
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
sleep 10s
|
|
|
|
done
|
|
|
|
chown -R admin:admin /home/admin/upgrade_logs
|
|
|
|
sync
|