mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-03-21 09:23:00 +01:00
Compare commits
6 Commits
refactor/p
...
MickLesk-p
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87cbfcea70 | ||
|
|
7c79b278eb | ||
|
|
ee01971321 | ||
|
|
aede3fe092 | ||
|
|
c0da26c179 | ||
|
|
be10f822e5 |
@@ -23,7 +23,7 @@ function update_script() {
|
|||||||
header_info
|
header_info
|
||||||
check_container_storage
|
check_container_storage
|
||||||
check_container_resources
|
check_container_resources
|
||||||
if [[ ! -f /etc/containers/systemd/homeassistant.container ]]; then
|
if [[ ! -f /etc/systemd/system/homeassistant.service ]]; then
|
||||||
msg_error "No ${APP} Installation Found!"
|
msg_error "No ${APP} Installation Found!"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -45,58 +45,32 @@ systemctl enable -q --now podman.socket
|
|||||||
echo -e 'unqualified-search-registries=["docker.io"]' >>/etc/containers/registries.conf
|
echo -e 'unqualified-search-registries=["docker.io"]' >>/etc/containers/registries.conf
|
||||||
msg_ok "Installed Podman"
|
msg_ok "Installed Podman"
|
||||||
|
|
||||||
mkdir -p /etc/containers/systemd
|
|
||||||
|
|
||||||
read -r -p "${TAB3}Would you like to add Portainer? <y/N> " prompt
|
read -r -p "${TAB3}Would you like to add Portainer? <y/N> " prompt
|
||||||
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
|
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
|
||||||
msg_info "Installing Portainer $PORTAINER_LATEST_VERSION"
|
msg_info "Installing Portainer $PORTAINER_LATEST_VERSION"
|
||||||
podman volume create portainer_data >/dev/null
|
podman volume create portainer_data >/dev/null
|
||||||
cat <<EOF >/etc/containers/systemd/portainer.container
|
$STD podman run -d \
|
||||||
[Unit]
|
-p 8000:8000 \
|
||||||
Description=Portainer Container
|
-p 9443:9443 \
|
||||||
After=network-online.target
|
--name=portainer \
|
||||||
|
--restart=always \
|
||||||
[Container]
|
-v /run/podman/podman.sock:/var/run/docker.sock \
|
||||||
Image=docker.io/portainer/portainer-ce:latest
|
-v portainer_data:/data \
|
||||||
ContainerName=portainer
|
portainer/portainer-ce:latest
|
||||||
PublishPort=8000:8000
|
|
||||||
PublishPort=9443:9443
|
|
||||||
Volume=/run/podman/podman.sock:/var/run/docker.sock
|
|
||||||
Volume=portainer_data:/data
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Restart=always
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=default.target multi-user.target
|
|
||||||
EOF
|
|
||||||
systemctl daemon-reload
|
|
||||||
systemctl enable -q --now portainer
|
|
||||||
msg_ok "Installed Portainer $PORTAINER_LATEST_VERSION"
|
msg_ok "Installed Portainer $PORTAINER_LATEST_VERSION"
|
||||||
else
|
else
|
||||||
read -r -p "${TAB3}Would you like to add the Portainer Agent? <y/N> " prompt
|
read -r -p "${TAB3}Would you like to add the Portainer Agent? <y/N> " prompt
|
||||||
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
|
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
|
||||||
msg_info "Installing Portainer agent $PORTAINER_AGENT_LATEST_VERSION"
|
msg_info "Installing Portainer agent $PORTAINER_AGENT_LATEST_VERSION"
|
||||||
cat <<EOF >/etc/containers/systemd/portainer-agent.container
|
podman volume create temp >/dev/null
|
||||||
[Unit]
|
podman volume remove temp >/dev/null
|
||||||
Description=Portainer Agent Container
|
$STD podman run -d \
|
||||||
After=network-online.target
|
-p 9001:9001 \
|
||||||
|
--name portainer_agent \
|
||||||
[Container]
|
--restart=always \
|
||||||
Image=docker.io/portainer/agent:latest
|
-v /run/podman/podman.sock:/var/run/docker.sock \
|
||||||
ContainerName=portainer_agent
|
-v /var/lib/containers/storage/volumes:/var/lib/docker/volumes \
|
||||||
PublishPort=9001:9001
|
portainer/agent
|
||||||
Volume=/run/podman/podman.sock:/var/run/docker.sock
|
|
||||||
Volume=/var/lib/containers/storage/volumes:/var/lib/docker/volumes
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Restart=always
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=default.target multi-user.target
|
|
||||||
EOF
|
|
||||||
systemctl daemon-reload
|
|
||||||
systemctl enable -q --now portainer-agent
|
|
||||||
msg_ok "Installed Portainer Agent $PORTAINER_AGENT_LATEST_VERSION"
|
msg_ok "Installed Portainer Agent $PORTAINER_AGENT_LATEST_VERSION"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -107,28 +81,18 @@ msg_ok "Pulled Home Assistant Image"
|
|||||||
|
|
||||||
msg_info "Installing Home Assistant"
|
msg_info "Installing Home Assistant"
|
||||||
$STD podman volume create hass_config
|
$STD podman volume create hass_config
|
||||||
cat <<EOF >/etc/containers/systemd/homeassistant.container
|
$STD podman run -d \
|
||||||
[Unit]
|
--name homeassistant \
|
||||||
Description=Home Assistant Container
|
--restart unless-stopped \
|
||||||
After=network-online.target
|
-v /dev:/dev \
|
||||||
|
-v hass_config:/config \
|
||||||
[Container]
|
-v /etc/localtime:/etc/localtime:ro \
|
||||||
Image=docker.io/homeassistant/home-assistant:stable
|
-v /etc/timezone:/etc/timezone:ro \
|
||||||
ContainerName=homeassistant
|
--net=host \
|
||||||
Volume=/dev:/dev
|
homeassistant/home-assistant:stable
|
||||||
Volume=hass_config:/config
|
podman generate systemd \
|
||||||
Volume=/etc/localtime:/etc/localtime:ro
|
--new --name homeassistant \
|
||||||
Volume=/etc/timezone:/etc/timezone:ro
|
>/etc/systemd/system/homeassistant.service
|
||||||
Network=host
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Restart=always
|
|
||||||
TimeoutStartSec=300
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=default.target multi-user.target
|
|
||||||
EOF
|
|
||||||
systemctl daemon-reload
|
|
||||||
systemctl enable -q --now homeassistant
|
systemctl enable -q --now homeassistant
|
||||||
msg_ok "Installed Home Assistant"
|
msg_ok "Installed Home Assistant"
|
||||||
|
|
||||||
|
|||||||
@@ -45,58 +45,32 @@ systemctl enable -q --now podman.socket
|
|||||||
echo -e 'unqualified-search-registries=["docker.io"]' >>/etc/containers/registries.conf
|
echo -e 'unqualified-search-registries=["docker.io"]' >>/etc/containers/registries.conf
|
||||||
msg_ok "Installed Podman"
|
msg_ok "Installed Podman"
|
||||||
|
|
||||||
mkdir -p /etc/containers/systemd
|
|
||||||
|
|
||||||
read -r -p "${TAB3}Would you like to add Portainer? <y/N> " prompt
|
read -r -p "${TAB3}Would you like to add Portainer? <y/N> " prompt
|
||||||
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
|
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
|
||||||
msg_info "Installing Portainer $PORTAINER_LATEST_VERSION"
|
msg_info "Installing Portainer $PORTAINER_LATEST_VERSION"
|
||||||
podman volume create portainer_data >/dev/null
|
podman volume create portainer_data >/dev/null
|
||||||
cat <<EOF >/etc/containers/systemd/portainer.container
|
$STD podman run -d \
|
||||||
[Unit]
|
-p 8000:8000 \
|
||||||
Description=Portainer Container
|
-p 9443:9443 \
|
||||||
After=network-online.target
|
--name=portainer \
|
||||||
|
--restart=always \
|
||||||
[Container]
|
-v /run/podman/podman.sock:/var/run/docker.sock \
|
||||||
Image=docker.io/portainer/portainer-ce:latest
|
-v portainer_data:/data \
|
||||||
ContainerName=portainer
|
portainer/portainer-ce:latest
|
||||||
PublishPort=8000:8000
|
|
||||||
PublishPort=9443:9443
|
|
||||||
Volume=/run/podman/podman.sock:/var/run/docker.sock
|
|
||||||
Volume=portainer_data:/data
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Restart=always
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=default.target multi-user.target
|
|
||||||
EOF
|
|
||||||
systemctl daemon-reload
|
|
||||||
systemctl enable -q --now portainer
|
|
||||||
msg_ok "Installed Portainer $PORTAINER_LATEST_VERSION"
|
msg_ok "Installed Portainer $PORTAINER_LATEST_VERSION"
|
||||||
else
|
else
|
||||||
read -r -p "${TAB3}Would you like to add the Portainer Agent? <y/N> " prompt
|
read -r -p "${TAB3}Would you like to add the Portainer Agent? <y/N> " prompt
|
||||||
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
|
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
|
||||||
msg_info "Installing Portainer agent $PORTAINER_AGENT_LATEST_VERSION"
|
msg_info "Installing Portainer agent $PORTAINER_AGENT_LATEST_VERSION"
|
||||||
cat <<EOF >/etc/containers/systemd/portainer-agent.container
|
podman volume create temp >/dev/null
|
||||||
[Unit]
|
podman volume remove temp >/dev/null
|
||||||
Description=Portainer Agent Container
|
$STD podman run -d \
|
||||||
After=network-online.target
|
-p 9001:9001 \
|
||||||
|
--name portainer_agent \
|
||||||
[Container]
|
--restart=always \
|
||||||
Image=docker.io/portainer/agent:latest
|
-v /run/podman/podman.sock:/var/run/docker.sock \
|
||||||
ContainerName=portainer_agent
|
-v /var/lib/containers/storage/volumes:/var/lib/docker/volumes \
|
||||||
PublishPort=9001:9001
|
portainer/agent
|
||||||
Volume=/run/podman/podman.sock:/var/run/docker.sock
|
|
||||||
Volume=/var/lib/containers/storage/volumes:/var/lib/docker/volumes
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Restart=always
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=default.target multi-user.target
|
|
||||||
EOF
|
|
||||||
systemctl daemon-reload
|
|
||||||
systemctl enable -q --now portainer-agent
|
|
||||||
msg_ok "Installed Portainer Agent $PORTAINER_AGENT_LATEST_VERSION"
|
msg_ok "Installed Portainer Agent $PORTAINER_AGENT_LATEST_VERSION"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -6698,22 +6698,38 @@ EOF
|
|||||||
# - Optionally uses official PGDG repository for specific versions
|
# - Optionally uses official PGDG repository for specific versions
|
||||||
# - Detects existing PostgreSQL version
|
# - Detects existing PostgreSQL version
|
||||||
# - Dumps all databases before upgrade
|
# - Dumps all databases before upgrade
|
||||||
# - Installs optional PG_MODULES (e.g. postgis, contrib)
|
# - Installs optional PG_MODULES (e.g. postgis, contrib, cron)
|
||||||
# - Restores dumped data post-upgrade
|
# - Restores dumped data post-upgrade
|
||||||
#
|
#
|
||||||
# Variables:
|
# Variables:
|
||||||
# USE_PGDG_REPO - Use official PGDG repository (default: true)
|
# USE_PGDG_REPO - Use official PGDG repository (default: true)
|
||||||
# Set to "false" to use distro packages instead
|
# Set to "false" to use distro packages instead
|
||||||
# PG_VERSION - Major PostgreSQL version (e.g. 15, 16) (default: 16)
|
# PG_VERSION - Major PostgreSQL version (e.g. 15, 16) (default: 16)
|
||||||
# PG_MODULES - Comma-separated list of modules (e.g. "postgis,contrib")
|
# PG_MODULES - Comma-separated list of modules (e.g. "postgis,contrib,cron")
|
||||||
#
|
#
|
||||||
# Examples:
|
# Examples:
|
||||||
# setup_postgresql # Uses PGDG repo, PG 16
|
# setup_postgresql # Uses PGDG repo, PG 16
|
||||||
# PG_VERSION="17" setup_postgresql # Specific version from PGDG
|
# PG_VERSION="17" setup_postgresql # Specific version from PGDG
|
||||||
# USE_PGDG_REPO=false setup_postgresql # Uses distro package instead
|
# USE_PGDG_REPO=false setup_postgresql # Uses distro package instead
|
||||||
|
# PG_VERSION="17" PG_MODULES="cron" setup_postgresql # With pg_cron module
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
function setup_postgresql() {
|
# Internal helper: Configure shared_preload_libraries for pg_cron
|
||||||
|
_configure_pg_cron_preload() {
|
||||||
|
local modules="${1:-}"
|
||||||
|
[[ -z "$modules" ]] && return 0
|
||||||
|
if [[ ",$modules," == *",cron,"* ]]; then
|
||||||
|
local current_libs
|
||||||
|
current_libs=$(sudo -u postgres psql -tAc "SHOW shared_preload_libraries;" 2>/dev/null || echo "")
|
||||||
|
if [[ "$current_libs" != *"pg_cron"* ]]; then
|
||||||
|
local new_libs="${current_libs:+${current_libs},}pg_cron"
|
||||||
|
$STD sudo -u postgres psql -c "ALTER SYSTEM SET shared_preload_libraries = '${new_libs}';"
|
||||||
|
$STD systemctl restart postgresql
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_postgresql() {
|
||||||
local PG_VERSION="${PG_VERSION:-16}"
|
local PG_VERSION="${PG_VERSION:-16}"
|
||||||
local PG_MODULES="${PG_MODULES:-}"
|
local PG_MODULES="${PG_MODULES:-}"
|
||||||
local USE_PGDG_REPO="${USE_PGDG_REPO:-true}"
|
local USE_PGDG_REPO="${USE_PGDG_REPO:-true}"
|
||||||
@@ -6751,6 +6767,7 @@ function setup_postgresql() {
|
|||||||
$STD apt install -y "postgresql-${CURRENT_PG_VERSION}-${module}" 2>/dev/null || true
|
$STD apt install -y "postgresql-${CURRENT_PG_VERSION}-${module}" 2>/dev/null || true
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
_configure_pg_cron_preload "$PG_MODULES"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -6786,6 +6803,7 @@ function setup_postgresql() {
|
|||||||
$STD apt install -y "postgresql-${INSTALLED_VERSION}-${module}" 2>/dev/null || true
|
$STD apt install -y "postgresql-${INSTALLED_VERSION}-${module}" 2>/dev/null || true
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
_configure_pg_cron_preload "$PG_MODULES"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -6807,6 +6825,7 @@ function setup_postgresql() {
|
|||||||
$STD apt install -y "postgresql-${PG_VERSION}-${module}" 2>/dev/null || true
|
$STD apt install -y "postgresql-${PG_VERSION}-${module}" 2>/dev/null || true
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
_configure_pg_cron_preload "$PG_MODULES"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -6834,13 +6853,16 @@ function setup_postgresql() {
|
|||||||
local SUITE
|
local SUITE
|
||||||
case "$DISTRO_CODENAME" in
|
case "$DISTRO_CODENAME" in
|
||||||
trixie | forky | sid)
|
trixie | forky | sid)
|
||||||
|
|
||||||
if verify_repo_available "https://apt.postgresql.org/pub/repos/apt" "trixie-pgdg"; then
|
if verify_repo_available "https://apt.postgresql.org/pub/repos/apt" "trixie-pgdg"; then
|
||||||
SUITE="trixie-pgdg"
|
SUITE="trixie-pgdg"
|
||||||
|
|
||||||
else
|
else
|
||||||
msg_warn "PGDG repo not available for ${DISTRO_CODENAME}, falling back to distro packages"
|
msg_warn "PGDG repo not available for ${DISTRO_CODENAME}, falling back to distro packages"
|
||||||
USE_PGDG_REPO=false setup_postgresql
|
USE_PGDG_REPO=false setup_postgresql
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
SUITE=$(get_fallback_suite "$DISTRO_ID" "$DISTRO_CODENAME" "https://apt.postgresql.org/pub/repos/apt")
|
SUITE=$(get_fallback_suite "$DISTRO_ID" "$DISTRO_CODENAME" "https://apt.postgresql.org/pub/repos/apt")
|
||||||
@@ -6924,6 +6946,7 @@ function setup_postgresql() {
|
|||||||
}
|
}
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
_configure_pg_cron_preload "$PG_MODULES"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@@ -6942,6 +6965,7 @@ function setup_postgresql() {
|
|||||||
# PG_DB_NAME="immich" PG_DB_USER="immich" PG_DB_EXTENSIONS="pgvector" setup_postgresql_db
|
# PG_DB_NAME="immich" PG_DB_USER="immich" PG_DB_EXTENSIONS="pgvector" setup_postgresql_db
|
||||||
# PG_DB_NAME="ghostfolio" PG_DB_USER="ghostfolio" PG_DB_GRANT_SUPERUSER="true" setup_postgresql_db
|
# PG_DB_NAME="ghostfolio" PG_DB_USER="ghostfolio" PG_DB_GRANT_SUPERUSER="true" setup_postgresql_db
|
||||||
# PG_DB_NAME="adventurelog" PG_DB_USER="adventurelog" PG_DB_EXTENSIONS="postgis" setup_postgresql_db
|
# PG_DB_NAME="adventurelog" PG_DB_USER="adventurelog" PG_DB_EXTENSIONS="postgis" setup_postgresql_db
|
||||||
|
# PG_DB_NAME="splitpro" PG_DB_USER="splitpro" PG_DB_EXTENSIONS="pg_cron" setup_postgresql_db
|
||||||
#
|
#
|
||||||
# Variables:
|
# Variables:
|
||||||
# PG_DB_NAME - Database name (required)
|
# PG_DB_NAME - Database name (required)
|
||||||
@@ -6973,6 +6997,13 @@ function setup_postgresql_db() {
|
|||||||
$STD sudo -u postgres psql -c "CREATE ROLE $PG_DB_USER WITH LOGIN PASSWORD '$PG_DB_PASS';"
|
$STD sudo -u postgres psql -c "CREATE ROLE $PG_DB_USER WITH LOGIN PASSWORD '$PG_DB_PASS';"
|
||||||
$STD sudo -u postgres psql -c "CREATE DATABASE $PG_DB_NAME WITH OWNER $PG_DB_USER ENCODING 'UTF8' TEMPLATE template0;"
|
$STD sudo -u postgres psql -c "CREATE DATABASE $PG_DB_NAME WITH OWNER $PG_DB_USER ENCODING 'UTF8' TEMPLATE template0;"
|
||||||
|
|
||||||
|
# Configure pg_cron database BEFORE creating the extension (must be set before pg_cron loads)
|
||||||
|
if [[ -n "${PG_DB_EXTENSIONS:-}" ]] && [[ ",${PG_DB_EXTENSIONS//[[:space:]]/}," == *",pg_cron,"* ]]; then
|
||||||
|
$STD sudo -u postgres psql -c "ALTER SYSTEM SET cron.database_name = '${PG_DB_NAME}';"
|
||||||
|
$STD sudo -u postgres psql -c "ALTER SYSTEM SET cron.timezone = 'UTC';"
|
||||||
|
$STD systemctl restart postgresql
|
||||||
|
fi
|
||||||
|
|
||||||
# Install extensions (comma-separated)
|
# Install extensions (comma-separated)
|
||||||
if [[ -n "${PG_DB_EXTENSIONS:-}" ]]; then
|
if [[ -n "${PG_DB_EXTENSIONS:-}" ]]; then
|
||||||
IFS=',' read -ra EXT_LIST <<<"${PG_DB_EXTENSIONS:-}"
|
IFS=',' read -ra EXT_LIST <<<"${PG_DB_EXTENSIONS:-}"
|
||||||
@@ -6982,6 +7013,12 @@ function setup_postgresql_db() {
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Grant pg_cron schema permissions to DB user
|
||||||
|
if [[ -n "${PG_DB_EXTENSIONS:-}" ]] && [[ ",${PG_DB_EXTENSIONS//[[:space:]]/}," == *",pg_cron,"* ]]; then
|
||||||
|
$STD sudo -u postgres psql -d "$PG_DB_NAME" -c "GRANT USAGE ON SCHEMA cron TO ${PG_DB_USER};"
|
||||||
|
$STD sudo -u postgres psql -d "$PG_DB_NAME" -c "GRANT ALL ON ALL TABLES IN SCHEMA cron TO ${PG_DB_USER};"
|
||||||
|
fi
|
||||||
|
|
||||||
# ALTER ROLE settings for Django/Rails compatibility (unless skipped)
|
# ALTER ROLE settings for Django/Rails compatibility (unless skipped)
|
||||||
if [[ "${PG_DB_SKIP_ALTER_ROLE:-}" != "true" ]]; then
|
if [[ "${PG_DB_SKIP_ALTER_ROLE:-}" != "true" ]]; then
|
||||||
$STD sudo -u postgres psql -c "ALTER ROLE $PG_DB_USER SET client_encoding TO 'utf8';"
|
$STD sudo -u postgres psql -c "ALTER ROLE $PG_DB_USER SET client_encoding TO 'utf8';"
|
||||||
@@ -7023,7 +7060,6 @@ function setup_postgresql_db() {
|
|||||||
export PG_DB_USER
|
export PG_DB_USER
|
||||||
export PG_DB_PASS
|
export PG_DB_PASS
|
||||||
}
|
}
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Installs rbenv and ruby-build, installs Ruby and optionally Rails.
|
# Installs rbenv and ruby-build, installs Ruby and optionally Rails.
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user