Files
shell_sequencer/seqs/redis.sh

87 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
toolName=redis
toolDeps=redis-server
# Get script working directory
# (when called from a different directory)
WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)"
CONFIG=0
SCRIPT_NAME=$(basename -- $0)
SCRIPT_NAME=${SCRIPT_NAME%%.*}
CONFIG_FILE_NAME="${SCRIPT_NAME}.cfg"
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
step_config() {
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
if [ $? -eq 0 ] ; then
CONFIG=1
fi
}
step_1_info() { echo "Install $toolName"; }
step_1_alias() { ALIAS="install"; }
step_1() {
local aptOpt=
if [ $QUIET -ne 0 ];then
aptOpt="-y"
fi
exe apt update
exe apt install $toolDeps $aptOpt
}
step_2_info() { echo "Installation notes"; }
step_2_alias() { ALIAS="notes"; }
step_2() {
cat <<NOTES_EOF
# For php applications make sure php-redis is installed
apt install php-redis
# Bind to localhsot
[/etc/redis/redis.conf]
bind 127.0.0.1 ::1
# or use socket
unixsocket /var/run/redis/redis-server.sock
unixsocketperm 770
## Password protect
requirepass verystrongpassword
# Nextcloud configuration
[/var/www/nextcloud/config/config.php]
'memcache.locking' => '\\OC\\Memcache\\Redis',
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'redis' =>
array (
'host' => '/var/run/redis/redis-server.sock',
'port' => 0,
'password' => 'verystrongpassword',
'timeout' => 0.0,
),
NOTES_EOF
}
step_10_info() {
echoinfoArgs "[CLI COMMAND]"
echo "Execute redis-cli commands"
echoinfo " [CLI COMMAND]"
echoinfo " e.g. info"
}
step_10_alias() { ALIAS="cli"; }
step_10() {
shift
local cliCmd="$@"
if [ ! -z "$REDIS_AUTH" ] ; then
#exe "echo -e \"AUTH=$REDIS_AUTH$cliCmd\" | redis-cli"
exe redis-cli -a "$REDIS_AUTH" $cliCmd
else
exe redis-cli $cliCmd
fi
}
VERSION_SEQREV=14
. /usr/local/bin/sequencer.sh