Merge branch 'main' of https://github.com/community-scripts/ProxmoxVED
This commit is contained in:
commit
f5a87a3729
@ -29,7 +29,7 @@ function update_script() {
|
||||
exit
|
||||
fi
|
||||
|
||||
RELEASE="v4.0.0"
|
||||
RELEASE="v4.1.0"
|
||||
if check_for_gh_release "opencloud" "opencloud-eu/opencloud" "${RELEASE}"; then
|
||||
msg_info "Stopping services"
|
||||
systemctl stop opencloud opencloud-wopi
|
||||
@ -37,7 +37,7 @@ function update_script() {
|
||||
|
||||
msg_info "Updating packages"
|
||||
$STD apt-get update
|
||||
$STD apt-get dist-upgrade
|
||||
$STD apt-get dist-upgrade -y
|
||||
msg_ok "Updated packages"
|
||||
|
||||
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "opencloud" "opencloud-eu/opencloud" "singlefile" "${RELEASE}" "/usr/bin" "opencloud-*-linux-amd64"
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
{
|
||||
"name": "Pi-Hole Exporter",
|
||||
"slug": "pihole-exporter",
|
||||
"categories": [
|
||||
9
|
||||
],
|
||||
"date_created": "2025-12-08",
|
||||
"type": "addon",
|
||||
"updateable": true,
|
||||
"privileged": false,
|
||||
"interface_port": 9617,
|
||||
"documentation": "https://github.com/eko/pihole-exporter",
|
||||
"website": "https://github.com/eko/pihole-exporter",
|
||||
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/pi-hole.webp",
|
||||
"config_path": "/opt/pihole-exporter.env",
|
||||
"description": "A Prometheus exporter for PI-Hole's Raspberry PI ad blocker",
|
||||
"install_methods": [
|
||||
{
|
||||
"type": "default",
|
||||
"script": "tools/addon/pihole-exporter.sh",
|
||||
"resources": {
|
||||
"cpu": null,
|
||||
"ram": null,
|
||||
"hdd": null,
|
||||
"os": null,
|
||||
"version": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "alpine",
|
||||
"script": "tools/addon/pihole-exporter.sh",
|
||||
"resources": {
|
||||
"cpu": null,
|
||||
"ram": null,
|
||||
"hdd": null,
|
||||
"os": null,
|
||||
"version": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"default_credentials": {
|
||||
"username": null,
|
||||
"password": null
|
||||
},
|
||||
"notes": []
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
{
|
||||
"name": "qbittorrent Exporter",
|
||||
"slug": "qbittorrent-exporter",
|
||||
"categories": [
|
||||
9
|
||||
],
|
||||
"date_created": "2025-11-21",
|
||||
"type": "addon",
|
||||
"updateable": true,
|
||||
"privileged": false,
|
||||
"interface_port": 8090,
|
||||
"documentation": "https://github.com/martabal/qbittorrent-exporter",
|
||||
"website": "https://github.com/martabal/qbittorrent-exporter",
|
||||
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/qbittorrent.webp",
|
||||
"config_path": "/opt/qbittorrent-exporter.env",
|
||||
"description": "A fast and lightweight prometheus exporter for qBittorrent ",
|
||||
"install_methods": [
|
||||
{
|
||||
"type": "default",
|
||||
"script": "tools/addon/qbittorrent-exporter.sh",
|
||||
"resources": {
|
||||
"cpu": null,
|
||||
"ram": null,
|
||||
"hdd": null,
|
||||
"os": null,
|
||||
"version": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "alpine",
|
||||
"script": "tools/addon/qbittorrent-exporter.sh",
|
||||
"resources": {
|
||||
"cpu": null,
|
||||
"ram": null,
|
||||
"hdd": null,
|
||||
"os": null,
|
||||
"version": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"default_credentials": {
|
||||
"username": null,
|
||||
"password": null
|
||||
},
|
||||
"notes": []
|
||||
}
|
||||
@ -79,6 +79,7 @@ SESSION_SECRET="${SECRET}"
|
||||
# OIDC_CLIENT_SECRET=
|
||||
# OIDC_CALLBACK_URL=
|
||||
# OIDC_SCOPES=
|
||||
# OIDC_AUTO_CREATE_USERS=true
|
||||
|
||||
# SEARCH_DEEP=
|
||||
# SEARCH_RIPGREP=
|
||||
|
||||
@ -57,7 +57,7 @@ echo "$COOLPASS" >~/.coolpass
|
||||
msg_ok "Installed Collabora Online"
|
||||
|
||||
# OpenCloud
|
||||
fetch_and_deploy_gh_release "opencloud" "opencloud-eu/opencloud" "singlefile" "v4.0.0" "/usr/bin" "opencloud-*-linux-amd64"
|
||||
fetch_and_deploy_gh_release "opencloud" "opencloud-eu/opencloud" "singlefile" "v4.1.0" "/usr/bin" "opencloud-*-linux-amd64"
|
||||
|
||||
msg_info "Configuring OpenCloud"
|
||||
DATA_DIR="/var/lib/opencloud/"
|
||||
|
||||
@ -1,250 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright (c) 2021-2025 community-scripts ORG
|
||||
# Author: CrazyWolf13
|
||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||
# Source: https://github.com/eko/pihole-exporter/
|
||||
|
||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/core.func)
|
||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/tools.func)
|
||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func)
|
||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/error_handler.func)
|
||||
load_functions
|
||||
|
||||
# Enable error handling
|
||||
set -Eeuo pipefail
|
||||
trap 'error_handler' ERR
|
||||
|
||||
# ==============================================================================
|
||||
# CONFIGURATION
|
||||
# ==============================================================================
|
||||
VERBOSE=${var_verbose:-no}
|
||||
APP="pihole-exporter"
|
||||
APP_TYPE="tools"
|
||||
INSTALL_PATH="/opt/pihole-exporter"
|
||||
CONFIG_PATH="/opt/pihole-exporter.env"
|
||||
header_info
|
||||
ensure_usr_local_bin_persist
|
||||
get_current_ip &>/dev/null
|
||||
|
||||
# ==============================================================================
|
||||
# OS DETECTION
|
||||
# ==============================================================================
|
||||
if [[ -f "/etc/alpine-release" ]]; then
|
||||
OS="Alpine"
|
||||
SERVICE_PATH="/etc/init.d/pihole-exporter"
|
||||
elif grep -qE 'ID=debian|ID=ubuntu' /etc/os-release; then
|
||||
OS="Debian"
|
||||
SERVICE_PATH="/etc/systemd/system/pihole-exporter.service"
|
||||
else
|
||||
echo -e "${CROSS} Unsupported OS detected. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ==============================================================================
|
||||
# UNINSTALL
|
||||
# ==============================================================================
|
||||
function uninstall() {
|
||||
msg_info "Uninstalling Pihole-Exporter"
|
||||
if [[ "$OS" == "Alpine" ]]; then
|
||||
rc-service pihole-exporter stop &>/dev/null
|
||||
rc-update del pihole-exporter &>/dev/null
|
||||
rm -f "$SERVICE_PATH"
|
||||
else
|
||||
systemctl disable -q --now pihole-exporter
|
||||
rm -f "$SERVICE_PATH"
|
||||
fi
|
||||
rm -rf "$INSTALL_PATH" "$CONFIG_PATH"
|
||||
rm -f "/usr/local/bin/update_pihole-exporter"
|
||||
rm -f "$HOME/.pihole-exporter"
|
||||
msg_ok "Pihole-Exporter has been uninstalled"
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# UPDATE
|
||||
# ==============================================================================
|
||||
function update() {
|
||||
if check_for_gh_release "pihole-exporter" "eko/pihole-exporter"; then
|
||||
msg_info "Stopping service"
|
||||
if [[ "$OS" == "Alpine" ]]; then
|
||||
rc-service pihole-exporter stop &>/dev/null
|
||||
else
|
||||
systemctl stop pihole-exporter
|
||||
fi
|
||||
msg_ok "Stopped service"
|
||||
|
||||
fetch_and_deploy_gh_release "pihole-exporter" "eko/pihole-exporter" "tarball" "latest"
|
||||
setup_go
|
||||
|
||||
msg_info "Building Pihole-Exporter"
|
||||
cd /opt/pihole-exporter/
|
||||
$STD /usr/local/bin/go build -o ./pihole-exporter
|
||||
msg_ok "Built Pihole-Exporter"
|
||||
|
||||
msg_info "Starting service"
|
||||
if [[ "$OS" == "Alpine" ]]; then
|
||||
rc-service pihole-exporter start &>/dev/null
|
||||
else
|
||||
systemctl start pihole-exporter
|
||||
fi
|
||||
msg_ok "Started service"
|
||||
msg_ok "Updated successfully"
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# INSTALL
|
||||
# ==============================================================================
|
||||
function install() {
|
||||
read -erp "Enter the protocol to use (http/https), default https: " pihole_PROTOCOL
|
||||
read -erp "Enter the hostname of Pihole, example: (127.0.0.1): " pihole_HOSTNAME
|
||||
read -erp "Enter the port of Pihole, default 443: " pihole_PORT
|
||||
read -rsp "Enter Pihole password: " pihole_PASSWORD
|
||||
printf "\n"
|
||||
read -erp "Do you want to skip TLS-Verification (if using a self-signed Certificate on Pi-Hole) [y/N]: " SKIP_TLS
|
||||
if [[ "${SKIP_TLS,,}" =~ ^(y|yes)$ ]]; then
|
||||
pihole_SKIP_TLS="true"
|
||||
fi
|
||||
|
||||
fetch_and_deploy_gh_release "pihole-exporter" "eko/pihole-exporter" "tarball" "latest"
|
||||
setup_go
|
||||
msg_info "Building Pihole-Exporter on ${OS}"
|
||||
cd /opt/pihole-exporter/
|
||||
$STD /usr/local/bin/go build -o ./pihole-exporter
|
||||
msg_ok "Built Pihole-Exporter"
|
||||
|
||||
msg_info "Creating configuration"
|
||||
cat <<EOF >"$CONFIG_PATH"
|
||||
# https://github.com/eko/pihole-exporter/?tab=readme-ov-file#available-cli-options
|
||||
PIHOLE_PASSWORD="${pihole_PASSWORD}"
|
||||
PIHOLE_HOSTNAME="${pihole_HOSTNAME:-127.0.0.1}"
|
||||
PIHOLE_PORT="${pihole_PORT:-443}"
|
||||
SKIP_TLS_VERIFICATION="${pihole_SKIP_TLS:-false}"
|
||||
PIHOLE_PROTOCOL="${pihole_PROTOCOL:-https}"
|
||||
EOF
|
||||
msg_ok "Created configuration"
|
||||
|
||||
msg_info "Creating service"
|
||||
if [[ "$OS" == "Debian" ]]; then
|
||||
cat <<EOF >"$SERVICE_PATH"
|
||||
[Unit]
|
||||
Description=pihole-exporter
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=root
|
||||
WorkingDirectory=/opt/pihole-exporter
|
||||
EnvironmentFile=$CONFIG_PATH
|
||||
ExecStart=/opt/pihole-exporter/pihole-exporter
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl daemon-reload
|
||||
systemctl enable -q --now pihole-exporter
|
||||
else
|
||||
cat <<EOF >"$SERVICE_PATH"
|
||||
#!/sbin/openrc-run
|
||||
|
||||
name="pihole-exporter"
|
||||
description="Pi-hole Exporter for Prometheus"
|
||||
command="${INSTALL_PATH}/pihole-exporter"
|
||||
command_background=true
|
||||
directory="/opt/pihole-exporter"
|
||||
pidfile="/run/\${RC_SVCNAME}.pid"
|
||||
output_log="/var/log/pihole-exporter.log"
|
||||
error_log="/var/log/pihole-exporter.log"
|
||||
|
||||
depend() {
|
||||
need net
|
||||
after firewall
|
||||
}
|
||||
|
||||
start_pre() {
|
||||
if [ -f "$CONFIG_PATH" ]; then
|
||||
export \$(grep -v '^#' $CONFIG_PATH | xargs)
|
||||
fi
|
||||
}
|
||||
EOF
|
||||
chmod +x "$SERVICE_PATH"
|
||||
$STD rc-update add pihole-exporter default
|
||||
$STD rc-service pihole-exporter start
|
||||
fi
|
||||
msg_ok "Created and started service"
|
||||
|
||||
# Create update script
|
||||
msg_info "Creating update script"
|
||||
ensure_usr_local_bin_persist
|
||||
cat <<'UPDATEEOF' >/usr/local/bin/update_pihole-exporter
|
||||
#!/usr/bin/env bash
|
||||
# pihole-exporter Update Script
|
||||
type=update bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/tools/addon/pihole-exporter.sh)"
|
||||
UPDATEEOF
|
||||
chmod +x /usr/local/bin/update_pihole-exporter
|
||||
msg_ok "Created update script (/usr/local/bin/update_pihole-exporter)"
|
||||
|
||||
echo ""
|
||||
msg_ok "Pihole-Exporter installed successfully"
|
||||
msg_ok "Metrics: ${BL}http://${CURRENT_IP}:9617/metrics${CL}"
|
||||
msg_ok "Config: ${BL}${CONFIG_PATH}${CL}"
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# MAIN
|
||||
# ==============================================================================
|
||||
header_info
|
||||
ensure_usr_local_bin_persist
|
||||
get_current_ip &>/dev/null
|
||||
|
||||
# Handle type=update (called from update script)
|
||||
if [[ "${type:-}" == "update" ]]; then
|
||||
if [[ -d "$INSTALL_PATH" && -f "$INSTALL_PATH/pihole-exporter" ]]; then
|
||||
update
|
||||
else
|
||||
msg_error "Pihole-Exporter is not installed. Nothing to update."
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check if already installed
|
||||
if [[ -d "$INSTALL_PATH" && -f "$INSTALL_PATH/pihole-exporter" ]]; then
|
||||
msg_warn "Pihole-Exporter is already installed."
|
||||
echo ""
|
||||
|
||||
echo -n "${TAB}Uninstall Pihole-Exporter? (y/N): "
|
||||
read -r uninstall_prompt
|
||||
if [[ "${uninstall_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||
uninstall
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo -n "${TAB}Update Pihole-Exporter? (y/N): "
|
||||
read -r update_prompt
|
||||
if [[ "${update_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||
update
|
||||
exit 0
|
||||
fi
|
||||
|
||||
msg_warn "No action selected. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Fresh installation
|
||||
msg_warn "Pihole-Exporter is not installed."
|
||||
echo ""
|
||||
echo -e "${TAB}${INFO} This will install:"
|
||||
echo -e "${TAB} - Pi-hole Exporter (Go binary)"
|
||||
echo -e "${TAB} - Systemd/OpenRC service"
|
||||
echo ""
|
||||
|
||||
echo -n "${TAB}Install Pihole-Exporter? (y/N): "
|
||||
read -r install_prompt
|
||||
if [[ "${install_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||
install
|
||||
else
|
||||
msg_warn "Installation cancelled. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
@ -1,243 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright (c) 2021-2025 community-scripts ORG
|
||||
# Author: CrazyWolf13
|
||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||
# Source: https://github.com/martabal/qbittorrent-exporter
|
||||
|
||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/core.func)
|
||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/tools.func)
|
||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func)
|
||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/error_handler.func)
|
||||
load_functions
|
||||
|
||||
# Enable error handling
|
||||
set -Eeuo pipefail
|
||||
trap 'error_handler' ERR
|
||||
|
||||
# ==============================================================================
|
||||
# CONFIGURATION
|
||||
# ==============================================================================
|
||||
VERBOSE=${var_verbose:-no}
|
||||
APP="qbittorrent-exporter"
|
||||
APP_TYPE="tools"
|
||||
INSTALL_PATH="/opt/qbittorrent-exporter"
|
||||
CONFIG_PATH="/opt/qbittorrent-exporter.env"
|
||||
header_info
|
||||
ensure_usr_local_bin_persist
|
||||
get_current_ip &>/dev/null
|
||||
|
||||
# ==============================================================================
|
||||
# OS DETECTION
|
||||
# ==============================================================================
|
||||
if [[ -f "/etc/alpine-release" ]]; then
|
||||
OS="Alpine"
|
||||
SERVICE_PATH="/etc/init.d/qbittorrent-exporter"
|
||||
elif grep -qE 'ID=debian|ID=ubuntu' /etc/os-release; then
|
||||
OS="Debian"
|
||||
SERVICE_PATH="/etc/systemd/system/qbittorrent-exporter.service"
|
||||
else
|
||||
echo -e "${CROSS} Unsupported OS detected. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ==============================================================================
|
||||
# UNINSTALL
|
||||
# ==============================================================================
|
||||
function uninstall() {
|
||||
msg_info "Uninstalling qBittorrent-Exporter"
|
||||
if [[ "$OS" == "Alpine" ]]; then
|
||||
rc-service qbittorrent-exporter stop &>/dev/null
|
||||
rc-update del qbittorrent-exporter &>/dev/null
|
||||
rm -f "$SERVICE_PATH"
|
||||
else
|
||||
systemctl disable -q --now qbittorrent-exporter
|
||||
rm -f "$SERVICE_PATH"
|
||||
fi
|
||||
rm -rf "$INSTALL_PATH" "$CONFIG_PATH"
|
||||
rm -f "/usr/local/bin/update_qbittorrent-exporter"
|
||||
rm -f "$HOME/.qbittorrent-exporter"
|
||||
msg_ok "qBittorrent-Exporter has been uninstalled"
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# UPDATE
|
||||
# ==============================================================================
|
||||
function update() {
|
||||
if check_for_gh_release "qbittorrent-exporter" "martabal/qbittorrent-exporter"; then
|
||||
msg_info "Stopping service"
|
||||
if [[ "$OS" == "Alpine" ]]; then
|
||||
rc-service qbittorrent-exporter stop &>/dev/null
|
||||
else
|
||||
systemctl stop qbittorrent-exporter
|
||||
fi
|
||||
msg_ok "Stopped service"
|
||||
|
||||
fetch_and_deploy_gh_release "qbittorrent-exporter" "martabal/qbittorrent-exporter" "tarball" "latest"
|
||||
setup_go
|
||||
|
||||
msg_info "Building qBittorrent-Exporter"
|
||||
cd /opt/qbittorrent-exporter
|
||||
$STD /usr/local/bin/go build -o ./qbittorrent-exporter
|
||||
msg_ok "Built qBittorrent-Exporter"
|
||||
|
||||
msg_info "Starting service"
|
||||
if [[ "$OS" == "Alpine" ]]; then
|
||||
rc-service qbittorrent-exporter start &>/dev/null
|
||||
else
|
||||
systemctl start qbittorrent-exporter
|
||||
fi
|
||||
msg_ok "Started service"
|
||||
msg_ok "Updated successfully"
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# INSTALL
|
||||
# ==============================================================================
|
||||
function install() {
|
||||
read -erp "Enter URL of qBittorrent, example: (http://127.0.0.1:8080): " QBITTORRENT_BASE_URL
|
||||
read -erp "Enter qBittorrent username: " QBITTORRENT_USERNAME
|
||||
read -rsp "Enter qBittorrent password: " QBITTORRENT_PASSWORD
|
||||
printf "\n"
|
||||
|
||||
fetch_and_deploy_gh_release "qbittorrent-exporter" "martabal/qbittorrent-exporter" "tarball" "latest"
|
||||
setup_go
|
||||
msg_info "Building qBittorrent-Exporter on ${OS}"
|
||||
cd /opt/qbittorrent-exporter
|
||||
$STD /usr/local/bin/go build -o ./qbittorrent-exporter
|
||||
msg_ok "Built qBittorrent-Exporter"
|
||||
|
||||
msg_info "Creating configuration"
|
||||
cat <<EOF >"$CONFIG_PATH"
|
||||
# https://github.com/martabal/qbittorrent-exporter?tab=readme-ov-file#parameters
|
||||
QBITTORRENT_BASE_URL="${QBITTORRENT_BASE_URL}"
|
||||
QBITTORRENT_USERNAME="${QBITTORRENT_USERNAME}"
|
||||
QBITTORRENT_PASSWORD="${QBITTORRENT_PASSWORD}"
|
||||
EOF
|
||||
msg_ok "Created configuration"
|
||||
|
||||
msg_info "Creating service"
|
||||
if [[ "$OS" == "Debian" ]]; then
|
||||
cat <<EOF >"$SERVICE_PATH"
|
||||
[Unit]
|
||||
Description=qbittorrent-exporter
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=root
|
||||
WorkingDirectory=/opt/qbittorrent-exporter
|
||||
EnvironmentFile=$CONFIG_PATH
|
||||
ExecStart=/opt/qbittorrent-exporter/qbittorrent-exporter
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl daemon-reload
|
||||
systemctl enable -q --now qbittorrent-exporter
|
||||
else
|
||||
cat <<EOF >"$SERVICE_PATH"
|
||||
#!/sbin/openrc-run
|
||||
|
||||
name="qbittorrent-exporter"
|
||||
description="qBittorrent Exporter for Prometheus"
|
||||
command="${INSTALL_PATH}/qbittorrent-exporter"
|
||||
command_background=true
|
||||
directory="/opt/qbittorrent-exporter"
|
||||
pidfile="/run/\${RC_SVCNAME}.pid"
|
||||
output_log="/var/log/qbittorrent-exporter.log"
|
||||
error_log="/var/log/qbittorrent-exporter.log"
|
||||
|
||||
depend() {
|
||||
need net
|
||||
after firewall
|
||||
}
|
||||
|
||||
start_pre() {
|
||||
if [ -f "$CONFIG_PATH" ]; then
|
||||
export \$(grep -v '^#' $CONFIG_PATH | xargs)
|
||||
fi
|
||||
}
|
||||
EOF
|
||||
chmod +x "$SERVICE_PATH"
|
||||
$STD rc-update add qbittorrent-exporter default
|
||||
$STD rc-service qbittorrent-exporter start
|
||||
fi
|
||||
msg_ok "Created and started service"
|
||||
|
||||
# Create update script
|
||||
msg_info "Creating update script"
|
||||
ensure_usr_local_bin_persist
|
||||
cat <<'UPDATEEOF' >/usr/local/bin/update_qbittorrent-exporter
|
||||
#!/usr/bin/env bash
|
||||
# qbittorrent-exporter Update Script
|
||||
type=update bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/tools/addon/qbittorrent-exporter.sh)"
|
||||
UPDATEEOF
|
||||
chmod +x /usr/local/bin/update_qbittorrent-exporter
|
||||
msg_ok "Created update script (/usr/local/bin/update_qbittorrent-exporter)"
|
||||
|
||||
echo ""
|
||||
msg_ok "qBittorrent-Exporter installed successfully"
|
||||
msg_ok "Metrics: ${BL}http://${CURRENT_IP}:8090/metrics${CL}"
|
||||
msg_ok "Config: ${BL}${CONFIG_PATH}${CL}"
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# MAIN
|
||||
# ==============================================================================
|
||||
header_info
|
||||
ensure_usr_local_bin_persist
|
||||
get_current_ip &>/dev/null
|
||||
|
||||
# Handle type=update (called from update script)
|
||||
if [[ "${type:-}" == "update" ]]; then
|
||||
if [[ -d "$INSTALL_PATH" && -f "$INSTALL_PATH/qbittorrent-exporter" ]]; then
|
||||
update
|
||||
else
|
||||
msg_error "qBittorrent-Exporter is not installed. Nothing to update."
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check if already installed
|
||||
if [[ -d "$INSTALL_PATH" && -f "$INSTALL_PATH/qbittorrent-exporter" ]]; then
|
||||
msg_warn "qBittorrent-Exporter is already installed."
|
||||
echo ""
|
||||
|
||||
echo -n "${TAB}Uninstall qBittorrent-Exporter? (y/N): "
|
||||
read -r uninstall_prompt
|
||||
if [[ "${uninstall_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||
uninstall
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo -n "${TAB}Update qBittorrent-Exporter? (y/N): "
|
||||
read -r update_prompt
|
||||
if [[ "${update_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||
update
|
||||
exit 0
|
||||
fi
|
||||
|
||||
msg_warn "No action selected. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Fresh installation
|
||||
msg_warn "qBittorrent-Exporter is not installed."
|
||||
echo ""
|
||||
echo -e "${TAB}${INFO} This will install:"
|
||||
echo -e "${TAB} - qBittorrent Exporter (Go binary)"
|
||||
echo -e "${TAB} - Systemd/OpenRC service"
|
||||
echo ""
|
||||
|
||||
echo -n "${TAB}Install qBittorrent-Exporter? (y/N): "
|
||||
read -r install_prompt
|
||||
if [[ "${install_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||
install
|
||||
else
|
||||
msg_warn "Installation cancelled. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
@ -588,96 +588,17 @@ echo -en "\e[1A\e[0K"
|
||||
FILE=$(basename $URL)
|
||||
msg_ok "Downloaded ${CL}${BL}${FILE}${CL}"
|
||||
|
||||
# --- Inject UniFi Installer via Cloud-Init ---
|
||||
msg_info "Preparing ${OS_DISPLAY} Cloud Image for UniFi OS"
|
||||
msg_ok "Downloaded ${OS_DISPLAY} Cloud Image"
|
||||
|
||||
# Install virt-customize if not available
|
||||
if ! command -v virt-customize &>/dev/null; then
|
||||
# Expand root partition to use full disk space
|
||||
msg_info "Expanding disk image to ${DISK_SIZE}"
|
||||
|
||||
# Install virt-resize if not available
|
||||
if ! command -v virt-resize &>/dev/null; then
|
||||
apt-get -qq update >/dev/null
|
||||
apt-get -qq install libguestfs-tools -y >/dev/null
|
||||
fi
|
||||
|
||||
# Create UniFi OS installation script and inject it into the image
|
||||
virt-customize -a "${FILE}" --run-command "cat > /root/install-unifi-os.sh << 'INSTALLSCRIPT'
|
||||
#!/bin/bash
|
||||
set -x
|
||||
exec > /var/log/unifi-install.log 2>&1
|
||||
|
||||
echo \"=== UniFi OS Installation Started at \$(date) ===\"
|
||||
|
||||
# Wait for cloud-init to complete
|
||||
if command -v cloud-init >/dev/null 2>&1; then
|
||||
echo \"Waiting for cloud-init to complete...\"
|
||||
cloud-init status --wait 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Install required packages
|
||||
echo \"Installing required packages...\"
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update
|
||||
apt-get install -y curl wget ca-certificates podman uidmap slirp4netns iptables
|
||||
|
||||
# Configure Podman
|
||||
echo \"Configuring Podman...\"
|
||||
loginctl enable-linger root
|
||||
|
||||
# Download UniFi OS Server
|
||||
echo \"Downloading UniFi OS Server ${UOS_VERSION}...\"
|
||||
cd /root
|
||||
curl -fsSL '${UOS_URL}' -o unifi-installer.bin
|
||||
chmod +x unifi-installer.bin
|
||||
|
||||
# Install UniFi OS Server
|
||||
echo \"Installing UniFi OS Server (this takes 3-5 minutes)...\"
|
||||
./unifi-installer.bin install
|
||||
|
||||
echo \"Waiting for services to start...\"
|
||||
sleep 15
|
||||
|
||||
# Start UniFi OS Server
|
||||
if systemctl list-unit-files | grep -q unifi-os-server; then
|
||||
echo \"Starting UniFi OS Server service...\"
|
||||
systemctl enable unifi-os-server
|
||||
systemctl start unifi-os-server
|
||||
sleep 10
|
||||
|
||||
if systemctl is-active --quiet unifi-os-server; then
|
||||
echo \"SUCCESS: UniFi OS Server is running\"
|
||||
else
|
||||
echo \"WARNING: Checking service status...\"
|
||||
systemctl status unifi-os-server --no-pager
|
||||
fi
|
||||
fi
|
||||
|
||||
touch /root/.unifi-installed
|
||||
echo \"=== Installation completed at \$(date) ===\"
|
||||
INSTALLSCRIPT" >/dev/null 2>&1
|
||||
|
||||
virt-customize -a "${FILE}" --chmod 0755:/root/install-unifi-os.sh >/dev/null 2>&1
|
||||
|
||||
# Create systemd service for first-boot installation
|
||||
virt-customize -a "${FILE}" --run-command "cat > /etc/systemd/system/unifi-firstboot.service << 'SVCFILE'
|
||||
[Unit]
|
||||
Description=UniFi OS First Boot Installation
|
||||
After=cloud-init.service network-online.target
|
||||
Wants=network-online.target
|
||||
ConditionPathExists=!/root/.unifi-installed
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/root/install-unifi-os.sh
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
SVCFILE" >/dev/null 2>&1
|
||||
|
||||
virt-customize -a "${FILE}" --run-command "systemctl enable unifi-firstboot.service" >/dev/null 2>&1
|
||||
|
||||
msg_ok "Prepared ${OS_DISPLAY} image with UniFi OS installer"
|
||||
|
||||
# Expand root partition to use full disk space
|
||||
msg_info "Expanding disk image to ${DISK_SIZE}"
|
||||
qemu-img create -f qcow2 expanded.qcow2 ${DISK_SIZE} >/dev/null 2>&1
|
||||
|
||||
# Detect partition device (sda1 for Ubuntu, vda1 for Debian)
|
||||
@ -712,21 +633,10 @@ qm set "$VMID" \
|
||||
qm resize "$VMID" scsi0 "$DISK_SIZE" >/dev/null
|
||||
qm set "$VMID" --agent enabled=1 >/dev/null
|
||||
|
||||
# Add Cloud-Init drive (standard Cloud-Init, no custom user-data)
|
||||
# Add Cloud-Init drive
|
||||
msg_info "Configuring Cloud-Init"
|
||||
setup_cloud_init "$VMID" "$STORAGE" "$HN" "yes" >/dev/null 2>&1
|
||||
msg_ok "Cloud-Init configured (UniFi OS installs via systemd service on first boot)"
|
||||
|
||||
# Display credentials immediately so user can login
|
||||
if [ -n "$CLOUDINIT_CRED_FILE" ] && [ -f "$CLOUDINIT_CRED_FILE" ]; then
|
||||
echo ""
|
||||
echo -e "${INFO}${BOLD}${GN}Cloud-Init Credentials (save these now!):${CL}"
|
||||
echo -e "${TAB}${DGN}User: ${BGN}${CLOUDINIT_USER:-root}${CL}"
|
||||
echo -e "${TAB}${DGN}Password: ${BGN}${CLOUDINIT_PASSWORD}${CL}"
|
||||
echo -e "${TAB}${RD}⚠️ UniFi OS installation runs automatically on first boot${CL}"
|
||||
echo -e "${TAB}${INFO}Monitor: ${BL}tail -f /var/log/unifi-install.log${CL}"
|
||||
echo ""
|
||||
fi
|
||||
msg_ok "Cloud-Init configured"
|
||||
|
||||
DESCRIPTION=$(
|
||||
cat <<EOF
|
||||
@ -769,69 +679,139 @@ if [ "$START_VM" == "yes" ]; then
|
||||
qm start $VMID
|
||||
msg_ok "Started UniFi OS VM"
|
||||
|
||||
msg_info "Waiting for VM to boot (30 seconds)"
|
||||
sleep 30
|
||||
msg_ok "VM should be booting now"
|
||||
msg_info "Waiting for VM to boot and Cloud-Init to complete (60-90 seconds)"
|
||||
sleep 60
|
||||
msg_ok "VM boot complete"
|
||||
|
||||
msg_info "Detecting VM IP address (may take up to 60 seconds)"
|
||||
msg_info "Detecting VM IP address"
|
||||
VM_IP=""
|
||||
for i in {1..30}; do
|
||||
VM_IP=$(qm guest cmd $VMID network-get-interfaces 2>/dev/null | jq -r '.[1]["ip-addresses"][]? | select(.["ip-address-type"] == "ipv4") | .["ip-address"]' 2>/dev/null | grep -v "127.0.0.1" | head -1 || echo "")
|
||||
|
||||
if [ -n "$VM_IP" ]; then
|
||||
msg_ok "VM IP Address detected: ${VM_IP}"
|
||||
msg_ok "VM IP Address: ${VM_IP}"
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
if [ -n "$VM_IP" ]; then
|
||||
msg_info "Waiting for UniFi OS installation (via Cloud-Init, takes 5-8 minutes)"
|
||||
|
||||
WAIT_COUNT=0
|
||||
MAX_WAIT=600 # 10 minutes max for Cloud-Init installation
|
||||
PORT_OPEN=0
|
||||
LAST_MSG_TIME=0
|
||||
|
||||
while [ $WAIT_COUNT -lt $MAX_WAIT ]; do
|
||||
if timeout 2 bash -c ">/dev/tcp/${VM_IP}/11443" 2>/dev/null; then
|
||||
PORT_OPEN=1
|
||||
msg_ok "UniFi OS Server is ready!"
|
||||
break
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
WAIT_COUNT=$((WAIT_COUNT + 10))
|
||||
|
||||
# Update message every 30 seconds
|
||||
if [ $((WAIT_COUNT - LAST_MSG_TIME)) -ge 30 ]; then
|
||||
echo -e "${BFR}${TAB}${YW}${HOLD}Installation in progress... ${WAIT_COUNT}s elapsed${CL}"
|
||||
echo -e "${TAB}${INFO}${YW}Monitor: ${BL}ssh ${CLOUDINIT_USER:-root}@${VM_IP} 'tail -f /var/log/unifi-install.log'${CL}"
|
||||
LAST_MSG_TIME=$WAIT_COUNT
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $PORT_OPEN -eq 1 ]; then
|
||||
echo -e "\n${TAB}${GATEWAY}${BOLD}${GN}✓ UniFi OS Server is ready!${CL}"
|
||||
echo -e "${TAB}${GATEWAY}${BOLD}${GN}✓ Access at: ${BGN}https://${VM_IP}:11443${CL}\n"
|
||||
else
|
||||
msg_ok "VM is running, UniFi OS installation in progress"
|
||||
echo -e "${TAB}${INFO}${YW}Installation runs via systemd service on first boot${CL}"
|
||||
echo -e "${TAB}${INFO}${YW}This takes 5-8 minutes${CL}"
|
||||
if [ "$USE_CLOUD_INIT" = "yes" ]; then
|
||||
echo -e "${TAB}${INFO}${YW}SSH: ${BL}ssh ${CLOUDINIT_USER:-root}@${VM_IP}${CL}"
|
||||
echo -e "${TAB}${INFO}${YW}Password: ${BGN}${CLOUDINIT_PASSWORD}${CL}"
|
||||
echo -e "${TAB}${INFO}${YW}Monitor: ${BL}tail -f /var/log/unifi-install.log${CL}"
|
||||
fi
|
||||
echo -e "${TAB}${INFO}${YW}UniFi OS will be at: ${BGN}https://${VM_IP}:11443${CL}"
|
||||
fi
|
||||
else
|
||||
msg_ok "VM is running (ID: ${VMID})"
|
||||
echo -e "${TAB}${INFO}${YW}Could not auto-detect IP address${CL}"
|
||||
if [ -z "$VM_IP" ]; then
|
||||
msg_error "Could not detect VM IP address"
|
||||
echo -e "${TAB}${INFO}${YW}Use Proxmox Console to login with Cloud-Init credentials${CL}"
|
||||
echo -e "${TAB}${INFO}${YW}User: ${BGN}${CLOUDINIT_USER:-root}${CL} / Password: ${BGN}${CLOUDINIT_PASSWORD}${CL}"
|
||||
echo -e "${TAB}${INFO}${YW}Monitor installation: ${BL}tail -f /var/log/unifi-install.log${CL}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Wait for SSH to be ready
|
||||
msg_info "Waiting for SSH to be ready"
|
||||
SSH_READY=0
|
||||
for i in {1..30}; do
|
||||
if timeout 5 sshpass -p "${CLOUDINIT_PASSWORD}" ssh -o ConnectTimeout=3 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
||||
"${CLOUDINIT_USER:-root}@${VM_IP}" "echo 'SSH Ready'" >/dev/null 2>&1; then
|
||||
SSH_READY=1
|
||||
msg_ok "SSH connection ready"
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
if [ $SSH_READY -eq 0 ]; then
|
||||
msg_error "SSH connection failed"
|
||||
echo -e "${TAB}${INFO}${YW}Manual login - User: ${BGN}${CLOUDINIT_USER:-root}${CL} / Password: ${BGN}${CLOUDINIT_PASSWORD}${CL}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if sshpass is installed
|
||||
if ! command -v sshpass &>/dev/null; then
|
||||
msg_info "Installing sshpass for automated SSH"
|
||||
apt-get update -qq >/dev/null 2>&1
|
||||
apt-get install -y sshpass -qq >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# Execute UniFi OS installation directly via SSH
|
||||
msg_info "Installing UniFi OS Server ${UOS_VERSION} (takes 4-6 minutes)"
|
||||
|
||||
# Create installation script
|
||||
INSTALL_SCRIPT=$(
|
||||
cat <<'EOFINSTALL'
|
||||
#!/bin/bash
|
||||
set -e
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
echo "[1/5] Updating system packages..."
|
||||
apt-get update -qq
|
||||
apt-get install -y curl wget ca-certificates podman uidmap slirp4netns iptables -qq
|
||||
|
||||
echo "[2/5] Configuring Podman..."
|
||||
loginctl enable-linger root
|
||||
|
||||
echo "[3/5] Downloading UniFi OS Server installer..."
|
||||
cd /root
|
||||
curl -fsSL "UNIFI_URL" -o unifi-installer.bin
|
||||
chmod +x unifi-installer.bin
|
||||
|
||||
echo "[4/5] Installing UniFi OS Server (this takes 3-5 minutes)..."
|
||||
./unifi-installer.bin install
|
||||
|
||||
echo "[5/5] Starting UniFi OS Server..."
|
||||
sleep 15
|
||||
|
||||
if systemctl list-unit-files | grep -q unifi-os-server; then
|
||||
systemctl enable unifi-os-server
|
||||
systemctl start unifi-os-server
|
||||
sleep 10
|
||||
|
||||
if systemctl is-active --quiet unifi-os-server; then
|
||||
echo "✓ UniFi OS Server is running"
|
||||
else
|
||||
echo "⚠ Service status:"
|
||||
systemctl status unifi-os-server --no-pager || true
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Installation completed!"
|
||||
EOFINSTALL
|
||||
)
|
||||
|
||||
# Replace URL placeholder
|
||||
INSTALL_SCRIPT="${INSTALL_SCRIPT//UNIFI_URL/$UOS_URL}"
|
||||
|
||||
# Execute installation via SSH (with output streaming)
|
||||
if sshpass -p "${CLOUDINIT_PASSWORD}" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
||||
"${CLOUDINIT_USER:-root}@${VM_IP}" "bash -s" <<<"$INSTALL_SCRIPT" 2>&1 | while IFS= read -r line; do
|
||||
echo -e "${TAB}${DGN}${line}${CL}"
|
||||
done; then
|
||||
msg_ok "UniFi OS Server installed successfully"
|
||||
else
|
||||
msg_error "Installation failed"
|
||||
echo -e "${TAB}${INFO}${YW}Check logs: ${BL}ssh ${CLOUDINIT_USER:-root}@${VM_IP}${CL}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Wait for UniFi OS web interface
|
||||
msg_info "Waiting for UniFi OS web interface (port 11443)"
|
||||
PORT_OPEN=0
|
||||
for i in {1..60}; do
|
||||
if timeout 2 bash -c ">/dev/tcp/${VM_IP}/11443" 2>/dev/null; then
|
||||
PORT_OPEN=1
|
||||
msg_ok "UniFi OS Server web interface is ready"
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo ""
|
||||
if [ $PORT_OPEN -eq 1 ]; then
|
||||
echo -e "${TAB}${GATEWAY}${BOLD}${GN}✓ UniFi OS Server is ready!${CL}"
|
||||
echo -e "${TAB}${GATEWAY}${BOLD}${GN}✓ Access at: ${BGN}https://${VM_IP}:11443${CL}"
|
||||
else
|
||||
echo -e "${TAB}${INFO}${YW}UniFi OS is installed but web interface not yet available${CL}"
|
||||
echo -e "${TAB}${INFO}${YW}Access at: ${BGN}https://${VM_IP}:11443${CL} ${YW}(may take 1-2 more minutes)${CL}"
|
||||
fi
|
||||
|
||||
echo -e "${TAB}${INFO}${DGN}SSH Access: ${BL}ssh ${CLOUDINIT_USER:-root}@${VM_IP}${CL}"
|
||||
echo -e "${TAB}${INFO}${DGN}Password: ${BGN}${CLOUDINIT_PASSWORD}${CL}"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
post_update_to_api "done" "none"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user