1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/funkwhale_ynh.git synced 2024-09-03 18:36:24 +02:00

Improve redis helper

This commit is contained in:
Jean-Baptiste Holcroft 2018-05-20 19:58:33 +02:00
parent 785cc05e4d
commit 9615629ed2
2 changed files with 15 additions and 9 deletions

View file

@ -6,20 +6,20 @@
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
path="/" (PATH)
admin="john" (USER)
is_public=1 (PUBLIC|public=1|private=0)
; Checks
pkg_linter=0
pkg_linter=1
setup_sub_dir=0
setup_root=0
setup_root=1
setup_nourl=0
setup_private=0
setup_public=0
setup_private=1
setup_public=1
upgrade=1
upgrade=1 from_commit=9b30b385673eb4dda1c85a84a9cacf8409cf4ab7
backup_restore=0
multi_instance=0
backup_restore=1
multi_instance=1
incorrect_path=0
port_already_use=0
change_url=0

View file

@ -12,20 +12,26 @@
# usage: ynh_redis_get_free_db
# | returns: the database number to use
ynh_redis_get_free_db() {
local result
local result max db
result=$(redis-cli INFO keyspace)
# get the num
max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+")
db=0
# default Debian setting is 15 databases
for i in $(seq 0 15)
for i in $(seq 0 "$max")
do
if ! echo "$result" | grep -q "db$i"
then
db=$i
break 1
db=-1
fi
done
test "$db" -eq -1 && ynh_die "No available Redis databases..."
echo "$db"
}