From 244b89f035356f1bcd49bd0ceb89a32dd6989ccb Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Wed, 3 Feb 2021 20:11:49 +0000 Subject: [PATCH 1/6] exclude migrations from black --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6a1d6afc83..7e7c9a2084 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -44,7 +44,7 @@ jobs: - script: | cd /myagent/_work/1/s/api source env/bin/activate - black --check tacticalrmm + black --exclude migrations/ --check tacticalrmm if [ $? -ne 0 ]; then exit 1 fi From 22488e93e104f50f68dac6c48695c2b0d3612da8 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Wed, 3 Feb 2021 23:23:34 +0000 Subject: [PATCH 2/6] approve updates when triggered manually --- api/tacticalrmm/winupdate/tasks.py | 4 ++++ api/tacticalrmm/winupdate/views.py | 1 + 2 files changed, 5 insertions(+) diff --git a/api/tacticalrmm/winupdate/tasks.py b/api/tacticalrmm/winupdate/tasks.py index 54b45c4f9c..a1ee8f9d19 100644 --- a/api/tacticalrmm/winupdate/tasks.py +++ b/api/tacticalrmm/winupdate/tasks.py @@ -129,6 +129,10 @@ def bulk_install_updates_task(pks: List[int]) -> None: for chunk in chunks: for agent in chunk: agent.delete_superseded_updates() + try: + agent.approve_updates() + except: + pass nats_data = { "func": "installwinupdates", "guids": agent.get_approved_update_guids(), diff --git a/api/tacticalrmm/winupdate/views.py b/api/tacticalrmm/winupdate/views.py index 4b5af2103f..629e94da5a 100644 --- a/api/tacticalrmm/winupdate/views.py +++ b/api/tacticalrmm/winupdate/views.py @@ -37,6 +37,7 @@ def install_updates(request, pk): if pyver.parse(agent.version) < pyver.parse("1.3.0"): return notify_error("Requires agent version 1.3.0 or greater") + agent.approve_updates() nats_data = { "func": "installwinupdates", "guids": agent.get_approved_update_guids(), From 1bfefcce3971615fe51f325546e5f2e98e349808 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Sat, 6 Feb 2021 00:38:29 +0000 Subject: [PATCH 3/6] fix backup --- backup.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/backup.sh b/backup.sh index 0a316493af..0538fc870c 100755 --- a/backup.sh +++ b/backup.sh @@ -1,6 +1,13 @@ #!/bin/bash -SCRIPT_VERSION="7" +##################################################### + +POSTGRES_USER="changeme" +POSTGRES_PW="hunter2" + +##################################################### + +SCRIPT_VERSION="8" SCRIPT_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/backup.sh' GREEN='\033[0;32m' @@ -24,13 +31,6 @@ if [ $EUID -eq 0 ]; then exit 1 fi -##################################################### - -POSTGRES_USER="changeme" -POSTGRES_PW="hunter2" - -##################################################### - if [[ "$POSTGRES_USER" == "changeme" || "$POSTGRES_PW" == "hunter2" ]]; then printf >&2 "${RED}You must change the postgres username/password at the top of this file.${NC}\n" printf >&2 "${RED}Check the github readme for where to find them.${NC}\n" @@ -43,7 +43,7 @@ if [ ! -d /rmmbackups ]; then fi if [ -d /meshcentral/meshcentral-backup ]; then - rm -f /meshcentral/meshcentral-backup/* + rm -rf /meshcentral/meshcentral-backup/* fi if [ -d /meshcentral/meshcentral-coredumps ]; then From c6e9e2967137964fd2974154b5af154c73d17295 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Sat, 6 Feb 2021 00:39:22 +0000 Subject: [PATCH 4/6] increase uwsgi buffer size --- install.sh | 8 +++----- update.sh | 11 ++++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index d2efd2b048..1f4e30b279 100644 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/bin/bash -SCRIPT_VERSION="36" +SCRIPT_VERSION="37" SCRIPT_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/install.sh' sudo apt install -y curl wget dirmngr gnupg lsb-release @@ -398,19 +398,17 @@ read -n 1 -s -r -p "Press any key to continue..." uwsgini="$(cat << EOF [uwsgi] - -# logto = /rmm/api/tacticalrmm/tacticalrmm/private/log/uwsgi.log chdir = /rmm/api/tacticalrmm module = tacticalrmm.wsgi home = /rmm/api/env master = true processes = 6 threads = 6 -enable-threads = True +enable-threads = true socket = /rmm/api/tacticalrmm/tacticalrmm.sock harakiri = 300 chmod-socket = 660 -# clear environment on exit +buffer-size = 65535 vacuum = true die-on-term = true max-requests = 500 diff --git a/update.sh b/update.sh index 813413c174..50fc74dc15 100644 --- a/update.sh +++ b/update.sh @@ -1,6 +1,6 @@ #!/bin/bash -SCRIPT_VERSION="105" +SCRIPT_VERSION="106" SCRIPT_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/update.sh' LATEST_SETTINGS_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/api/tacticalrmm/tacticalrmm/settings.py' YELLOW='\033[1;33m' @@ -193,6 +193,15 @@ sudo chown -R $USER:$GROUP /home/${USER}/.cache sudo chown ${USER}:${USER} -R /etc/letsencrypt sudo chmod 775 -R /etc/letsencrypt +CHECK_BUFF_SIZE=$(grep buffer-size /rmm/api/tacticalrmm/app.ini) +if ! [[ $CHECK_BUFF_SIZE ]]; then +setbuff="$(cat << EOF +buffer-size = 65535 +EOF +)" +echo "${setbuff}" | tee --append /rmm/api/tacticalrmm/app.ini > /dev/null +fi + CHECK_REMOVE_SALT=$(grep KEEP_SALT /rmm/api/tacticalrmm/tacticalrmm/local_settings.py) if ! [[ $CHECK_REMOVE_SALT ]]; then printf >&2 "${YELLOW}This update removes salt from the rmm${NC}\n" From bcfb3726b0d8d7014138fffaba0a89ad338c8c77 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Sat, 6 Feb 2021 00:40:25 +0000 Subject: [PATCH 5/6] update restore script to work on debian 10 --- restore.sh | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/restore.sh b/restore.sh index a436161bc0..cd4c277011 100755 --- a/restore.sh +++ b/restore.sh @@ -7,10 +7,10 @@ pgpw="hunter2" ##################################################### -SCRIPT_VERSION="14" +SCRIPT_VERSION="15" SCRIPT_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/restore.sh' -sudo apt install -y curl wget +sudo apt install -y curl wget dirmngr gnupg lsb-release GREEN='\033[0;32m' YELLOW='\033[1;33m' @@ -37,12 +37,38 @@ if [[ "$pgusername" == "changeme" || "$pgpw" == "hunter2" ]]; then exit 1 fi -UBU20=$(grep 20.04 "/etc/"*"release") -if ! [[ $UBU20 ]]; then - echo -ne "\033[0;31mThis restore script will only work on Ubuntu 20.04\e[0m\n" - exit 1 +osname=$(lsb_release -si); osname=${osname^} +osname=$(echo "$osname" | tr '[A-Z]' '[a-z]') +fullrel=$(lsb_release -sd) +codename=$(lsb_release -sc) +relno=$(lsb_release -sr | cut -d. -f1) +fullrelno=$(lsb_release -sr) + +# Fallback if lsb_release -si returns anything else than Ubuntu, Debian or Raspbian +if [ ! "$osname" = "ubuntu" ] && [ ! "$osname" = "debian" ]; then + osname=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"') + osname=${osname^} fi +# determine system +if ([ "$osname" = "ubuntu" ] && [ "$fullrelno" = "20.04" ]) || ([ "$osname" = "debian" ] && [ $relno -ge 10 ]); then + echo $fullrel +else + echo $fullrel + echo -ne "${RED}Only Ubuntu release 20.04 and Debian 10 and later, are supported\n" + echo -ne "Your system does not appear to be supported${NC}\n" + exit 1 +fi + +if ([ "$osname" = "ubuntu" ]); then + mongodb_repo="deb [arch=amd64] https://repo.mongodb.org/apt/$osname $codename/mongodb-org/4.4 multiverse" +else + mongodb_repo="deb [arch=amd64] https://repo.mongodb.org/apt/$osname $codename/mongodb-org/4.4 main" + +fi + +postgresql_repo="deb [arch=amd64] https://apt.postgresql.org/pub/repos/apt/ $codename-pgdg main" + if [ $EUID -eq 0 ]; then echo -ne "\033[0;31mDo NOT run this script as root. Exiting.\e[0m\n" exit 1 @@ -172,7 +198,7 @@ sudo apt install -y python3-venv python3-dev python3-pip python3-setuptools pyth print_green 'Installing postgresql' -sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' +echo "$postgresql_repo" | sudo tee /etc/apt/sources.list.d/pgdg.list wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt update sudo apt install -y postgresql-13 @@ -194,8 +220,8 @@ PGPASSWORD=${pgpw} psql -h localhost -U ${pgusername} -d tacticalrmm -f $tmp_dir print_green 'Restoring MongoDB' -wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add - -echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list +wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add - +echo "$mongodb_repo" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list sudo apt update sudo apt install -y mongodb-org sudo systemctl enable mongod From 71fb39db1f42d3f6d4de43e1a2014c562c9f4d76 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Sat, 6 Feb 2021 00:59:49 +0000 Subject: [PATCH 6/6] bump versions --- api/tacticalrmm/tacticalrmm/settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/tacticalrmm/tacticalrmm/settings.py b/api/tacticalrmm/tacticalrmm/settings.py index e26293b451..2cb36b673e 100644 --- a/api/tacticalrmm/tacticalrmm/settings.py +++ b/api/tacticalrmm/tacticalrmm/settings.py @@ -15,14 +15,14 @@ AUTH_USER_MODEL = "accounts.User" # latest release -TRMM_VERSION = "0.4.6" +TRMM_VERSION = "0.4.7" # bump this version everytime vue code is changed # to alert user they need to manually refresh their browser APP_VER = "0.0.111" # https://github.com/wh1te909/rmmagent -LATEST_AGENT_VER = "1.4.3" +LATEST_AGENT_VER = "1.4.4" MESH_VER = "0.7.54"