mirror of
https://github.com/YunoHost-Apps/penpot_ynh.git
synced 2024-09-03 19:56:56 +02:00
Redis helpers.
This commit is contained in:
parent
cb185a6e4c
commit
807304e3e0
2 changed files with 50 additions and 4 deletions
|
@ -10,3 +10,41 @@ current_hash=cc5b1c950be5b1b290ea76e3419057dffaeab797
|
|||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
# get the first available redis database
|
||||
#
|
||||
# usage: ynh_redis_get_free_db
|
||||
# | returns: the database number to use
|
||||
ynh_redis_get_free_db() {
|
||||
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 "$max")
|
||||
do
|
||||
if ! echo "$result" | grep -q "db$i"
|
||||
then
|
||||
db=$i
|
||||
break 1
|
||||
fi
|
||||
db=-1
|
||||
done
|
||||
|
||||
test "$db" -eq -1 && ynh_die --message="No available Redis databases..."
|
||||
|
||||
echo "$db"
|
||||
}
|
||||
|
||||
# Create a master password and set up global settings
|
||||
# Please always call this script in install and restore scripts
|
||||
#
|
||||
# usage: ynh_redis_remove_db database
|
||||
# | arg: database - the database to erase
|
||||
ynh_redis_remove_db() {
|
||||
local db=$1
|
||||
redis-cli -n "$db" flushall
|
||||
}
|
|
@ -16,13 +16,19 @@ source /usr/share/yunohost/helpers
|
|||
ynh_script_progression --message="Removing system configurations related to $app..."
|
||||
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||
if ynh_exec_warn_less yunohost service status $app-backend >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app service integration..."
|
||||
yunohost service remove $app
|
||||
ynh_script_progression --message="Removing $app-backend service integration..."
|
||||
yunohost service remove $app-backend
|
||||
ynh_remove_systemd_config --service="$app-backend"
|
||||
fi
|
||||
|
||||
ynh_remove_systemd_config
|
||||
if ynh_exec_warn_less yunohost service status $app-exporter >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app-exporter service integration..."
|
||||
yunohost service remove $app-exporter
|
||||
ynh_remove_systemd_config --service="$app-exporter"
|
||||
fi
|
||||
|
||||
ynh_remove_nginx_config
|
||||
|
||||
|
@ -32,6 +38,8 @@ ynh_remove_logrotate
|
|||
|
||||
ynh_secure_remove --file="/var/log/$app"
|
||||
|
||||
ynh_redis_remove_db "$redis_db"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue