#!/bin/bash set -eu # Check if apache class is set and activate apache modules that will be needed grep -q '^apache' /etc/dsv/computed_classes || { echo "Please set the apache class"; exit 1; } a2enmod rewrite proxy proxy_http proxy_wstunnel # Check if mariadb class is set grep -q '^mariadb' /etc/dsv/computed_classes || { echo "Please set the apache class"; exit 1; } # Set up variables that will be needed proj_name="proxmox-web-portal" #proj_dir="$(cd "$(dirname "$0")" && pwd)" proj_dir="$(pwd)" service_file="/etc/systemd/system/${proj_name}.service" log_dir="/var/log/${proj_name}" log_rotate="/etc/logrotate.d/${proj_name}" db_path="${proj_dir}/app.db" schema_path="${proj_dir}/schema.sql" # Set up log directory with permissions along with logrotate mkdir -p "$log_dir" chown www-data:www-data "$log_dir" chmod 755 "$log_dir" touch "$log_rotate" cat < "$log_rotate" ${log_dir}/*.log { daily missingok rotate 14 compress delaycompress notifempty create 0640 www-data www-data sharedscripts postrotate systemctl restart ${proj_name} > /dev/null 2>&1 || true endscript } EOL # Make sure curl is installed apt update -y apt install -y curl # Set up nodejs curl -fsSL https://deb.nodesource.com/setup_23.x -o nodesource_setup.sh | bash - apt install -y nodejs npm # Set up sqlite apt install -y sqlite3 sqlite3 "$db_path" < "$schema_path" # Go to project directory and set up the rest cd "$proj_dir" npm ci cp config.ini.example config.ini # Get the novnc repo git submodule update --init --recursive # Create systemd service touch "$service_file" cat <"$service_file" [Unit] Description=Proxmox Web Portal After=network.target [Service] Environment=NODE_ENV=test WorkingDirectory=${proj_dir} ExecStart=/usr/bin/node ${proj_dir}/server.js Restart=always RestartSec=10 User=www-data Group=www-data StandardOutput=append:${log_dir}/output.log StandardError=append:${log_dir}/error.log [Install] WantedBy=multi-user.target EOL echo "Setup is finished, please configure config.ini, mariadb followed by importing schema.sql, apache and start with systemctl start proxmox-web-portal"