|
| 1 | +#!/usr/bin/env bash |
| 2 | +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) |
| 3 | +# Copyright (c) 2021-2025 community-scripts ORG |
| 4 | +# Author: MickLesk (CanbiZ) |
| 5 | +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE |
| 6 | +# Source: https://nxvms.com/download/releases/linux |
| 7 | + |
| 8 | +APP="NxWitness" |
| 9 | +var_tags="nvr" |
| 10 | +var_cpu="2" |
| 11 | +var_ram="2048" |
| 12 | +var_disk="8" |
| 13 | +var_os="ubuntu" |
| 14 | +var_version="24.04" |
| 15 | +var_unprivileged="0" |
| 16 | + |
| 17 | +header_info "$APP" |
| 18 | +variables |
| 19 | +color |
| 20 | +catch_errors |
| 21 | + |
| 22 | +function update_script() { |
| 23 | + header_info |
| 24 | + check_container_storage |
| 25 | + check_container_resources |
| 26 | + if [[ ! -f /etc/systemd/system/networkoptix-mediaserver.service ]]; then |
| 27 | + msg_error "No ${APP} Installation Found!" |
| 28 | + exit |
| 29 | + fi |
| 30 | + BASE_URL="https://updates.networkoptix.com/default/index.html" |
| 31 | + RELEASE=$(curl -s "$BASE_URL" | grep -oP '(?<=<b>)[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(?=</b>)' | head -n 1) |
| 32 | + DETAIL_PAGE=$(curl -s "$BASE_URL#note_$RELEASE") |
| 33 | + DOWNLOAD_URL=$(echo "$DETAIL_PAGE" | grep -oP "https://updates.networkoptix.com/default/$RELEASE/linux/nxwitness-server-[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+-linux_x64\.deb" | head -n 1) |
| 34 | + if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then |
| 35 | + msg_info "Stopping ${APP}" |
| 36 | + systemctl stop networkoptix-root-tool networkoptix-mediaserver |
| 37 | + msg_ok "${APP} Stopped" |
| 38 | + |
| 39 | + msg_info "Updating ${APP} to ${RELEASE}" |
| 40 | + cd /tmp |
| 41 | + wget -q "$DOWNLOAD_URL" -O "nxwitness-server-$RELEASE-linux_x64.deb" |
| 42 | + export DEBIAN_FRONTEND=noninteractive |
| 43 | + export DEBCONF_NOWARNINGS=yes |
| 44 | + dpkg -i nxwitness-server-$RELEASE-linux_x64.deb >/dev/null 2>&1 |
| 45 | + echo "${RELEASE}" >/opt/${APP}_version.txt |
| 46 | + msg_ok "Updated ${APP}" |
| 47 | + |
| 48 | + msg_info "Starting ${APP}" |
| 49 | + systemctl start networkoptix-root-tool networkoptix-mediaserver |
| 50 | + msg_ok "Started ${APP}" |
| 51 | + |
| 52 | + msg_info "Cleaning up" |
| 53 | + rm -f /tmp/nxwitness-server-$RELEASE-linux_x64.deb |
| 54 | + msg_ok "Cleaned" |
| 55 | + |
| 56 | + msg_ok "Updated Successfully" |
| 57 | + else |
| 58 | + msg_ok "No update required. ${APP} is already at ${RELEASE}" |
| 59 | + fi |
| 60 | + exit |
| 61 | +} |
| 62 | + |
| 63 | +start |
| 64 | +build_container |
| 65 | +description |
| 66 | + |
| 67 | +msg_ok "Completed Successfully!\n" |
| 68 | +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" |
| 69 | +echo -e "${INFO}${YW} Access it using the following URL:${CL}" |
| 70 | +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:7001/${CL}" |
0 commit comments