Merge branch 'community-scripts:main' into step-ca

This commit is contained in:
Joerg Heinemann
2026-02-03 16:06:55 +01:00
committed by GitHub
4 changed files with 187 additions and 28 deletions

View File

@@ -5,7 +5,7 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV
# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE # License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
# Source: https://nginxui.com # Source: https://nginxui.com
APP="Nginx UI" APP="Nginx-UI"
var_tags="${var_tags:-webserver;nginx;proxy}" var_tags="${var_tags:-webserver;nginx;proxy}"
var_cpu="${var_cpu:-1}" var_cpu="${var_cpu:-1}"
var_ram="${var_ram:-512}" var_ram="${var_ram:-512}"

View File

@@ -14,7 +14,7 @@ network_check
update_os update_os
msg_info "Installing Dependencies" msg_info "Installing Dependencies"
$STD apt-get install -y \ $STD apt install -y \
nginx \ nginx \
logrotate logrotate
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
@@ -59,24 +59,40 @@ msg_ok "Configured Nginx UI"
msg_info "Creating Service" msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/nginx-ui.service cat <<EOF >/etc/systemd/system/nginx-ui.service
[Unit] [Unit]
Description=Nginx UI - Web-based Nginx Management Description=Yet another WebUI for Nginx
Documentation=https://nginxui.com Documentation=https://nginxui.com
After=network.target nginx.service After=network.target nginx.service
[Service] [Service]
Type=simple Type=simple
User=root
WorkingDirectory=/usr/local/etc/nginx-ui
ExecStart=/usr/local/bin/nginx-ui --config /usr/local/etc/nginx-ui/app.ini ExecStart=/usr/local/bin/nginx-ui --config /usr/local/etc/nginx-ui/app.ini
RuntimeDirectory=nginx-ui
WorkingDirectory=/var/run/nginx-ui
Restart=on-failure Restart=on-failure
RestartSec=5 TimeoutStopSec=5
KillMode=mixed
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
EOF EOF
systemctl enable -q --now nginx-ui systemctl daemon-reload
msg_ok "Created Service" msg_ok "Created Service"
msg_info "Creating Initial Admin User"
systemctl start nginx-ui
sleep 3
systemctl stop nginx-ui
sleep 1
/usr/local/bin/nginx-ui reset-password --config /usr/local/etc/nginx-ui/app.ini &>/tmp/nginx-ui-reset.log || true
ADMIN_PASS=$(grep -oP 'Password: \K\S+' /tmp/nginx-ui-reset.log || echo "admin")
echo -e "Nginx-UI Credentials\nUsername: admin\nPassword: $ADMIN_PASS" >~/nginx-ui.creds
rm -f /tmp/nginx-ui-reset.log
msg_ok "Created Initial Admin User"
msg_info "Starting Service"
systemctl enable -q --now nginx-ui
msg_ok "Started Service"
motd_ssh motd_ssh
customize customize
cleanup_lxc cleanup_lxc

View File

