-
Notifications
You must be signed in to change notification settings - Fork 9
/
redis.sh
executable file
·55 lines (50 loc) · 1.06 KB
/
redis.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
set -e
cd "${0%/*}"
if [[ -z "$XDG_CACHE_HOME" ]]; then
cache_dir="$HOME/.cache"
else
cache_dir="$XDG_CACHE_HOME"
fi
if [[ -z "$XDG_DATA_HOME" ]]; then
logs_dir="$HOME/.local/share"
else
logs_dir="$XDG_DATA_HOME"
fi
startup () {
mkdir -p "$cache_dir/kocka-logger"
mkdir -p "$logs_dir/kocka-logger/logs"
redis-server redis.conf --dir "$cache_dir/kocka-logger" --logfile "$logs_dir/kocka-logger/logs/redis.log"
}
shutdown () {
redis-cli -p 14052 shutdown
}
case $1 in
start)
# Start the Redis server.
startup
;;
stop)
# Stop the Redis server.
shutdown
;;
restart)
# Restarts the Redis server.
shutdown
startup
;;
reset)
# Resets Redis data and restarts the server.
shutdown
rm cache/redis.rdb
startup
;;
cli)
# Enters Redis CLI.
redis-cli -p 14052
;;
*)
# Outputs usage instructions.
echo "Usage: $0 start | stop | restart | reset | cli"
;;
esac