Compare commits

...

19 Commits

Author SHA1 Message Date
wh1te909
fd80ccd2c5 Release 0.16.4 2023-09-02 00:20:54 +00:00
wh1te909
9dc0b24399 bump versions 2023-09-01 23:48:31 +00:00
wh1te909
747954e6fb wording 2023-09-01 22:03:51 +00:00
wh1te909
274f4f227e node install script is deprecated [skip ci] 2023-09-01 21:12:45 +00:00
wh1te909
92197d8d49 change to localhost 2023-09-01 18:56:09 +00:00
wh1te909
aee06920eb more self signed stuff 2023-09-01 18:55:34 +00:00
wh1te909
5111b17d3c bump web ver [skip ci] 2023-08-30 04:29:36 +00:00
wh1te909
2849d8f45d update scripts for self signed 2023-08-29 23:53:19 +00:00
wh1te909
bac60d9bd4 feat: reset all checks status closes amidaware/tacticalrmm#1615 2023-08-29 20:36:20 +00:00
wh1te909
9c797162f4 only Manual is supported in insecure mode 2023-08-29 20:33:58 +00:00
wh1te909
09d184e2f8 update installers 2023-08-25 18:25:09 +00:00
wh1te909
7bca618906 allow self-signed certs 2023-08-24 21:40:51 +00:00
wh1te909
67607103e9 back to dev [skip ci] 2023-08-24 21:05:50 +00:00
wh1te909
73c9956fe4 Release 0.16.3 2023-08-18 04:33:01 +00:00
wh1te909
b42f2ffe33 bump version [skip ci] 2023-08-18 04:29:41 +00:00
wh1te909
30a3f185ef fix npm #1604 [skip ci] 2023-08-18 04:28:58 +00:00
wh1te909
4f1b41227f Release 0.16.2 2023-08-14 20:57:52 +00:00
wh1te909
83b9d13ec9 bump version [skip ci] 2023-08-14 20:57:14 +00:00
wh1te909
cee7896c37 back to dev [skip ci] 2023-08-14 17:06:40 +00:00
16 changed files with 299 additions and 58 deletions

View File

@@ -570,6 +570,13 @@ def install_agent(request):
from agents.utils import get_agent_url from agents.utils import get_agent_url
from core.utils import token_is_valid from core.utils import token_is_valid
insecure = getattr(settings, "TRMM_INSECURE", False)
if insecure and request.data["installMethod"] in {"exe", "powershell"}:
return notify_error(
"Not available in insecure mode. Please use the 'Manual' method."
)
# TODO rework this ghetto validation hack # TODO rework this ghetto validation hack
# https://github.com/amidaware/tacticalrmm/issues/1461 # https://github.com/amidaware/tacticalrmm/issues/1461
try: try:
@@ -672,6 +679,9 @@ def install_agent(request):
if int(request.data["power"]): if int(request.data["power"]):
cmd.append("--power") cmd.append("--power")
if insecure:
cmd.append("--insecure")
resp["cmd"] = " ".join(str(i) for i in cmd) resp["cmd"] = " ".join(str(i) for i in cmd)
else: else:
install_flags.insert(0, f"sudo ./{inno}") install_flags.insert(0, f"sudo ./{inno}")
@@ -680,6 +690,8 @@ def install_agent(request):
resp["cmd"] = ( resp["cmd"] = (
dl + f" && chmod +x {inno} && " + " ".join(str(i) for i in cmd) dl + f" && chmod +x {inno} && " + " ".join(str(i) for i in cmd)
) )
if insecure:
resp["cmd"] += " --insecure"
resp["url"] = download_url resp["url"] = download_url

View File

@@ -172,6 +172,31 @@ class TestCheckViews(TacticalTestCase):
self.check_not_authenticated("post", url) self.check_not_authenticated("post", url)
def test_reset_all_checks_status(self):
# setup data
agent = baker.make_recipe("agents.agent")
check = baker.make_recipe("checks.diskspace_check", agent=agent)
baker.make("checks.CheckResult", assigned_check=check, agent=agent)
baker.make(
"checks.CheckHistory",
check_id=check.id,
agent_id=agent.agent_id,
_quantity=30,
)
baker.make(
"checks.CheckHistory",
check_id=check.id,
agent_id=agent.agent_id,
_quantity=30,
)
url = f"{base_url}/{agent.agent_id}/resetall/"
resp = self.client.post(url)
self.assertEqual(resp.status_code, 200)
self.check_not_authenticated("post", url)
def test_add_memory_check(self): def test_add_memory_check(self):
url = f"{base_url}/" url = f"{base_url}/"
agent = baker.make_recipe("agents.agent") agent = baker.make_recipe("agents.agent")

View File

@@ -6,6 +6,7 @@ urlpatterns = [
path("", views.GetAddChecks.as_view()), path("", views.GetAddChecks.as_view()),
path("<int:pk>/", views.GetUpdateDeleteCheck.as_view()), path("<int:pk>/", views.GetUpdateDeleteCheck.as_view()),
path("<int:pk>/reset/", views.ResetCheck.as_view()), path("<int:pk>/reset/", views.ResetCheck.as_view()),
path("<agent:agent_id>/resetall/", views.ResetAllChecksStatus.as_view()),
path("<agent:agent_id>/run/", views.run_checks), path("<agent:agent_id>/run/", views.run_checks),
path("<int:pk>/history/", views.GetCheckHistory.as_view()), path("<int:pk>/history/", views.GetCheckHistory.as_view()),
path("<str:target>/<int:pk>/csbulkrun/", views.bulk_run_checks), path("<str:target>/<int:pk>/csbulkrun/", views.bulk_run_checks),

View File

@@ -1,7 +1,7 @@
import asyncio import asyncio
from datetime import datetime as dt from datetime import datetime as dt
from django.db.models import Q from django.db.models import Prefetch, Q
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.utils import timezone as djangotime from django.utils import timezone as djangotime
from rest_framework.decorators import api_view, permission_classes from rest_framework.decorators import api_view, permission_classes
@@ -13,7 +13,7 @@ from rest_framework.views import APIView
from agents.models import Agent from agents.models import Agent
from alerts.models import Alert from alerts.models import Alert
from automation.models import Policy from automation.models import Policy
from tacticalrmm.constants import CheckStatus, CheckType from tacticalrmm.constants import AGENT_DEFER, CheckStatus, CheckType
from tacticalrmm.exceptions import NatsDown from tacticalrmm.exceptions import NatsDown
from tacticalrmm.helpers import notify_error from tacticalrmm.helpers import notify_error
from tacticalrmm.nats_utils import abulk_nats_command from tacticalrmm.nats_utils import abulk_nats_command
@@ -122,15 +122,54 @@ class ResetCheck(APIView):
result.save() result.save()
# resolve any alerts that are open # resolve any alerts that are open
alert = Alert.create_or_return_check_alert( if alert := Alert.create_or_return_check_alert(
result.assigned_check, agent=result.agent, skip_create=True result.assigned_check, agent=result.agent, skip_create=True
) ):
if alert:
alert.resolve() alert.resolve()
return Response("The check status was reset") return Response("The check status was reset")
class ResetAllChecksStatus(APIView):
permission_classes = [IsAuthenticated, ChecksPerms]
def post(self, request, agent_id):
agent = get_object_or_404(
Agent.objects.defer(*AGENT_DEFER)
.select_related(
"policy",
"policy__alert_template",
"alert_template",
)
.prefetch_related(
Prefetch(
"checkresults",
queryset=CheckResult.objects.select_related("assigned_check"),
),
"agentchecks",
),
agent_id=agent_id,
)
if not _has_perm_on_agent(request.user, agent.agent_id):
raise PermissionDenied()
for check in agent.get_checks_with_policies():
try:
result = check.check_result
result.status = CheckStatus.PASSING
result.save()
if alert := Alert.create_or_return_check_alert(
result.assigned_check, agent=agent, skip_create=True
):
alert.resolve()
except:
# check hasn't run yet, no check result entry
continue
return Response("All checks status were reset")
class GetCheckHistory(APIView): class GetCheckHistory(APIView):
permission_classes = [IsAuthenticated, ChecksPerms] permission_classes = [IsAuthenticated, ChecksPerms]

View File

@@ -3,6 +3,7 @@ import re
import uuid import uuid
from contextlib import suppress from contextlib import suppress
from django.conf import settings
from django.db.models import Count, Exists, OuterRef, Prefetch, prefetch_related_objects from django.db.models import Count, Exists, OuterRef, Prefetch, prefetch_related_objects
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.utils import timezone as djangotime from django.utils import timezone as djangotime
@@ -288,6 +289,9 @@ class AgentDeployment(APIView):
return Response(DeploymentSerializer(deps, many=True).data) return Response(DeploymentSerializer(deps, many=True).data)
def post(self, request): def post(self, request):
if getattr(settings, "TRMM_INSECURE", False):
return notify_error("Not available in insecure mode")
from accounts.models import User from accounts.models import User
site = get_object_or_404(Site, pk=request.data["site"]) site = get_object_or_404(Site, pk=request.data["site"])
@@ -343,6 +347,9 @@ class GenerateAgent(APIView):
permission_classes = (AllowAny,) permission_classes = (AllowAny,)
def get(self, request, uid): def get(self, request, uid):
if getattr(settings, "TRMM_INSECURE", False):
return notify_error("Not available in insecure mode")
from tacticalrmm.utils import generate_winagent_exe from tacticalrmm.utils import generate_winagent_exe
try: try:

View File

@@ -12,6 +12,16 @@ if [ "${HAS_SYSTEMD}" != 'systemd' ]; then
exit 1 exit 1
fi fi
if [[ $DISPLAY ]]; then
echo "ERROR: Display detected. Installer only supports running headless, i.e from ssh."
echo "If you cannot ssh in then please run 'sudo systemctl isolate multi-user.target' to switch to a non-graphical user session and run the installer again."
exit 1
fi
DEBUG=0
INSECURE=0
NOMESH=0
agentDL='agentDLChange' agentDL='agentDLChange'
meshDL='meshDLChange' meshDL='meshDLChange'
@@ -124,6 +134,19 @@ if [ $# -ne 0 ] && [ $1 == 'uninstall' ]; then
exit 0 exit 0
fi fi
while [[ "$#" -gt 0 ]]; do
case $1 in
--debug) DEBUG=1 ;;
--insecure) INSECURE=1 ;;
--nomesh) NOMESH=1 ;;
*)
echo "ERROR: Unknown parameter: $1"
exit 1
;;
esac
shift
done
RemoveOldAgent RemoveOldAgent
echo "Downloading tactical agent..." echo "Downloading tactical agent..."
@@ -136,7 +159,7 @@ chmod +x ${agentBin}
MESH_NODE_ID="" MESH_NODE_ID=""
if [ $# -ne 0 ] && [ $1 == '--nomesh' ]; then if [[ $NOMESH -eq 1 ]]; then
echo "Skipping mesh install" echo "Skipping mesh install"
else else
if [ -f "${meshSystemBin}" ]; then if [ -f "${meshSystemBin}" ]; then
@@ -154,18 +177,22 @@ if [ ! -d "${agentBinPath}" ]; then
mkdir -p ${agentBinPath} mkdir -p ${agentBinPath}
fi fi
if [ $# -ne 0 ] && [ $1 == '--debug' ]; then INSTALL_CMD="${agentBin} -m install -api ${apiURL} -client-id ${clientID} -site-id ${siteID} -agent-type ${agentType} -auth ${token}"
INSTALL_CMD="${agentBin} -m install -api ${apiURL} -client-id ${clientID} -site-id ${siteID} -agent-type ${agentType} -auth ${token} -log debug"
else
INSTALL_CMD="${agentBin} -m install -api ${apiURL} -client-id ${clientID} -site-id ${siteID} -agent-type ${agentType} -auth ${token}"
fi
if [ "${MESH_NODE_ID}" != '' ]; then if [ "${MESH_NODE_ID}" != '' ]; then
INSTALL_CMD+=" -meshnodeid ${MESH_NODE_ID}" INSTALL_CMD+=" --meshnodeid ${MESH_NODE_ID}"
fi
if [[ $DEBUG -eq 1 ]]; then
INSTALL_CMD+=" --log debug"
fi
if [[ $INSECURE -eq 1 ]]; then
INSTALL_CMD+=" --insecure"
fi fi
if [ "${proxy}" != '' ]; then if [ "${proxy}" != '' ]; then
INSTALL_CMD+=" -proxy ${proxy}" INSTALL_CMD+=" --proxy ${proxy}"
fi fi
eval ${INSTALL_CMD} eval ${INSTALL_CMD}

View File

@@ -4,7 +4,7 @@ import os
from django.conf import settings from django.conf import settings
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from tacticalrmm.helpers import get_nats_ports from tacticalrmm.helpers import get_nats_internal_protocol, get_nats_ports
class Command(BaseCommand): class Command(BaseCommand):
@@ -21,9 +21,10 @@ class Command(BaseCommand):
ssl = "disable" ssl = "disable"
nats_std_port, _ = get_nats_ports() nats_std_port, _ = get_nats_ports()
proto = get_nats_internal_protocol()
config = { config = {
"key": settings.SECRET_KEY, "key": settings.SECRET_KEY,
"natsurl": f"tls://{settings.ALLOWED_HOSTS[0]}:{nats_std_port}", "natsurl": f"{proto}://{settings.ALLOWED_HOSTS[0]}:{nats_std_port}",
"user": db["USER"], "user": db["USER"],
"pass": db["PASSWORD"], "pass": db["PASSWORD"],
"host": db["HOST"], "host": db["HOST"],

View File

@@ -502,3 +502,27 @@ class TestCoreUtils(TacticalTestCase):
r, r,
"http://tactical-meshcentral:4443/meshagents?id=4&meshid=abc123&installflags=0", "http://tactical-meshcentral:4443/meshagents?id=4&meshid=abc123&installflags=0",
) )
@override_settings(TRMM_INSECURE=True)
def test_get_meshagent_url_insecure(self):
r = get_meshagent_url(
ident=MeshAgentIdent.DARWIN_UNIVERSAL,
plat="darwin",
mesh_site="https://mesh.example.com",
mesh_device_id="abc123",
)
self.assertEqual(
r,
"http://mesh.example.com:4430/meshagents?id=abc123&installflags=2&meshinstall=10005",
)
r = get_meshagent_url(
ident=MeshAgentIdent.WIN64,
plat="windows",
mesh_site="https://mesh.example.com",
mesh_device_id="abc123",
)
self.assertEqual(
r,
"http://mesh.example.com:4430/meshagents?id=4&meshid=abc123&installflags=0",
)

View File

@@ -88,8 +88,12 @@ def get_mesh_ws_url() -> str:
if settings.DOCKER_BUILD: if settings.DOCKER_BUILD:
uri = f"{settings.MESH_WS_URL}/control.ashx?auth={token}" uri = f"{settings.MESH_WS_URL}/control.ashx?auth={token}"
else: else:
site = core.mesh_site.replace("https", "wss") if getattr(settings, "TRMM_INSECURE", False):
uri = f"{site}/control.ashx?auth={token}" site = core.mesh_site.replace("https", "ws")
uri = f"{site}:4430/control.ashx?auth={token}"
else:
site = core.mesh_site.replace("https", "wss")
uri = f"{site}/control.ashx?auth={token}"
return uri return uri
@@ -181,6 +185,8 @@ def get_meshagent_url(
) -> str: ) -> str:
if settings.DOCKER_BUILD: if settings.DOCKER_BUILD:
base = settings.MESH_WS_URL.replace("ws://", "http://") base = settings.MESH_WS_URL.replace("ws://", "http://")
elif getattr(settings, "TRMM_INSECURE", False):
base = mesh_site.replace("https", "http") + ":4430"
else: else:
base = mesh_site base = mesh_site

View File

@@ -42,6 +42,13 @@ def get_nats_ports() -> tuple[int, int]:
return nats_standard_port, nats_websocket_port return nats_standard_port, nats_websocket_port
def get_nats_internal_protocol() -> str:
if getattr(settings, "TRMM_INSECURE", False):
return "nats"
return "tls"
def date_is_in_past(*, datetime_obj: "datetime", agent_tz: str) -> bool: def date_is_in_past(*, datetime_obj: "datetime", agent_tz: str) -> bool:
""" """
datetime_obj must be a naive datetime datetime_obj must be a naive datetime
@@ -66,8 +73,9 @@ def rand_range(min: int, max: int) -> float:
def setup_nats_options() -> dict[str, Any]: def setup_nats_options() -> dict[str, Any]:
nats_std_port, _ = get_nats_ports() nats_std_port, _ = get_nats_ports()
proto = get_nats_internal_protocol()
opts = { opts = {
"servers": f"tls://{settings.ALLOWED_HOSTS[0]}:{nats_std_port}", "servers": f"{proto}://{settings.ALLOWED_HOSTS[0]}:{nats_std_port}",
"user": "tacticalrmm", "user": "tacticalrmm",
"name": "trmm-django", "name": "trmm-django",
"password": settings.SECRET_KEY, "password": settings.SECRET_KEY,

View File

@@ -20,17 +20,17 @@ MAC_UNINSTALL = BASE_DIR / "core" / "mac_uninstall.sh"
AUTH_USER_MODEL = "accounts.User" AUTH_USER_MODEL = "accounts.User"
# latest release # latest release
TRMM_VERSION = "0.16.1" TRMM_VERSION = "0.16.4"
# https://github.com/amidaware/tacticalrmm-web # https://github.com/amidaware/tacticalrmm-web
WEB_VERSION = "0.101.28" WEB_VERSION = "0.101.29"
# bump this version everytime vue code is changed # bump this version everytime vue code is changed
# to alert user they need to manually refresh their browser # to alert user they need to manually refresh their browser
APP_VER = "0.0.183" APP_VER = "0.0.184"
# https://github.com/amidaware/rmmagent # https://github.com/amidaware/rmmagent
LATEST_AGENT_VER = "2.4.10" LATEST_AGENT_VER = "2.5.0"
MESH_VER = "1.1.9" MESH_VER = "1.1.9"

View File

@@ -34,7 +34,12 @@ from tacticalrmm.constants import (
DebugLogType, DebugLogType,
ScriptShell, ScriptShell,
) )
from tacticalrmm.helpers import get_certs, get_nats_ports, notify_error from tacticalrmm.helpers import (
get_certs,
get_nats_internal_protocol,
get_nats_ports,
notify_error,
)
def generate_winagent_exe( def generate_winagent_exe(
@@ -204,10 +209,6 @@ def reload_nats() -> None:
nats_std_port, nats_ws_port = get_nats_ports() nats_std_port, nats_ws_port = get_nats_ports()
config = { config = {
"tls": {
"cert_file": cert_file,
"key_file": key_file,
},
"authorization": {"users": users}, "authorization": {"users": users},
"max_payload": 67108864, "max_payload": 67108864,
"port": nats_std_port, # internal only "port": nats_std_port, # internal only
@@ -217,6 +218,12 @@ def reload_nats() -> None:
}, },
} }
if get_nats_internal_protocol() == "tls":
config["tls"] = {
"cert_file": cert_file,
"key_file": key_file,
}
if "NATS_HTTP_PORT" in os.environ: if "NATS_HTTP_PORT" in os.environ:
config["http_port"] = int(os.getenv("NATS_HTTP_PORT")) # type: ignore config["http_port"] = int(os.getenv("NATS_HTTP_PORT")) # type: ignore
elif hasattr(settings, "NATS_HTTP_PORT"): elif hasattr(settings, "NATS_HTTP_PORT"):

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
SCRIPT_VERSION="28" SCRIPT_VERSION="29"
GREEN='\033[0;32m' GREEN='\033[0;32m'
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
@@ -72,7 +72,7 @@ mkdir ${tmp_dir}/confd
POSTGRES_USER=$(/rmm/api/env/bin/python /rmm/api/tacticalrmm/manage.py get_config dbuser) POSTGRES_USER=$(/rmm/api/env/bin/python /rmm/api/tacticalrmm/manage.py get_config dbuser)
POSTGRES_PW=$(/rmm/api/env/bin/python /rmm/api/tacticalrmm/manage.py get_config dbpw) POSTGRES_PW=$(/rmm/api/env/bin/python /rmm/api/tacticalrmm/manage.py get_config dbpw)
pg_dump --dbname=postgresql://"${POSTGRES_USER}":"${POSTGRES_PW}"@127.0.0.1:5432/tacticalrmm | gzip -9 >${tmp_dir}/postgres/db-${dt_now}.psql.gz pg_dump --dbname=postgresql://"${POSTGRES_USER}":"${POSTGRES_PW}"@localhost:5432/tacticalrmm | gzip -9 >${tmp_dir}/postgres/db-${dt_now}.psql.gz
node /meshcentral/node_modules/meshcentral --dbexport # for import to postgres node /meshcentral/node_modules/meshcentral --dbexport # for import to postgres
@@ -82,7 +82,7 @@ if grep -q postgres "/meshcentral/meshcentral-data/config.json"; then
fi fi
MESH_POSTGRES_USER=$(jq '.settings.postgres.user' /meshcentral/meshcentral-data/config.json -r) MESH_POSTGRES_USER=$(jq '.settings.postgres.user' /meshcentral/meshcentral-data/config.json -r)
MESH_POSTGRES_PW=$(jq '.settings.postgres.password' /meshcentral/meshcentral-data/config.json -r) MESH_POSTGRES_PW=$(jq '.settings.postgres.password' /meshcentral/meshcentral-data/config.json -r)
pg_dump --dbname=postgresql://"${MESH_POSTGRES_USER}":"${MESH_POSTGRES_PW}"@127.0.0.1:5432/meshcentral | gzip -9 >${tmp_dir}/postgres/mesh-db-${dt_now}.psql.gz pg_dump --dbname=postgresql://"${MESH_POSTGRES_USER}":"${MESH_POSTGRES_PW}"@localhost:5432/meshcentral | gzip -9 >${tmp_dir}/postgres/mesh-db-${dt_now}.psql.gz
else else
mongodump --gzip --out=${tmp_dir}/meshcentral/mongo mongodump --gzip --out=${tmp_dir}/meshcentral/mongo
fi fi
@@ -101,6 +101,11 @@ if grep -q CERT_FILE "$local_settings"; then
KEY_FILE=$(grep "^KEY_FILE" "$local_settings" | awk -F'[= "]' '{print $5}') KEY_FILE=$(grep "^KEY_FILE" "$local_settings" | awk -F'[= "]' '{print $5}')
cp -p $CERT_FILE ${tmp_dir}/certs/custom/cert cp -p $CERT_FILE ${tmp_dir}/certs/custom/cert
cp -p $KEY_FILE ${tmp_dir}/certs/custom/key cp -p $KEY_FILE ${tmp_dir}/certs/custom/key
elif grep -q TRMM_INSECURE "$local_settings"; then
mkdir -p ${tmp_dir}/certs/selfsigned
certdir='/etc/ssl/tactical'
cp -p ${certdir}/key.pem ${tmp_dir}/certs/selfsigned/
cp -p ${certdir}/cert.pem ${tmp_dir}/certs/selfsigned/
fi fi
for i in rmm frontend meshcentral; do for i in rmm frontend meshcentral; do

View File

@@ -1,9 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
SCRIPT_VERSION="75" SCRIPT_VERSION="77"
SCRIPT_URL='https://raw.githubusercontent.com/amidaware/tacticalrmm/master/install.sh' SCRIPT_URL='https://raw.githubusercontent.com/amidaware/tacticalrmm/master/install.sh'
sudo apt install -y curl wget dirmngr gnupg lsb-release sudo apt install -y curl wget dirmngr gnupg lsb-release ca-certificates
GREEN='\033[0;32m' GREEN='\033[0;32m'
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
@@ -14,6 +14,7 @@ NC='\033[0m'
SCRIPTS_DIR='/opt/trmm-community-scripts' SCRIPTS_DIR='/opt/trmm-community-scripts'
PYTHON_VER='3.11.4' PYTHON_VER='3.11.4'
SETTINGS_FILE='/rmm/api/tacticalrmm/tacticalrmm/settings.py' SETTINGS_FILE='/rmm/api/tacticalrmm/tacticalrmm/settings.py'
local_settings='/rmm/api/tacticalrmm/tacticalrmm/local_settings.py'
TMP_FILE=$(mktemp -p "" "rmminstall_XXXXXXXXXX") TMP_FILE=$(mktemp -p "" "rmminstall_XXXXXXXXXX")
curl -s -L "${SCRIPT_URL}" >${TMP_FILE} curl -s -L "${SCRIPT_URL}" >${TMP_FILE}
@@ -161,19 +162,38 @@ if echo "$IPV4" | grep -qE '^(10\.|172\.1[6789]\.|172\.2[0-9]\.|172\.3[01]\.|192
BEHIND_NAT=true BEHIND_NAT=true
fi fi
insecure=false
if [[ $* == *--insecure* ]]; then
insecure=true
fi
sudo apt install -y software-properties-common sudo apt install -y software-properties-common
sudo apt update sudo apt update
sudo apt install -y certbot openssl sudo apt install -y openssl
print_green 'Getting wildcard cert' if [[ "$insecure" = true ]]; then
print_green 'Generating self-signed cert'
certdir='/etc/ssl/tactical'
sudo mkdir -p $certdir
sudo chown ${USER}:${USER} $certdir
sudo chmod 770 $certdir
CERT_PRIV_KEY=${certdir}/key.pem
CERT_PUB_KEY=${certdir}/cert.pem
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 \
-nodes -keyout ${CERT_PRIV_KEY} -out ${CERT_PUB_KEY} -subj "/CN=${rootdomain}" \
-addext "subjectAltName=DNS:${rootdomain},DNS:*.${rootdomain}"
else
sudo apt install -y certbot
print_green 'Getting wildcard cert'
sudo certbot certonly --manual -d *.${rootdomain} --agree-tos --no-bootstrap --preferred-challenges dns -m ${letsemail} --no-eff-email
while [[ $? -ne 0 ]]; do
sudo certbot certonly --manual -d *.${rootdomain} --agree-tos --no-bootstrap --preferred-challenges dns -m ${letsemail} --no-eff-email sudo certbot certonly --manual -d *.${rootdomain} --agree-tos --no-bootstrap --preferred-challenges dns -m ${letsemail} --no-eff-email
done while [[ $? -ne 0 ]]; do
sudo certbot certonly --manual -d *.${rootdomain} --agree-tos --no-bootstrap --preferred-challenges dns -m ${letsemail} --no-eff-email
CERT_PRIV_KEY=/etc/letsencrypt/live/${rootdomain}/privkey.pem done
CERT_PUB_KEY=/etc/letsencrypt/live/${rootdomain}/fullchain.pem CERT_PRIV_KEY=/etc/letsencrypt/live/${rootdomain}/privkey.pem
CERT_PUB_KEY=/etc/letsencrypt/live/${rootdomain}/fullchain.pem
fi
sudo chown ${USER}:${USER} -R /etc/letsencrypt sudo chown ${USER}:${USER} -R /etc/letsencrypt
@@ -232,7 +252,10 @@ done
print_green 'Installing NodeJS' print_green 'Installing NodeJS'
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=18
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt update sudo apt update
sudo apt install -y gcc g++ make sudo apt install -y gcc g++ make
sudo apt install -y nodejs sudo apt install -y nodejs
@@ -253,7 +276,7 @@ cd ~
sudo rm -rf Python-${PYTHON_VER} Python-${PYTHON_VER}.tgz sudo rm -rf Python-${PYTHON_VER} Python-${PYTHON_VER}.tgz
print_green 'Installing redis and git' print_green 'Installing redis and git'
sudo apt install -y ca-certificates redis git sudo apt install -y redis git
print_green 'Installing postgresql' print_green 'Installing postgresql'
@@ -336,9 +359,23 @@ MESH_VER=$(grep "^MESH_VER" "$SETTINGS_FILE" | awk -F'[= "]' '{print $5}')
sudo mkdir -p /meshcentral/meshcentral-data sudo mkdir -p /meshcentral/meshcentral-data
sudo chown ${USER}:${USER} -R /meshcentral sudo chown ${USER}:${USER} -R /meshcentral
cd /meshcentral cd /meshcentral
npm install meshcentral@${MESH_VER}
sudo chown ${USER}:${USER} -R /meshcentral sudo chown ${USER}:${USER} -R /meshcentral
mesh_pkg="$(
cat <<EOF
{
"dependencies": {
"archiver": "5.3.1",
"meshcentral": "${MESH_VER}",
"otplib": "10.2.3",
"pg": "8.7.1",
"pgtools": "0.3.2"
}
}
EOF
)"
echo "${mesh_pkg}" >/meshcentral/package.json
meshcfg="$( meshcfg="$(
cat <<EOF cat <<EOF
{ {
@@ -382,6 +419,8 @@ EOF
)" )"
echo "${meshcfg}" >/meshcentral/meshcentral-data/config.json echo "${meshcfg}" >/meshcentral/meshcentral-data/config.json
npm install
localvars="$( localvars="$(
cat <<EOF cat <<EOF
SECRET_KEY = "${DJANGO_SEKRET}" SECRET_KEY = "${DJANGO_SEKRET}"
@@ -413,7 +452,11 @@ REDIS_HOST = "localhost"
ADMIN_ENABLED = True ADMIN_ENABLED = True
EOF EOF
)" )"
echo "${localvars}" >/rmm/api/tacticalrmm/tacticalrmm/local_settings.py echo "${localvars}" >$local_settings
if [[ "$insecure" = true ]]; then
echo "TRMM_INSECURE = True" | tee --append $local_settings >/dev/null
fi
if [ "$arch" = "x86_64" ]; then if [ "$arch" = "x86_64" ]; then
natsapi='nats-api' natsapi='nats-api'
@@ -446,7 +489,7 @@ python manage.py load_community_scripts
WEB_VERSION=$(python manage.py get_config webversion) WEB_VERSION=$(python manage.py get_config webversion)
printf >&2 "${YELLOW}%0.s*${NC}" {1..80} printf >&2 "${YELLOW}%0.s*${NC}" {1..80}
printf >&2 "\n" printf >&2 "\n"
printf >&2 "${YELLOW}Please create your login for the RMM website and django admin${NC}\n" printf >&2 "${YELLOW}Please create your login for the RMM website${NC}\n"
printf >&2 "${YELLOW}%0.s*${NC}" {1..80} printf >&2 "${YELLOW}%0.s*${NC}" {1..80}
printf >&2 "\n" printf >&2 "\n"
echo -ne "Username: " echo -ne "Username: "
@@ -856,7 +899,7 @@ done
sleep 5 sleep 5
sudo systemctl enable meshcentral sudo systemctl enable meshcentral
print_green 'Starting meshcentral and waiting for it to install plugins' print_green 'Starting meshcentral and waiting for it to be ready'
sudo systemctl restart meshcentral sudo systemctl restart meshcentral
@@ -880,7 +923,7 @@ meshtoken="$(
MESH_TOKEN_KEY = "${MESHTOKENKEY}" MESH_TOKEN_KEY = "${MESHTOKENKEY}"
EOF EOF
)" )"
echo "${meshtoken}" | tee --append /rmm/api/tacticalrmm/tacticalrmm/local_settings.py >/dev/null echo "${meshtoken}" | tee --append $local_settings >/dev/null
print_green 'Creating meshcentral account and group' print_green 'Creating meshcentral account and group'
@@ -917,7 +960,7 @@ sudo systemctl enable nats-api.service
sudo systemctl start nats-api.service sudo systemctl start nats-api.service
## disable django admin ## disable django admin
sed -i 's/ADMIN_ENABLED = True/ADMIN_ENABLED = False/g' /rmm/api/tacticalrmm/tacticalrmm/local_settings.py sed -i 's/ADMIN_ENABLED = True/ADMIN_ENABLED = False/g' $local_settings
print_green 'Restarting services' print_green 'Restarting services'
for i in rmm.service daphne.service celery.service celerybeat.service; do for i in rmm.service daphne.service celery.service celerybeat.service; do
@@ -929,7 +972,6 @@ printf >&2 "${YELLOW}%0.s*${NC}" {1..80}
printf >&2 "\n\n" printf >&2 "\n\n"
printf >&2 "${YELLOW}Installation complete!${NC}\n\n" printf >&2 "${YELLOW}Installation complete!${NC}\n\n"
printf >&2 "${YELLOW}Access your rmm at: ${GREEN}https://${frontenddomain}${NC}\n\n" printf >&2 "${YELLOW}Access your rmm at: ${GREEN}https://${frontenddomain}${NC}\n\n"
printf >&2 "${YELLOW}Django admin url (disabled by default): ${GREEN}https://${rmmdomain}/${ADMINURL}/${NC}\n\n"
printf >&2 "${YELLOW}MeshCentral username: ${GREEN}${meshusername}${NC}\n" printf >&2 "${YELLOW}MeshCentral username: ${GREEN}${meshusername}${NC}\n"
printf >&2 "${YELLOW}MeshCentral password: ${GREEN}${MESHPASSWD}${NC}\n\n" printf >&2 "${YELLOW}MeshCentral password: ${GREEN}${MESHPASSWD}${NC}\n\n"

View File

@@ -1,10 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
SCRIPT_VERSION="50" SCRIPT_VERSION="52"
SCRIPT_URL='https://raw.githubusercontent.com/amidaware/tacticalrmm/master/restore.sh' SCRIPT_URL='https://raw.githubusercontent.com/amidaware/tacticalrmm/master/restore.sh'
sudo apt update sudo apt update
sudo apt install -y curl wget dirmngr gnupg lsb-release sudo apt install -y curl wget dirmngr gnupg lsb-release ca-certificates
GREEN='\033[0;32m' GREEN='\033[0;32m'
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
@@ -122,7 +122,10 @@ sudo apt update
print_green 'Installing NodeJS' print_green 'Installing NodeJS'
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=18
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt update sudo apt update
sudo apt install -y gcc g++ make sudo apt install -y gcc g++ make
sudo apt install -y nodejs sudo apt install -y nodejs
@@ -209,7 +212,13 @@ if [ -d "${tmp_dir}/certs/custom" ]; then
cp -p ${tmp_dir}/certs/custom/cert $CERT_FILE cp -p ${tmp_dir}/certs/custom/cert $CERT_FILE
cp -p ${tmp_dir}/certs/custom/key $KEY_FILE cp -p ${tmp_dir}/certs/custom/key $KEY_FILE
elif [ -d "${tmp_dir}/certs/selfsigned" ]; then
certdir='/etc/ssl/tactical'
sudo mkdir -p $certdir
sudo chown ${USER}:${USER} $certdir
sudo chmod 770 $certdir
cp -p ${tmp_dir}/certs/selfsigned/key.pem $certdir
cp -p ${tmp_dir}/certs/selfsigned/cert.pem $certdir
fi fi
print_green 'Restoring celery configs' print_green 'Restoring celery configs'
@@ -238,7 +247,7 @@ cd ~
sudo rm -rf Python-${PYTHON_VER} Python-${PYTHON_VER}.tgz sudo rm -rf Python-${PYTHON_VER} Python-${PYTHON_VER}.tgz
print_green 'Installing redis and git' print_green 'Installing redis and git'
sudo apt install -y ca-certificates redis git sudo apt install -y redis git
print_green 'Installing postgresql' print_green 'Installing postgresql'
@@ -349,7 +358,21 @@ else
fi fi
cd /meshcentral cd /meshcentral
npm install meshcentral@${MESH_VER} mesh_pkg="$(
cat <<EOF
{
"dependencies": {
"archiver": "5.3.1",
"meshcentral": "${MESH_VER}",
"otplib": "10.2.3",
"pg": "8.7.1",
"pgtools": "0.3.2"
}
}
EOF
)"
echo "${mesh_pkg}" >/meshcentral/package.json
npm install
if [ "$FROM_MONGO" = true ]; then if [ "$FROM_MONGO" = true ]; then
node node_modules/meshcentral --dbimport >/dev/null node node_modules/meshcentral --dbimport >/dev/null

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
SCRIPT_VERSION="146" SCRIPT_VERSION="147"
SCRIPT_URL='https://raw.githubusercontent.com/amidaware/tacticalrmm/master/update.sh' SCRIPT_URL='https://raw.githubusercontent.com/amidaware/tacticalrmm/master/update.sh'
LATEST_SETTINGS_URL='https://raw.githubusercontent.com/amidaware/tacticalrmm/master/api/tacticalrmm/tacticalrmm/settings.py' LATEST_SETTINGS_URL='https://raw.githubusercontent.com/amidaware/tacticalrmm/master/api/tacticalrmm/tacticalrmm/settings.py'
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
@@ -407,8 +407,22 @@ if [[ "${CURRENT_MESH_VER}" != "${LATEST_MESH_VER}" ]] || [[ "$force" = true ]];
sudo systemctl stop meshcentral sudo systemctl stop meshcentral
sudo chown ${USER}:${USER} -R /meshcentral sudo chown ${USER}:${USER} -R /meshcentral
cd /meshcentral cd /meshcentral
rm -rf node_modules/ rm -rf node_modules/ package.json package-lock.json
npm install meshcentral@${LATEST_MESH_VER} mesh_pkg="$(
cat <<EOF
{
"dependencies": {
"archiver": "5.3.1",
"meshcentral": "${LATEST_MESH_VER}",
"otplib": "10.2.3",
"pg": "8.7.1",
"pgtools": "0.3.2"
}
}
EOF
)"
echo "${mesh_pkg}" >/meshcentral/package.json
npm install
sudo systemctl start meshcentral sudo systemctl start meshcentral
fi fi