mirror of
https://github.com/YunoHost-Apps/calckey_ynh.git
synced 2024-09-03 18:16:18 +02:00
Update _common.sh
This commit is contained in:
parent
e0e26177d1
commit
0ff3dbe2e2
1 changed files with 43 additions and 17 deletions
|
@ -5,23 +5,11 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
# PHP APP SPECIFIC
|
# PHP APP SPECIFIC
|
||||||
#=================================================
|
#=================================================
|
||||||
# Depending on its version, YunoHost uses different default PHP version:
|
|
||||||
## YunoHost version "11.X" => PHP 7.4
|
|
||||||
## YunoHost version "4.X" => PHP 7.3
|
|
||||||
#
|
|
||||||
# This behaviour can be overridden by setting the YNH_PHP_VERSION variable
|
|
||||||
#YNH_PHP_VERSION=7.3
|
|
||||||
#YNH_PHP_VERSION=7.4
|
|
||||||
#YNH_PHP_VERSION=8.0
|
|
||||||
# For more information, see the PHP application helper: https://github.com/YunoHost/yunohost/blob/dev/helpers/php#L3-L6
|
|
||||||
# Or this app package depending on PHP: https://github.com/YunoHost-Apps/grav_ynh/blob/master/scripts/_common.sh
|
|
||||||
# PHP dependencies used by the app (must be on a single line)
|
|
||||||
#php_dependencies="php$YNH_PHP_VERSION-deb1 php$YNH_PHP_VERSION-deb2"
|
|
||||||
# or, if you do not need a custom YNH_PHP_VERSION:
|
|
||||||
php_dependencies="php$YNH_DEFAULT_PHP_VERSION-deb1 php$YNH_DEFAULT_PHP_VERSION-deb2"
|
|
||||||
|
|
||||||
# dependencies used by the app (must be on a single line)
|
NODEJS_VERSION="16.15.0"
|
||||||
pkg_dependencies="deb1 deb2 $php_dependencies"
|
|
||||||
|
# dependencies used by the app
|
||||||
|
pkg_dependencies="ffmpeg postgresql"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
|
@ -32,5 +20,43 @@ pkg_dependencies="deb1 deb2 $php_dependencies"
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# FUTURE OFFICIAL HELPERS
|
# REDIS 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
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue