diff --git a/tests/redis.conf b/tests/redis.conf new file mode 100644 index 00000000..e1ba4917 --- /dev/null +++ b/tests/redis.conf @@ -0,0 +1,10 @@ +ENABLED=true +RELEASE="noble" +TESTNAME="Redis install" + +testcase() {( + set -e + ./bin/armbian-config --api module_redis remove + ./bin/armbian-config --api module_redis install + ./bin/armbian-config --api module_redis status +)} diff --git a/tools/include/images/REDIS1.png b/tools/include/images/REDIS1.png new file mode 100644 index 00000000..c56184a2 Binary files /dev/null and b/tools/include/images/REDIS1.png differ diff --git a/tools/include/markdown/REDIS1-footer.md b/tools/include/markdown/REDIS1-footer.md new file mode 100644 index 00000000..dae7a1ab --- /dev/null +++ b/tools/include/markdown/REDIS1-footer.md @@ -0,0 +1,15 @@ +=== "Access to the service" + + Redis server is accessible on port **6379**: + + - Host: `redis://:6379` + +=== "Directories" + + - Data directory: `/armbian/redis/data` + +=== "View logs" + + ```sh + docker logs -f redis + ``` diff --git a/tools/include/markdown/REDIS1-header.md b/tools/include/markdown/REDIS1-header.md new file mode 100644 index 00000000..ca73fc3e --- /dev/null +++ b/tools/include/markdown/REDIS1-header.md @@ -0,0 +1,11 @@ +Redis is an open-source, in-memory data structure store, used as a database, cache, and message broker. +It supports a variety of data structures such as strings, hashes, lists, sets, and sorted sets. + +**Key Features:** +- Extremely fast performance with in-memory storage +- Persistence options (snapshotting and AOF) +- Pub/Sub messaging capabilities +- Built-in replication and high availability +- Simple API and wide client support + +Redis is widely used for real-time applications, caching layers, session stores, and lightweight queues across industries and platforms. diff --git a/tools/json/config.software.json b/tools/json/config.software.json index 5129555a..d67431be 100644 --- a/tools/json/config.software.json +++ b/tools/json/config.software.json @@ -1116,6 +1116,40 @@ "author": "@armbian", "condition": "module_mariadb status" }, + { + "id": "REDIS1", + "description": "Redis install", + "short": "Redis", + "about": "This operation will install Redis, a powerful in-memory key-value database", + "command": [ + "module_redis install" + ], + "status": "Stable", + "author": "@igorpecovnik", + "condition": "! module_redis status" + }, + { + "id": "REDIS2", + "description": "Redis remove", + "about": "This operation will remove Redis container", + "command": [ + "module_redis remove" + ], + "status": "Stable", + "author": "@igorpecovnik", + "condition": "module_redis status" + }, + { + "id": "REDIS3", + "description": "Redis purge with data folder", + "about": "This operation will purge Redis data and remove the container", + "command": [ + "module_redis purge" + ], + "status": "Stable", + "author": "@igorpecovnik", + "condition": "module_redis status" + }, { "id": "MYA001", "description": "phpMyAdmin web interface manager", diff --git a/tools/modules/software/module_redis.sh b/tools/modules/software/module_redis.sh new file mode 100644 index 00000000..91725faa --- /dev/null +++ b/tools/modules/software/module_redis.sh @@ -0,0 +1,89 @@ +module_options+=( + ["module_redis,author"]="" + ["module_redis,maintainer"]="@igorpecovnik" + ["module_redis,feature"]="module_redis" + ["module_redis,example"]="install remove purge status help" + ["module_redis,desc"]="Install Redis in a container (In-Memory Data Store)" + ["module_redis,status"]="Active" + ["module_redis,doc_link"]="https://redis.io/docs/" + ["module_redis,group"]="Database" + ["module_redis,port"]="6379" + ["module_redis,arch"]="x86-64 arm64" +) +# +# Module redis +# +function module_redis () { + local title="redis" + local condition=$(which "$title" 2>/dev/null) + + if pkg_installed docker-ce; then + local container=$(docker container ls -a | mawk '/redis?( |$)/{print $1}') + local image=$(docker image ls -a | mawk '/redis?( |$)/{print $3}') + fi + + local commands + IFS=' ' read -r -a commands <<< "${module_options["module_redis,example"]}" + + REDIS_BASE="${SOFTWARE_FOLDER}/redis" + + case "$1" in + "${commands[0]}") + pkg_installed docker-ce || module_docker install + [[ -d "$REDIS_BASE" ]] || mkdir -p "$REDIS_BASE" || { echo "Couldn't create storage directory: $REDIS_BASE"; exit 1; } + docker run -d \ + --name=redis \ + --net=lsio \ + -p 6379:6379 \ + -v "${REDIS_BASE}/data:/data" \ + --restart unless-stopped \ + redis:alpine + for i in $(seq 1 20); do + if docker inspect -f '{{ index .Config.Labels "org.opencontainers.image.version" }}' redis >/dev/null 2>&1 ; then + break + else + sleep 3 + fi + if [ $i -eq 20 ]; then + echo -e "\nTimed out waiting for ${title} to start, consult your container logs for more info (\`docker logs redis\`)" + exit 1 + fi + done + ;; + "${commands[1]}") + if [[ -n "${container}" ]]; then + docker container rm -f "$container" >/dev/null + fi + + if [[ -n "${image}" ]]; then + docker image rm "$image" >/dev/null + fi + ;; + "${commands[2]}") + ${module_options["module_redis,feature"]} ${commands[1]} + if [[ -n "${REDIS_BASE}" && "${REDIS_BASE}" != "/" ]]; then + rm -rf "${REDIS_BASE}" + fi + ;; + "${commands[3]}") + if [[ "${container}" && "${image}" ]]; then + return 0 + else + return 1 + fi + ;; + "${commands[4]}") + echo -e "\nUsage: ${module_options["module_redis,feature"]} " + echo -e "Commands: ${module_options["module_redis,example"]}" + echo "Available commands:" + echo -e "\tinstall\t- Install $title." + echo -e "\tremove\t- Remove $title." + echo -e "\tpurge\t- Purge $title data folder." + echo -e "\tstatus\t- Installation status $title." + echo + ;; + *) + ${module_options["module_redis,feature"]} ${commands[4]} + ;; + esac +}