add version

This commit is contained in:
wh1te909 2020-11-01 09:18:22 +00:00
parent a606f0c315
commit 06a69045bc
9 changed files with 124 additions and 35 deletions

View File

@ -6,3 +6,24 @@ class TestCoreTasks(BaseTestCase):
def test_core_maintenance_tasks(self):
task = core_maintenance_tasks.s().apply()
self.assertEqual(task.state, "SUCCESS")
def test_dashboard_info(self):
url = "/core/dashinfo/"
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
self.check_not_authenticated("get", url)
def test_vue_version(self):
url = "/core/version/"
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
self.check_not_authenticated("get", url)
def test_get_core_settings(self):
url = "/core/getcoresettings/"
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
self.check_not_authenticated("get", url)

View File

@ -7,4 +7,5 @@ urlpatterns = [
path("editsettings/", views.edit_settings),
path("version/", views.version),
path("emailtest/", views.email_test),
path("dashinfo/", views.dashboard_info),
]

View File

@ -66,6 +66,11 @@ def version(request):
return Response(settings.APP_VER)
@api_view()
def dashboard_info(request):
return Response({"trmm_version": settings.TRMM_VERSION})
@api_view()
def email_test(request):
core = CoreSettings.objects.first()

View File

@ -9,15 +9,25 @@ EXE_DIR = os.path.join(BASE_DIR, "tacticalrmm/private/exe")
AUTH_USER_MODEL = "accounts.User"
# latest release
TRMM_VERSION = "0.1.0"
# bump this version everytime vue code is changed
# to alert user they need to manually refresh their browser
APP_VER = "0.0.83"
APP_VER = "0.0.84"
# https://github.com/wh1te909/salt
LATEST_SALT_VER = "1.1.0"
# https://github.com/wh1te909/rmmagent
LATEST_AGENT_VER = "1.0.1"
MESH_VER = "0.6.62"
# for the update script, bump when need to recreate venv or npm install
PIP_VER = "1"
NPM_VER = "1"
DL_64 = f"https://github.com/wh1te909/rmmagent/releases/download/v{LATEST_AGENT_VER}/winagent-v{LATEST_AGENT_VER}.exe"
DL_32 = f"https://github.com/wh1te909/rmmagent/releases/download/v{LATEST_AGENT_VER}/winagent-v{LATEST_AGENT_VER}-x86.exe"

View File

@ -1,6 +1,6 @@
#!/bin/bash
SCRIPT_VERSION="16"
SCRIPT_VERSION="17"
SCRIPT_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/develop/install.sh'
GREEN='\033[0;32m'
@ -282,6 +282,8 @@ sudo chown ${USER}:${USER} /rmm
sudo mkdir -p /var/log/celery
sudo chown ${USER}:${USER} /var/log/celery
git clone https://github.com/wh1te909/tacticalrmm.git /rmm/
cd /rmm
git checkout master
localvars="$(cat << EOF
SECRET_KEY = "${DJANGO_SEKRET}"

View File

@ -7,7 +7,7 @@ pgpw="hunter2"
#####################################################
SCRIPT_VERSION="4"
SCRIPT_VERSION="5"
SCRIPT_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/develop/restore.sh'
GREEN='\033[0;32m'
@ -212,6 +212,8 @@ sudo chown ${USER}:${USER} /rmm
sudo mkdir -p /var/log/celery
sudo chown ${USER}:${USER} /var/log/celery
git clone https://github.com/wh1te909/tacticalrmm.git /rmm/
cd /rmm
git checkout master
cp $tmp_dir/rmm/local_settings.py /rmm/api/tacticalrmm/tacticalrmm/
cp $tmp_dir/rmm/env /rmm/web/.env

View File