@@ -20,15 +20,15 @@ load_functions() {
color color
formatting formatting
icons icons
default_vars
set_std_mode set_std_mode
shell_check
get_valid_nextid get_valid_nextid
cleanup_vmid cleanup_vmid
cleanup cleanup
check_root check_root
pve_check pve_check
arch_check arch_check
ssh_check
# add more
} }
# Function to download & save header files # Function to download & save header files
@@ -86,6 +86,7 @@ formatting() {
BOLD=$(echo "\033[1m") BOLD=$(echo "\033[1m")
HOLD=" " HOLD=" "
TAB=" " TAB=" "
TAB3=" "
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -94,6 +95,8 @@ formatting() {
icons() { icons() {
CM="${TAB}✔️${TAB}" CM="${TAB}✔️${TAB}"
CROSS="${TAB}✖️${TAB}" CROSS="${TAB}✖️${TAB}"
DNSOK="✔️ "
DNSFAIL="${TAB}✖️${TAB}"
INFO="${TAB}💡${TAB}${CL}" INFO="${TAB}💡${TAB}${CL}"
OS="${TAB}🖥️${TAB}${CL}" OS="${TAB}🖥️${TAB}${CL}"
OSVERSION="${TAB}🌟${TAB}${CL}" OSVERSION="${TAB}🌟${TAB}${CL}"
@@ -110,12 +113,16 @@ icons() {
NETWORK="${TAB}📡${TAB}${CL}" NETWORK="${TAB}📡${TAB}${CL}"
GATEWAY="${TAB}🌐${TAB}${CL}" GATEWAY="${TAB}🌐${TAB}${CL}"
DISABLEIPV6="${TAB}🚫${TAB}${CL}" DISABLEIPV6="${TAB}🚫${TAB}${CL}"
ICON_DISABLEIPV6="${TAB}🚫${TAB}${CL}"
DEFAULT="${TAB}⚙️${TAB}${CL}" DEFAULT="${TAB}⚙️${TAB}${CL}"
MACADDRESS="${TAB}🔗${TAB}${CL}" MACADDRESS="${TAB}🔗${TAB}${CL}"
VLANTAG="${TAB}🏷️${TAB}${CL}" VLANTAG="${TAB}🏷️${TAB}${CL}"
ROOTSSH="${TAB}🔑${TAB}${CL}" ROOTSSH="${TAB}🔑${TAB}${CL}"
CREATING="${TAB}🚀${TAB}${CL}" CREATING="${TAB}🚀${TAB}${CL}"
ADVANCED="${TAB}🧩${TAB}${CL}" ADVANCED="${TAB}🧩${TAB}${CL}"
FUSE="${TAB}🗂️${TAB}${CL}"
GPU="${TAB}🎮${TAB}${CL}"
HOURGLASS="${TAB}${TAB}"
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -129,9 +136,90 @@ set_std_mode() {
fi fi
} }
# Silent execution function # ------------------------------------------------------------------------------
# default_vars()
#
# - Sets default retry and wait variables used for system actions
# - RETRY_NUM: Maximum number of retry attempts (default: 10)
# - RETRY_EVERY: Seconds to wait between retries (default: 3)
# ------------------------------------------------------------------------------
default_vars() {
RETRY_NUM=10
RETRY_EVERY=3
i=$RETRY_NUM
}
# ------------------------------------------------------------------------------
# get_active_logfile()
#
# - Returns the appropriate log file based on execution context
# - BUILD_LOG: Host operations (VM creation)
# - Fallback to /tmp/build-<timestamp>.log if not set
# ------------------------------------------------------------------------------
get_active_logfile() {
if [[ -n "${BUILD_LOG:-}" ]]; then
echo "$BUILD_LOG"
else
# Fallback for legacy scripts
echo "/tmp/build-$(date +%Y%m%d_%H%M%S).log"
fi
}
# ------------------------------------------------------------------------------
# silent()
#
# - Executes command with output redirected to active log file
# - On error: displays last 10 lines of log and exits with original exit code
# - Temporarily disables error trap to capture exit code correctly
# - Sources explain_exit_code() for detailed error messages
# ------------------------------------------------------------------------------
silent() { silent() {
"$@" >/dev/null 2>&1 local cmd="$*"
local caller_line="${BASH_LINENO[0]:-unknown}"
local logfile="$(get_active_logfile)"
set +Eeuo pipefail
trap - ERR
"$@" >>"$logfile" 2>&1
local rc=$?
set -Eeuo pipefail
trap 'error_handler' ERR
if [[ $rc -ne 0 ]]; then
# Source explain_exit_code if needed
if ! declare -f explain_exit_code >/dev/null 2>&1; then
source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/error_handler.func) 2>/dev/null || true
fi
local explanation=""
if declare -f explain_exit_code >/dev/null 2>&1; then
explanation="$(explain_exit_code "$rc")"
fi
printf "\e[?25h"
if [[ -n "$explanation" ]]; then
msg_error "in line ${caller_line}: exit code ${rc} (${explanation})"
else
msg_error "in line ${caller_line}: exit code ${rc}"
fi
msg_custom "→" "${YWB}" "${cmd}"
if [[ -s "$logfile" ]]; then
local log_lines=$(wc -l <"$logfile")
echo "--- Last 10 lines of log ---"
tail -n 10 "$logfile"
echo "----------------------------"
# Show how to view full log if there are more lines
if [[ $log_lines -gt 10 ]]; then
msg_custom "📋" "${YW}" "View full log (${log_lines} lines): ${logfile}"
fi
fi
exit "$rc"
fi
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -237,6 +325,46 @@ __curl_err_handler() {
exit 1 exit 1
} }
# ------------------------------------------------------------------------------
# shell_check()
#
# - Verifies that the script is running under Bash shell
# - Exits with error message if different shell is detected
# ------------------------------------------------------------------------------
shell_check() {
if [[ "$(ps -p $$ -o comm=)" != "bash" ]]; then
clear
msg_error "Your default shell is currently not set to Bash. To use these scripts, please switch to the Bash shell."
echo -e "\nExiting..."
sleep 2
exit
fi
}
# ------------------------------------------------------------------------------
# clear_line()
#
# - Clears current terminal line using tput or ANSI escape codes
# - Moves cursor to beginning of line (carriage return)
# - Fallback to ANSI codes if tput not available
# ------------------------------------------------------------------------------
clear_line() {
tput cr 2>/dev/null || echo -en "\r"
tput el 2>/dev/null || echo -en "\033[K"
}
# ------------------------------------------------------------------------------
# is_verbose_mode()
#
# - Determines if script should run in verbose mode
# - Checks VERBOSE and var_verbose variables
# - Also returns true if not running in TTY (pipe/redirect scenario)
# ------------------------------------------------------------------------------
is_verbose_mode() {
local verbose="${VERBOSE:-${var_verbose:-no}}"
[[ "$verbose" != "no" || ! -t 2 ]]
}
### dev spinner ### ### dev spinner ###
SPINNER_ACTIVE=0 SPINNER_ACTIVE=0
SPINNER_PID="" SPINNER_PID=""
@@ -332,7 +460,9 @@ msg_ok() {
printf "\r\e[2K%s %b\n" "${CM}" "${GN}${msg}${CL}" >&2 printf "\r\e[2K%s %b\n" "${CM}" "${GN}${msg}${CL}" >&2
# Remove from shown messages to allow it to be shown again # Remove from shown messages to allow it to be shown again
unset MSG_INFO_SHOWN["$msg"] local sanitized_msg
sanitized_msg=$(printf '%s' "$msg" | sed 's/\x1b\[[0-9;]*m//g; s/[^a-zA-Z0-9_]/_/g')
unset 'MSG_INFO_SHOWN['"$sanitized_msg"']' 2>/dev/null || true
} }
msg_error() { msg_error() {
@@ -341,15 +471,42 @@ msg_error() {
printf "\r\e[2K%s %b\n" "${CROSS}" "${RD}${msg}${CL}" >&2 printf "\r\e[2K%s %b\n" "${CROSS}" "${RD}${msg}${CL}" >&2
} }
msg_warn() {
stop_spinner
local msg="$1"
echo -e "${BFR:-}${INFO:-} ${YWB}${msg}${CL}" >&2
}
# Helper function to display a message with custom symbol and color # Helper function to display a message with custom symbol and color
msg_custom() { msg_custom() {
local symbol="${1:-*}" local symbol="${1:-*}"
local color="${2:-$CL}" local color="${2:-$CL}"
local msg="${3:-Custom message}" local msg="${3:-Custom message}"
[[ -z "$msg" ]] && return
stop_spinner stop_spinner
printf "\r\e[2K%s %b\n" "$symbol" "${color}${msg}${CL}" >&2 printf "\r\e[2K%s %b\n" "$symbol" "${color}${msg}${CL}" >&2
} }
# ------------------------------------------------------------------------------
# msg_debug()
#
# - Displays debug message with timestamp when var_full_verbose=1
# - Automatically enables var_verbose if not already set
# - Uses bright yellow color for debug output
# ------------------------------------------------------------------------------
msg_debug() {
if [[ "${var_full_verbose:-0}" == "1" ]]; then
[[ "${var_verbose:-0}" != "1" ]] && var_verbose=1
echo -e "${YWB}[$(date '+%F %T')] [DEBUG]${CL} $*"
fi
}
# Displays error message and immediately terminates script
fatal() {
msg_error "$1"
kill -INT $$
}
get_valid_nextid() { get_valid_nextid() {
local try_id local try_id
try_id=$(pvesh get /cluster/nextid) try_id=$(pvesh get /cluster/nextid)
@@ -413,19 +570,6 @@ arch_check() {
fi fi
} }
ssh_check() {
if command -v pveversion >/dev/null 2>&1; then
if [ -n "${SSH_CLIENT:+x}" ]; then
if whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "SSH DETECTED" --yesno "It's suggested to use the Proxmox shell instead of SSH, since SSH can create issues while gathering variables. Would you like to proceed with using SSH?" 10 62; then
echo "you've been warned"
else
clear
exit
fi
fi
fi
}
exit_script() { exit_script() {
clear clear
echo -e "\n${CROSS}${RD}User exited script${CL}\n" echo -e "\n${CROSS}${RD}User exited script${CL}\n"

View File

@@ -8,8 +8,8 @@
# Docker VM - Creates a Docker-ready Virtual Machine # Docker VM - Creates a Docker-ready Virtual Machine
# ============================================================================== # ==============================================================================
source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/api.func) source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/api.func) 2>/dev/null
source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/vm-core.func) source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/vm-core.func) 2>/dev/null
source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/cloud-init.func) 2>/dev/null || true source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/cloud-init.func) 2>/dev/null || true
load_functions load_functions
@@ -371,7 +371,6 @@ function start_script() {
# MAIN EXECUTION # MAIN EXECUTION
# ============================================================================== # ==============================================================================
header_info header_info
echo -e "\n Loading..."
check_root check_root
arch_check arch_check