From 37b789450431c34cf562a07ef1a7aebf289bcbd3 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 24 Mar 2025 12:32:45 +0100 Subject: [PATCH] Extension: Redis Alpine Installation (#3367) * Extension: Redis Alpine Installation * change website note --- ct/alpine-redis.sh | 72 +++++++++++++++++++++++++++++++++ frontend/public/json/redis.json | 13 +++++- install/alpine-redis-install.sh | 35 ++++++++++++++++ 3 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 ct/alpine-redis.sh create mode 100644 install/alpine-redis-install.sh diff --git a/ct/alpine-redis.sh b/ct/alpine-redis.sh new file mode 100644 index 000000000..2080461ca --- /dev/null +++ b/ct/alpine-redis.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://redis.io/ + +APP="Alpine-Redis" +var_tags="alpine;database" +var_cpu="1" +var_ram="256" +var_disk="1" +var_os="alpine" +var_version="3.21" +var_unprivileged="1" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + if ! apk -e info newt >/dev/null 2>&1; then + apk add -q newt + fi + LXCIP=$(ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) + while true; do + CHOICE=$( + whiptail --backtitle "Proxmox VE Helper Scripts" --title "Redis Management" --menu "Select option" 11 58 3 \ + "1" "Update Redis" \ + "2" "Allow 0.0.0.0 for listening" \ + "3" "Allow only ${LXCIP} for listening" 3>&2 2>&1 1>&3 + ) + exit_status=$? + if [ $exit_status == 1 ]; then + clear + exit-script + fi + header_info + case $CHOICE in + 1) + msg_info "Updating Redis" + apk update && apk upgrade redis + rc-service redis restart + msg_ok "Redis updated successfully!" + exit + ;; + 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!" + exit + ;; + 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}!" + exit + ;; + esac + done +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable on port 6379. + ${BL}redis-cli -h ${IP} -p 6379${CL} \n" \ No newline at end of file diff --git a/frontend/public/json/redis.json b/frontend/public/json/redis.json index 099ddfd4e..3f633f8c4 100644 --- a/frontend/public/json/redis.json +++ b/frontend/public/json/redis.json @@ -24,6 +24,17 @@ "os": "debian", "version": "12" } + }, + { + "type": "alpine", + "script": "ct/alpine-redis.sh", + "resources": { + "cpu": 1, + "ram": 256, + "hdd": 1, + "os": "alpine", + "version": "3.21" + } } ], "default_credentials": { @@ -32,7 +43,7 @@ }, "notes": [ { - "text": "Redis Configuration: `nano /etc/redis/redis.conf`", + "text": "Redis Configuration: `nano /etc/redis/redis.conf` or in Alpine: `nano /etc/redis.conf`", "type": "info" } ] diff --git a/install/alpine-redis-install.sh b/install/alpine-redis-install.sh new file mode 100644 index 000000000..2fb4140cd --- /dev/null +++ b/install/alpine-redis-install.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://redis.io/ + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apk add \ + newt \ + curl \ + openssh \ + nano \ + mc \ + gpg + +msg_ok "Installed Dependencies" + +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" + +motd_ssh +customize \ No newline at end of file