From 07b8ff91b84b780f748a19acd1b7f47ba03654be Mon Sep 17 00:00:00 2001 From: MickLesk Date: Tue, 18 Aug 2026 10:18:33 +0200 Subject: [PATCH] redis: one script for Debian and Alpine, running on community-scripts/core First of the alpine pairs moved over. The two scripts become one with a section per OS, the same shape as valkey in ProxmoxVED: setup_deb_based/setup_alpine in the install script, update_deb_based/update_alpine in the ct script, dispatched by run_os_setup and run_os_update. The bootstrap now points at community-scripts/core rather than this repo's misc/build.func, which is where those two dispatchers live. Nothing in misc/ is touched. _CS_DEFAULT_URL has to be set before sourcing: core resolves the scripts root from the calling script's checkout, and when there is no checkout -- the usual `bash -c "$(curl ...)"` -- it falls back to ProxmoxVED. A ProxmoxVE script would then fetch its own -install.sh from the wrong repository. Setting only the fallback keeps a local checkout and a fork resolving through their own git remote, which is the point of that mechanism. Verified: both files parse, the bootstrap resolves the scripts root to ProxmoxVE and the engine to core, and the sections are the only functions defined. ct/alpine-redis.sh and install/alpine-redis-install.sh are deliberately left in place. They still run against misc/build.func, so bookmarked URLs keep working; retiring them is a separate decision with user-facing consequences. --- ct/redis.sh | 76 +++++++++++++++++++++++++++++++++------- install/redis-install.sh | 45 +++++++++++++++--------- 2 files changed, 92 insertions(+), 29 deletions(-) diff --git a/ct/redis.sh b/ct/redis.sh index e1c8e509c..c15b17780 100644 --- a/ct/redis.sh +++ b/ct/redis.sh @@ -1,40 +1,90 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +_CS_DEFAULT_URL="https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main" +_cs_boot="${COMMUNITY_SCRIPTS_CORE_DIR:-$(dirname "${BASH_SOURCE[0]}")/../../core}/core/build.func" +source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/build.func") # Copyright (c) 2021-2026 tteck -# Author: tteck (tteckster) +# Author: tteck (tteckster) | MickLesk (CanbiZ) # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # Source: https://redis.io/ APP="Redis" var_tags="${var_tags:-database}" var_cpu="${var_cpu:-1}" -var_ram="${var_ram:-1024}" -var_disk="${var_disk:-4}" -var_os="${var_os:-debian}" -var_version="${var_version:-13}" var_arm64="${var_arm64:-yes}" var_unprivileged="${var_unprivileged:-1}" +if [[ -z "${var_os:-}" ]] && command -v pveversion >/dev/null 2>&1; then + var_os=$(msg_menu "Choose the container OS" \ + "debian" "Debian 13" \ + "alpine" "Alpine 3.24 (smaller footprint)") +fi + +if [[ "${var_os:-}" == "alpine" ]]; then + var_ram="${var_ram:-256}" + var_disk="${var_disk:-1}" + var_version="${var_version:-3.24}" +else + var_ram="${var_ram:-1024}" + var_disk="${var_disk:-4}" + var_version="${var_version:-13}" +fi header_info "$APP" variables color catch_errors -function update_script() { - header_info - check_container_storage - check_container_resources +update_deb_based() { if [[ ! -f /lib/systemd/system/redis-server.service ]]; then msg_error "No ${APP} Installation Found!" - exit + exit 1 fi msg_info "Updating $APP LXC" $STD apt update $STD apt upgrade -y msg_ok "Updated $APP LXC" - msg_ok "Updated successfully!" - exit +} + +update_alpine() { + if [[ ! -f /etc/init.d/redis ]]; then + msg_error "No ${APP} Installation Found!" + exit 1 + fi + + LXCIP=$(ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) + CHOICE=$(msg_menu "Redis Management" \ + "1" "Update Redis" \ + "2" "Allow 0.0.0.0 for listening" \ + "3" "Allow only ${LXCIP} for listening") + + case "$CHOICE" in + 1) + msg_info "Updating Redis" + $STD apk update + $STD apk upgrade redis + rc-service redis restart + msg_ok "Updated Redis" + ;; + 2) + msg_info "Setting Redis to listen on all interfaces" + sed -i 's/^bind .*/bind 0.0.0.0/' /etc/redis.conf + rc-service redis restart + msg_ok "Redis now listens on all interfaces" + ;; + 3) + msg_info "Setting Redis to listen only on ${LXCIP}" + sed -i "s/^bind .*/bind ${LXCIP}/" /etc/redis.conf + rc-service redis restart + msg_ok "Redis now listens only on ${LXCIP}" + ;; + esac +} + +function update_script() { + header_info + check_container_storage + check_container_resources + run_os_update } start diff --git a/install/redis-install.sh b/install/redis-install.sh index 09b02db67..0ba452994 100644 --- a/install/redis-install.sh +++ b/install/redis-install.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Copyright (c) 2021-2026 tteck -# Author: tteck (tteckster) +# Author: tteck (tteckster) | MickLesk (CanbiZ) # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # Source: https://redis.io/ @@ -13,23 +13,36 @@ setting_up_container network_check update_os -msg_info "Installing Dependencies" -$STD apt install -y apt-transport-https -msg_ok "Installed Dependencies" +setup_deb_based() { + msg_info "Installing Dependencies" + $STD apt install -y apt-transport-https + msg_ok "Installed Dependencies" -msg_info "Setting up Redis Repository" -setup_deb822_repo \ - "redis" \ - "https://packages.redis.io/gpg" \ - "https://packages.redis.io/deb" \ - "trixie" -msg_ok "Setup Redis Repository" + msg_info "Setting up Redis Repository" + setup_deb822_repo \ + "redis" \ + "https://packages.redis.io/gpg" \ + "https://packages.redis.io/deb" \ + "trixie" + msg_ok "Setup Redis Repository" -msg_info "Setting up Redis" -$STD apt install -y redis -sed -i 's/^bind .*/bind 0.0.0.0/' /etc/redis/redis.conf -systemctl enable -q --now redis-server -msg_ok "Setup Redis" + msg_info "Setting up Redis" + $STD apt install -y redis + sed -i 's/^bind .*/bind 0.0.0.0/' /etc/redis/redis.conf + systemctl enable -q --now redis-server + msg_ok "Setup Redis" +} + +setup_alpine() { + msg_info "Installing Redis" + $STD apk add redis + $STD sed -i 's/^bind .*/bind 0.0.0.0/' /etc/redis.conf + $STD rc-update add redis default + $STD rc-service redis start + msg_ok "Installed Redis" +} + +run_os_setup motd_ssh customize