From 7ff6c79835e2976ae2fb4680ffb136d2005e2c82 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Sat, 27 Mar 2021 20:00:47 +0000 Subject: [PATCH] remove natsapi from normal install --- backup.sh | 15 +++++++++------ docs/docs/troubleshooting.md | 1 - install.sh | 23 +---------------------- restore.sh | 4 ---- update.sh | 16 ++++++++++------ 5 files changed, 20 insertions(+), 39 deletions(-) diff --git a/backup.sh b/backup.sh index 870052bb..f8696460 100755 --- a/backup.sh +++ b/backup.sh @@ -1,6 +1,6 @@ #!/bin/bash -SCRIPT_VERSION="10" +SCRIPT_VERSION="11" SCRIPT_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/backup.sh' GREEN='\033[0;32m' @@ -8,17 +8,20 @@ YELLOW='\033[1;33m' BLUE='\033[0;34m' RED='\033[0;31m' NC='\033[0m' +THIS_SCRIPT=$(readlink -f "$0") TMP_FILE=$(mktemp -p "" "rmmbackup_XXXXXXXXXX") curl -s -L "${SCRIPT_URL}" > ${TMP_FILE} NEW_VER=$(grep "^SCRIPT_VERSION" "$TMP_FILE" | awk -F'[="]' '{print $3}') if [ "${SCRIPT_VERSION}" -ne "${NEW_VER}" ]; then - printf >&2 "${YELLOW}A newer version of this backup script is available.${NC}\n" - printf >&2 "${YELLOW}Please download the latest version from ${GREEN}${SCRIPT_URL}${YELLOW} and re-run.${NC}\n" - rm -f $TMP_FILE - exit 1 + printf >&2 "${YELLOW}Old backup script detected, downloading and replacing with the latest version...${NC}\n" + wget -q "${SCRIPT_URL}" -O backup.sh + exec ${THIS_SCRIPT} fi + +rm -f $TMP_FILE + if [ $EUID -eq 0 ]; then echo -ne "\033[0;31mDo NOT run this script as root. Exiting.\e[0m\n" exit 1 @@ -69,7 +72,7 @@ sudo tar -czvf ${tmp_dir}/nginx/etc-nginx.tar.gz -C /etc/nginx . sudo tar -czvf ${tmp_dir}/confd/etc-confd.tar.gz -C /etc/conf.d . -sudo cp ${sysd}/rmm.service ${sysd}/celery.service ${sysd}/celerybeat.service ${sysd}/meshcentral.service ${sysd}/nats.service ${sysd}/natsapi.service ${tmp_dir}/systemd/ +sudo cp ${sysd}/rmm.service ${sysd}/celery.service ${sysd}/celerybeat.service ${sysd}/meshcentral.service ${sysd}/nats.service ${tmp_dir}/systemd/ cat /rmm/api/tacticalrmm/tacticalrmm/private/log/debug.log | gzip -9 > ${tmp_dir}/rmm/debug.log.gz cp /rmm/api/tacticalrmm/tacticalrmm/local_settings.py /rmm/api/tacticalrmm/app.ini ${tmp_dir}/rmm/ diff --git a/docs/docs/troubleshooting.md b/docs/docs/troubleshooting.md index 3f34fc0c..b98dbf23 100644 --- a/docs/docs/troubleshooting.md +++ b/docs/docs/troubleshooting.md @@ -69,7 +69,6 @@ sudo systemctl status celery sudo systemctl status celerybeat sudo systemctl status nginx sudo systemctl status nats -sudo systemctl status natsapi sudo systemctl status meshcentral sudo systemctl status mongod sudo systemctl status postgresql diff --git a/install.sh b/install.sh index ab8d7a8c..05fb01d7 100644 --- a/install.sh +++ b/install.sh @@ -482,26 +482,6 @@ EOF )" echo "${natsservice}" | sudo tee /etc/systemd/system/nats.service > /dev/null -natsapi="$(cat << EOF -[Unit] -Description=Tactical NATS API -After=network.target rmm.service nginx.service nats.service - -[Service] -Type=simple -ExecStart=/usr/local/bin/nats-api -User=${USER} -Group=${USER} -Restart=always -RestartSec=5s - -[Install] -WantedBy=multi-user.target -EOF -)" -echo "${natsapi}" | sudo tee /etc/systemd/system/natsapi.service > /dev/null - - nginxrmm="$(cat << EOF server_tokens off; @@ -808,7 +788,6 @@ sleep 5 MESHEXE=$(node node_modules/meshcentral/meshctrl.js --url wss://${meshdomain}:443 --loginuser ${meshusername} --loginpass ${MESHPASSWD} GenerateInviteLink --group TacticalRMM --hours 8) sudo systemctl enable nats.service -sudo systemctl enable natsapi.service cd /rmm/api/tacticalrmm source /rmm/api/env/bin/activate python manage.py initial_db_setup @@ -820,7 +799,7 @@ sudo systemctl start nats.service sed -i 's/ADMIN_ENABLED = True/ADMIN_ENABLED = False/g' /rmm/api/tacticalrmm/tacticalrmm/local_settings.py print_green 'Restarting services' -for i in rmm.service celery.service celerybeat.service natsapi.service +for i in rmm.service celery.service celerybeat.service do sudo systemctl stop ${i} sudo systemctl start ${i} diff --git a/restore.sh b/restore.sh index 01ca8975..4c379865 100755 --- a/restore.sh +++ b/restore.sh @@ -350,10 +350,6 @@ print_green 'Starting meshcentral' sudo systemctl enable meshcentral sudo systemctl start meshcentral -print_green 'Starting natsapi' -sudo systemctl enable natsapi.service -sudo systemctl start natsapi.service - printf >&2 "${YELLOW}%0.s*${NC}" {1..80} printf >&2 "\n\n" printf >&2 "${YELLOW}Restore complete!${NC}\n\n" diff --git a/update.sh b/update.sh index 0f175d01..d8893a46 100644 --- a/update.sh +++ b/update.sh @@ -67,7 +67,15 @@ LATEST_NPM_VER=$(grep "^NPM_VER" "$TMP_SETTINGS" | awk -F'[= "]' '{print $5}') CURRENT_PIP_VER=$(grep "^PIP_VER" "$SETTINGS_FILE" | awk -F'[= "]' '{print $5}') CURRENT_NPM_VER=$(grep "^NPM_VER" "$SETTINGS_FILE" | awk -F'[= "]' '{print $5}') -for i in nginx nats natsapi rmm celery celerybeat +if [ -f /etc/systemd/system/natsapi.service ]; then + printf >&2 "${GREEN}Removing natsapi.service${NC}\n" + sudo systemctl stop natsapi.service + sudo systemctl disable natsapi.service + sudo rm -f /etc/systemd/system/natsapi.service + sudo systemctl daemon-reload +fi + +for i in nginx nats rmm celery celerybeat do printf >&2 "${GREEN}Stopping ${i} service...${NC}\n" sudo systemctl stop ${i} @@ -107,10 +115,6 @@ EOF )" echo "${uwsgini}" > /rmm/api/tacticalrmm/app.ini - -# forgot to add this in install script. catch any installs that don't have it enabled and enable it -sudo systemctl enable natsapi.service - CHECK_NGINX_WORKER_CONN=$(grep "worker_connections 2048" /etc/nginx/nginx.conf) if ! [[ $CHECK_NGINX_WORKER_CONN ]]; then printf >&2 "${GREEN}Changing nginx worker connections to 2048${NC}\n" @@ -254,7 +258,7 @@ sudo rm -rf /var/www/rmm/dist sudo cp -pr /rmm/web/dist /var/www/rmm/ sudo chown www-data:www-data -R /var/www/rmm/dist -for i in rmm celery celerybeat nginx nats natsapi +for i in rmm celery celerybeat nginx nats do printf >&2 "${GREEN}Starting ${i} service${NC}\n" sudo systemctl start ${i}