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
|
2021-04-11 00:51:26 +00:00
|
|
|
rm -f /home/bitcoin/.mynode/${APP}_version || true
|
|
|
|
rm -f /mnt/hdd/mynode/settings/${APP}_version || true
|
|
|
|
|
2021-05-06 04:14:05 +00:00
|
|
|
# Make sure app is marked for install
|
|
|
|
if [ -f /home/bitcoin/.mynode/${APP}_version_latest ]; then
|
|
|
|
touch /home/bitcoin/.mynode/install_${APP} || true
|
|
|
|
else
|
|
|
|
touch /mnt/hdd/mynode/settings/install_${APP} || true
|
|
|
|
fi
|
|
|
|
|
2021-04-11 00:51:26 +00:00
|
|
|
# Custom re-install steps
|
2021-05-18 01:41:26 +00:00
|
|
|
if [ "$APP" = "bos" ]; then
|
|
|
|
npm uninstall -g balanceofsatoshis
|
|
|
|
elif [ "$APP" = "netdata" ]; then
|
2020-03-21 02:53:38 +00:00
|
|
|
systemctl stop netdata
|
|
|
|
docker rmi netdata/netdata || true
|
2020-10-30 03:19:48 +00:00
|
|
|
elif [ "$APP" = "btcpayserver" ]; then
|
2022-04-14 02:36:04 +00:00
|
|
|
# Stop and clean images
|
|
|
|
/usr/local/bin/btcpay-down.sh
|
|
|
|
/usr/local/bin/btcpay-clean.sh
|
|
|
|
|
|
|
|
# Remove files and data (don't remove volume for re-install)
|
|
|
|
rm -f /etc/profile.d/btcpay-env.sh
|
|
|
|
rm -rf /usr/local/bin/btcpay-*
|
|
|
|
rm -rf /usr/local/bin/changedomain.sh
|
|
|
|
|
|
|
|
# Finally remove main folder
|
|
|
|
rm -rf /mnt/hdd/mynode/btcpayserver
|
2022-05-25 02:05:06 +00:00
|
|
|
elif [ "$APP" = "docker" ]; then
|
|
|
|
apt-get install --reinstall docker-ce
|
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
|
2021-04-11 00:51:26 +00:00
|
|
|
rm -f /mnt/hdd/mynode/settings/webssh2_version
|
2020-02-09 02:20:35 +00:00
|
|
|
systemctl stop webssh2
|
|
|
|
docker rmi webssh2
|
2021-08-12 04:23:32 +00:00
|
|
|
elif [ "$APP" = "vpn" ]; then
|
|
|
|
rm -rf /etc/openvpn
|
|
|
|
rm -rf /etc/.pivpn
|
|
|
|
rm -rf /home/pivpn/ovpns
|
2020-03-01 18:40:59 +00:00
|
|
|
elif [ "$APP" = "dojo" ]; then
|
|
|
|
rm -f /mnt/hdd/mynode/settings/dojo_url
|
2021-05-18 01:56:17 +00:00
|
|
|
rm -f /mnt/hdd/mynode/settings/mynode_dojo_install
|
2021-01-23 04:55:44 +00:00
|
|
|
cd /mnt/hdd/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 ~
|
2021-01-23 04:55:44 +00:00
|
|
|
rm -rf /opt/download/dojo
|
|
|
|
rm -rf /mnt/hdd/mynode/dojo
|
2021-11-19 20:47:04 +00:00
|
|
|
elif [ "$APP" = "lndmanage" ]; then
|
|
|
|
pip3 uninstall -y lndmanage
|
2020-01-26 03:39:55 +00:00
|
|
|
else
|
2021-04-11 00:51:26 +00:00
|
|
|
echo "No custom re-install steps"
|
2020-01-26 03:39:55 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Run post upgrade script
|
|
|
|
for i in {1..3}
|
|
|
|
do
|
2021-10-09 23:51:56 +00:00
|
|
|
/bin/bash /usr/bin/mynode_post_upgrade.sh 2>&1
|
2020-01-26 03:39:55 +00:00
|
|
|
RC=$?
|
|
|
|
if [ "${RC}" -eq "0" ]; then
|
|
|
|
rm -f $UPGRADE_ERROR_FILE
|
|
|
|
break
|
|
|
|
fi
|
2021-10-09 23:51:56 +00:00
|
|
|
printf "\n\n\n"
|
|
|
|
printf "##################################################\n"
|
|
|
|
printf "Post upgrade script failed attempt $i. Retrying. \n"
|
|
|
|
printf "##################################################\n"
|
|
|
|
printf "\n\n\n"
|
2020-01-26 03:39:55 +00:00
|
|
|
sleep 10s
|
|
|
|
done
|
|
|
|
chown -R admin:admin /home/admin/upgrade_logs
|
|
|
|
sync
|