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:
parent
785cc05e4d
commit
9615629ed2
2 changed files with 15 additions and 9 deletions
|
@ -6,20 +6,20 @@
|
||||||
;; Test complet
|
;; Test complet
|
||||||
; Manifest
|
; Manifest
|
||||||
domain="domain.tld" (DOMAIN)
|
domain="domain.tld" (DOMAIN)
|
||||||
path="/path" (PATH)
|
path="/" (PATH)
|
||||||
admin="john" (USER)
|
admin="john" (USER)
|
||||||
is_public=1 (PUBLIC|public=1|private=0)
|
is_public=1 (PUBLIC|public=1|private=0)
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=0
|
pkg_linter=1
|
||||||
setup_sub_dir=0
|
setup_sub_dir=0
|
||||||
setup_root=0
|
setup_root=1
|
||||||
setup_nourl=0
|
setup_nourl=0
|
||||||
setup_private=0
|
setup_private=1
|
||||||
setup_public=0
|
setup_public=1
|
||||||
upgrade=1
|
upgrade=1
|
||||||
upgrade=1 from_commit=9b30b385673eb4dda1c85a84a9cacf8409cf4ab7
|
upgrade=1 from_commit=9b30b385673eb4dda1c85a84a9cacf8409cf4ab7
|
||||||
backup_restore=0
|
backup_restore=1
|
||||||
multi_instance=0
|
multi_instance=1
|
||||||
incorrect_path=0
|
incorrect_path=0
|
||||||
port_already_use=0
|
port_already_use=0
|
||||||
change_url=0
|
change_url=0
|
||||||
|
|
|
@ -12,20 +12,26 @@
|
||||||
# usage: ynh_redis_get_free_db
|
# usage: ynh_redis_get_free_db
|
||||||
# | returns: the database number to use
|
# | returns: the database number to use
|
||||||
ynh_redis_get_free_db() {
|
ynh_redis_get_free_db() {
|
||||||
local result
|
local result max db
|
||||||
result=$(redis-cli INFO keyspace)
|
result=$(redis-cli INFO keyspace)
|
||||||
|
|
||||||
|
# get the num
|
||||||
|
max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+")
|
||||||
|
|
||||||
db=0
|
db=0
|
||||||
# default Debian setting is 15 databases
|
# default Debian setting is 15 databases
|
||||||
for i in $(seq 0 15)
|
for i in $(seq 0 "$max")
|
||||||
do
|
do
|
||||||
if ! echo "$result" | grep -q "db$i"
|
if ! echo "$result" | grep -q "db$i"
|
||||||
then
|
then
|
||||||
db=$i
|
db=$i
|
||||||
break 1
|
break 1
|
||||||
|
db=-1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
test "$db" -eq -1 && ynh_die "No available Redis databases..."
|
||||||
|
|
||||||
echo "$db"
|
echo "$db"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue