Skip to content

Commit

Permalink
Release 0.4.14
Browse files Browse the repository at this point in the history
  • Loading branch information
wh1te909 committed Feb 20, 2021
2 parents a11616a + f45938b commit 8097c68
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 12 deletions.
1 change: 0 additions & 1 deletion api/tacticalrmm/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from rest_framework.response import Response
from rest_framework.views import APIView

from agents.models import Agent
from logs.models import AuditLog
from tacticalrmm.utils import notify_error

Expand Down
10 changes: 8 additions & 2 deletions api/tacticalrmm/agents/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,17 @@ def handle_agent_recovery_task(pk: int) -> None:

@app.task
def run_script_email_results_task(
agentpk: int, scriptpk: int, nats_timeout: int, emails: List[str]
agentpk: int,
scriptpk: int,
nats_timeout: int,
emails: List[str],
args: List[str] = [],
):
agent = Agent.objects.get(pk=agentpk)
script = Script.objects.get(pk=scriptpk)
r = agent.run_script(scriptpk=script.pk, full=True, timeout=nats_timeout, wait=True)
r = agent.run_script(
scriptpk=script.pk, args=args, full=True, timeout=nats_timeout, wait=True
)
if r == "timeout":
logger.error(f"{agent.hostname} timed out running script.")
return
Expand Down
8 changes: 6 additions & 2 deletions api/tacticalrmm/agents/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ def run_script(request):
return notify_error("Requires agent version 1.1.0 or greater")
script = get_object_or_404(Script, pk=request.data["scriptPK"])
output = request.data["output"]
args = request.data["args"]
req_timeout = int(request.data["timeout"]) + 3

AuditLog.audit_script_run(
Expand All @@ -694,7 +695,9 @@ def run_script(request):
)

if output == "wait":
r = agent.run_script(scriptpk=script.pk, timeout=req_timeout, wait=True)
r = agent.run_script(
scriptpk=script.pk, args=args, timeout=req_timeout, wait=True
)
return Response(r)

elif output == "email":
Expand All @@ -709,9 +712,10 @@ def run_script(request):
scriptpk=script.pk,
nats_timeout=req_timeout,
emails=emails,
args=args,
)
else:
agent.run_script(scriptpk=script.pk, timeout=req_timeout)
agent.run_script(scriptpk=script.pk, args=args, timeout=req_timeout)

return Response(f"{script.name} will now be run on {agent.hostname}")

Expand Down
2 changes: 1 addition & 1 deletion api/tacticalrmm/core/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_ui_maintenance_actions(self, remove_orphaned_win_tasks, reload_nats):
# test prune db with tables
data = {
"action": "prune_db",
"prune_tables": ["audit_logs", "agent_outages", "pending_actions"],
"prune_tables": ["audit_logs", "alerts", "pending_actions"],
}
r = self.client.post(url, data)
self.assertEqual(r.status_code, 200)
Expand Down
7 changes: 7 additions & 0 deletions api/tacticalrmm/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ def server_maintenance(request):
records_count += pendingactions.count()
pendingactions.delete()

if "alerts" in tables:
from alerts.models import Alert

alerts = Alert.objects.all()
records_count += alerts.count()
alerts.delete()

return Response(f"{records_count} records were pruned from the database")

return notify_error("The data is incorrect")
2 changes: 1 addition & 1 deletion api/tacticalrmm/tacticalrmm/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
AUTH_USER_MODEL = "accounts.User"

# latest release
TRMM_VERSION = "0.4.13"
TRMM_VERSION = "0.4.14"

# bump this version everytime vue code is changed
# to alert user they need to manually refresh their browser
Expand Down
12 changes: 7 additions & 5 deletions update.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

SCRIPT_VERSION="108"
SCRIPT_VERSION="109"
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'
Expand Down Expand Up @@ -114,10 +114,12 @@ SETTINGS_FILE="/rmm/api/tacticalrmm/tacticalrmm/settings.py"
LATEST_TRMM_VER=$(grep "^TRMM_VERSION" "$TMP_SETTINGS" | awk -F'[= "]' '{print $5}')
CURRENT_TRMM_VER=$(grep "^TRMM_VERSION" "$SETTINGS_FILE" | awk -F'[= "]' '{print $5}')

if [[ "${CURRENT_TRMM_VER}" == "${LATEST_TRMM_VER}" ]]; then
printf >&2 "${GREEN}Already on latest version. Current version: ${CURRENT_TRMM_VER} Latest version: ${LATEST_TRMM_VER}${NC}\n"
rm -f $TMP_SETTINGS
exit 0
if [[ $* != *--force* ]]; then
if [[ "${CURRENT_TRMM_VER}" == "${LATEST_TRMM_VER}" ]]; then
printf >&2 "${GREEN}Already on latest version. Current version: ${CURRENT_TRMM_VER} Latest version: ${LATEST_TRMM_VER}${NC}\n"
rm -f $TMP_SETTINGS
exit 0
fi
fi

LATEST_MESH_VER=$(grep "^MESH_VER" "$TMP_SETTINGS" | awk -F'[= "]' '{print $5}')
Expand Down
3 changes: 3 additions & 0 deletions web/src/components/modals/core/ServerMaintenance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<q-checkbox v-model="prune_tables" val="pending_actions" label="Pending Actions">
<q-tooltip>Removes completed pending actions</q-tooltip>
</q-checkbox>
<q-checkbox v-model="prune_tables" val="alerts" label="Alerts">
<q-tooltip>Removes all alerts</q-tooltip>
</q-checkbox>
</q-card-section>

<q-card-actions align="left">
Expand Down

0 comments on commit 8097c68

Please sign in to comment.