diff --git a/ct/zoneminder.sh b/ct/zoneminder.sh new file mode 100644 index 00000000..221457f7 --- /dev/null +++ b/ct/zoneminder.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2024 community-scripts ORG +# Author: [YourUserName] +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: [SOURCE_URL] + +# App Default Values +APP="ZoneMinder" +# Name of the app (e.g. Google, Adventurelog, Apache-Guacamole) +var_tags="nvr" +# Tags for Proxmox VE, maximum 2 pcs., no spaces allowed, separated by a semicolon ; (e.g. database | adblock;dhcp) +var_cpu="2" +# Number of cores (1-X) (e.g. 4) - default is 2 +var_ram="2048" +# Amount of used RAM in MB (e.g. 2048 or 4096) +var_disk="16" +# Amount of used disk space in GB (e.g. 4 or 10) +var_os="ubuntu" +# Default OS (e.g. debian, ubuntu, alpine) +var_version="22.04" +# Default OS version (e.g. 12 for debian, 24.04 for ubuntu, 3.20 for alpine) +var_unprivileged="1" +# 1 = unprivileged container, 0 = privileged container + +# App Output & Base Settings +header_info "$APP" +base_settings + +# Core +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + # Check if installation is present | -f for file, -d for folder + # We assume zmpkg.pl is present if ZoneMinder was installed + if [[ ! -f /usr/bin/zmpkg.pl ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + # Get the latest available release tag from GitHub + # NOTE: The container must have 'grep' available (which is standard). + RELEASE=$(curl -fsSL https://api.github.com/repos/ZoneMinder/zoneminder/releases/latest | grep -Po '"tag_name": "\K.*?(?=")') + if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt 2>/dev/null || echo 'none')" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + msg_info "Updating $APP" + + # Stopping Services + msg_info "Stopping $APP" + systemctl stop zoneminder + msg_ok "Stopped $APP" + + # Creating Backup + # Adjust paths as needed for your environment + msg_info "Creating Backup" + tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /etc/zm /usr/share/zoneminder /var/cache/zoneminder + msg_ok "Backup Created" + + # Execute Update (apt-based) + msg_info "Updating $APP to v${RELEASE}" + apt-get update && apt-get install --only-upgrade zoneminder -y + msg_ok "Updated $APP to v${RELEASE}" + + # Starting Services + msg_info "Starting $APP" + systemctl start zoneminder + sleep 2 + msg_ok "Started $APP" + + # Cleaning up + msg_info "Cleaning Up" + rm -rf /tmp/zoneminder-update + msg_ok "Cleanup Completed" + + # Write out the new version + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Update Successful" + else + msg_ok "No update required. ${APP} is already at v${RELEASE}" + fi + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:80/zm${CL}" diff --git a/install/zoneminder-install.sh b/install/zoneminder-install.sh new file mode 100644 index 00000000..bc613549 --- /dev/null +++ b/install/zoneminder-install.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 community-scripts ORG +# Author: [YourUserName] +# License: MIT +# Source: [SOURCE_URL] + +# Import Functions und Setup +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +# Installing Dependencies with the 3 core dependencies (curl;sudo;mc) +# plus any additional packages you need +msg_info "Installing Dependencies" +$STD apt-get install -y \ + curl \ + sudo \ + mc \ + apache2 \ + mariadb-server \ + libapache2-mod-php +msg_ok "Installed Dependencies" + +# create a random password for root +# create a random password for the 'zmuser' +msg_info "Pre-seeding dbconfig-common for ZoneMinder" + +ROOT_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) +ZMPASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) + +export DEBIAN_FRONTEND=noninteractive + +echo "zoneminder zoneminder/dbconfig-install boolean true" | debconf-set-selections +echo "zoneminder zoneminder/dbconfig-reinstall boolean false" | debconf-set-selections +echo "zoneminder zoneminder/mysql/admin-user string root" | debconf-set-selections +echo "zoneminder zoneminder/mysql/admin-pass password $ROOT_PASS" | debconf-set-selections +echo "zoneminder zoneminder/mysql/app-pass password $ZMPASS" | debconf-set-selections +echo "zoneminder zoneminder/app-password-confirm password $ZMPASS"| debconf-set-selections + +{ + echo "ZoneMinder Database Credentials" + echo "MySQL Root Password: $ROOT_PASS" + echo "ZoneMinder DB User: zmuser" + echo "ZoneMinder DB Pass: $ZMPASS" + echo "ZoneMinder DB Name: zm" +} >> ~/zoneminder.creds +msg_ok "dbconfig pre-seeding complete" + +# Enable the ZoneMinder PPA (iconnor/zoneminder-1.36) and install +msg_info "Enabling ZoneMinder PPA and installing ZoneMinder" +$STD apt install -y software-properties-common +$STD add-apt-repository ppa:iconnor/zoneminder-1.36 -y +$STD apt update +$STD apt-get install -y zoneminder +msg_ok "ZoneMinder installed" + +# Enable Apache modules & ZoneMinder service +msg_info "Configuring Apache and ZoneMinder" +a2enmod rewrite +a2enconf zoneminder +systemctl restart apache2 +systemctl enable zoneminder +systemctl start zoneminder +msg_ok "Apache and ZoneMinder configured and running" + +# Cleanup +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/json/zoneminder.json b/json/zoneminder.json new file mode 100644 index 00000000..0609b791 --- /dev/null +++ b/json/zoneminder.json @@ -0,0 +1,34 @@ +{ + "name": "ZoneMinder", + "slug": "zoneminder", + "categories": [ + 15 + ], + "date_created": "2025-01-21", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 80, + "documentation": null, + "website": "https://zoneminder.com", + "logo": "https://raw.githubusercontent.com/ZoneMinder/ZoneMinder/master/web/graphics/icon_zoneminder.png", + "description": "ZoneMinder is an open source video surveillance solution for Linux.", + "install_methods": [ + { + "type": "default", + "script": "ct/ZoneMinder.sh", + "resources": { + "cpu": 2, + "ram": 2048, + "hdd": 16, + "os": "ubuntu", + "version": "22.04" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [] +}