@ -1,7 +1,8 @@
#!/bin/bash
SCRIPT_VERSION="93"
SCRIPT_VERSION="94"
SCRIPT_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/develop/update.sh'
LATEST_SETTINGS_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/api/tacticalrmm/tacticalrmm/settings.py'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
RED='\033[0;31m'
@ -33,6 +34,38 @@ if [ "$ORIGUSER" != "$USER" ]; then
exit 1
fi
TMP_SETTINGS=$(mktemp -p "" "rmmsettings_XXXXXXXXXX")
curl -s -L "${LATEST_SETTINGS_URL}" > ${TMP_SETTINGS}
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
fi
LATEST_MESH_VER=$(grep "^MESH_VER" "$TMP_SETTINGS" | awk -F'[= "]' '{print $5}')
LATEST_PIP_VER=$(grep "^PIP_VER" "$TMP_SETTINGS" | awk -F'[= "]' '{print $5}')
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 rmm celery celerybeat celery-winupdate
do
sudo systemctl stop ${i}
done
cd /rmm
git fetch
git checkout master
git reset --hard FETCH_HEAD
git clean -df
git pull
# added new celery queue 9-7-2020
if [ ! -f /etc/systemd/system/celery-winupdate.service ]; then
celerywinupdatesvc="$(cat << EOF
@ -79,13 +112,6 @@ sudo systemctl daemon-reload
sudo systemctl enable celery-winupdate
fi
for i in celery celerybeat celery-winupdate rmm nginx
do
sudo systemctl stop ${i}
done
sudo chown ${USER}:${USER} -R /rmm
sudo chown ${USER}:${USER} /var/log/celery
sudo chown ${USER}:${USER} -R /srv/salt/
@ -96,24 +122,27 @@ sudo chown -R $USER:$GROUP /home/${USER}/.config
sudo chown -R $USER:$GROUP /home/${USER}/.cache
sudo chmod 750 /srv/salt/scripts/userdefined
cd /rmm
git fetch origin develop
git reset --hard FETCH_HEAD
git clean -df
cp /rmm/_modules/* /srv/salt/_modules/
cp /rmm/scripts/* /srv/salt/scripts/
/usr/local/rmmgo/go/bin/go get github.com/josephspurrier/goversioninfo/cmd/goversioninfo
sudo cp /rmm/api/tacticalrmm/core/goinstaller/bin/goversioninfo /usr/local/bin/
sudo chown ${USER}:${USER} /usr/local/bin/goversioninfo
sudo chmod +x /usr/local/bin/goversioninfo
rm -rf /rmm/api/env
cd /rmm/api
python3 -m venv env
source /rmm/api/env/bin/activate
cd /rmm/api/tacticalrmm
pip install --no-cache-dir --upgrade pip
pip install --no-cache-dir setuptools==49.6.0 wheel==0.35.1
pip install --no-cache-dir -r requirements.txt
if [[ "${CURRENT_PIP_VER}" != "${LATEST_PIP_VER}" ]]; then
rm -rf /rmm/api/env
cd /rmm/api
python3 -m venv env
source /rmm/api/env/bin/activate
cd /rmm/api/tacticalrmm
pip install --no-cache-dir --upgrade pip
pip install --no-cache-dir setuptools==49.6.0 wheel==0.35.1
pip install --no-cache-dir -r requirements.txt
else
source /rmm/api/env/bin/activate
cd /rmm/api/tacticalrmm
fi
python manage.py pre_update_tasks
python manage.py migrate
python manage.py delete_tokens
@ -122,14 +151,16 @@ python manage.py collectstatic --no-input
python manage.py post_update_tasks
deactivate
rm -rf /rmm/web/node_modules
rm -rf /rmm/web/dist
cd /rmm/web
npm install
if [[ "${CURRENT_NPM_VER}" != "${LATEST_NPM_VER}" ]]; then
rm -rf /rmm/web/node_modules
npm install
fi
npm run build
sudo rm -rf /var/www/rmm/dist
sudo cp -pvr /rmm/web/dist /var/www/rmm/
sudo cp -pr /rmm/web/dist /var/www/rmm/
sudo chown www-data:www-data -R /var/www/rmm/dist
for i in celery celerybeat celery-winupdate rmm nginx
@ -137,12 +168,17 @@ do
sudo systemctl start ${i}
done
sudo systemctl stop meshcentral
sudo chown ${USER}:${USER} -R /meshcentral
cd /meshcentral
rm -rf node_modules/
npm install meshcentral@0.6.62
sudo systemctl start meshcentral
sleep 10
CURRENT_MESH_VER=$(cd /meshcentral && npm list meshcentral | grep 'meshcentral@' | awk -F'[@]' '{print $2}' | tr -d " \t")
if [[ "${CURRENT_MESH_VER}" != "${LATEST_MESH_VER}" ]]; then
printf >&2 "${GREEN}Updating meshcentral from ${CURRENT_MESH_VER} to ${LATEST_MESH_VER}${NC}\n"
sudo systemctl stop meshcentral
sudo chown ${USER}:${USER} -R /meshcentral
cd /meshcentral
rm -rf node_modules/
npm install meshcentral@${LATEST_MESH_VER}
sudo systemctl start meshcentral
sleep 10
fi
rm -f $TMP_SETTINGS
printf >&2 "${GREEN}Update finished!${NC}\n"

View File

@ -153,6 +153,9 @@ export default function () {
getAgentCounts(context, data = {}) {
return axios.post("/agents/agent_counts/", data)
},
getDashInfo(context) {
return axios.get("/core/dashinfo/");
},
loadAutomatedTasks(context, pk) {
axios.get(`/tasks/${pk}/automatedtasks/`).then(r => {
context.commit("SET_AUTOMATED_TASKS", r.data);

View File

@ -7,7 +7,9 @@
</q-banner>
<q-toolbar>
<q-btn dense flat push @click="refreshEntireSite" icon="refresh" />
<q-toolbar-title>Tactical RMM</q-toolbar-title>
<q-toolbar-title
>Tactical RMM<span class="text-overline">&nbsp;&nbsp;&nbsp;v{{ currentTRMMVersion }}</span></q-toolbar-title
>
<!-- Devices Chip -->
<q-chip color="white" class="cursor-pointer">
@ -265,6 +267,7 @@ export default {
frame: [],
poll: null,
search: null,
currentTRMMVersion: null,
columns: [
{
name: "smsalert",
@ -369,6 +372,7 @@ export default {
methods: {
refreshEntireSite() {
this.$store.dispatch("loadTree");
this.getDashInfo();
this.getAgentCounts();
if (this.allClientsActive) {
@ -468,6 +472,7 @@ export default {
this.poll = setInterval(() => {
this.$store.dispatch("checkVer");
this.getAgentCounts();
this.getDashInfo();
}, 60 * 5 * 1000);
},
setSplitter(val) {
@ -481,6 +486,9 @@ export default {
this.workstationOfflineCount = r.data.total_workstation_offline_count;
});
},
getDashInfo() {
this.$store.dispatch("getDashInfo").then(r => (this.currentTRMMVersion = r.data.trmm_version));
},
showToggleMaintenance(node) {
let data = {
id: node.id,
@ -537,6 +545,7 @@ export default {
this.getTree();
this.$store.dispatch("getUpdatedSites");
this.$store.dispatch("checkVer");
this.getDashInfo();
this.getAgentCounts();
},
mounted() {