1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/bookstack_ynh.git synced 2024-09-03 18:16:02 +02:00
This commit is contained in:
ericgaspar 2021-10-27 22:37:10 +02:00
parent d94f2b6816
commit c08320d284
No known key found for this signature in database
GPG key ID: 574F281483054D44
4 changed files with 63 additions and 2 deletions

View file

@ -52,11 +52,18 @@ LDAP_SERVER=ldap://127.0.0.1:389
LDAP_BASE_DN=ou=users,dc=yunohost,dc=org LDAP_BASE_DN=ou=users,dc=yunohost,dc=org
LDAP_DN=false LDAP_DN=false
LDAP_PASS=false LDAP_PASS=false
LDAP_USER_FILTER="(&(|(objectclass=posixAccount))(uid={{username}})(permission=cn=__APP__.main,ou=permission,dc=yunohost,dc=org))" LDAP_USER_FILTER=(&(|(objectclass=posixAccount))(uid={{username}})(permission=cn=__APP__.main,ou=permission,dc=yunohost,dc=org))
LDAP_VERSION=false LDAP_VERSION=3
LDAP_TLS_INSECURE=false LDAP_TLS_INSECURE=false
LDAP_ID_ATTRIBUTE=uid LDAP_ID_ATTRIBUTE=uid
LDAP_EMAIL_ATTRIBUTE=mail LDAP_EMAIL_ATTRIBUTE=mail
LDAP_DISPLAY_NAME_ATTRIBUTE=cn LDAP_DISPLAY_NAME_ATTRIBUTE=cn
LDAP_FOLLOW_REFERRALS=true LDAP_FOLLOW_REFERRALS=true
LDAP_DUMP_USER_DETAILS=false LDAP_DUMP_USER_DETAILS=false
# Set both the cache and session to use Redis
CACHE_DRIVER=redis
SESSION_DRIVER=redis
# Example of using a single local Redis server
REDIS_SERVERS=127.0.0.1:6379:__REDIS_DB__

View file

@ -21,3 +21,45 @@ YNH_COMPOSER_VERSION=2.1.1
#================================================= #=================================================
# FUTURE OFFICIAL HELPERS # 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
}

View file

@ -108,6 +108,10 @@ ynh_install_composer --phpversion=$phpversion --workdir=$final_path --install_ar
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
# Configure redis
redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
mail_pwd=$(ynh_string_random --length=12) mail_pwd=$(ynh_string_random --length=12)
ynh_add_config --template=../conf/.env.example --destination=$final_path/.env ynh_add_config --template=../conf/.env.example --destination=$final_path/.env
chmod 600 $final_path/.env chmod 600 $final_path/.env

View file

@ -20,6 +20,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
#================================================= #=================================================
# REMOVE THE MYSQL DATABASE # REMOVE THE MYSQL DATABASE
@ -29,6 +30,13 @@ ynh_script_progression --message="Removing the MySQL database..." --weight=1
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE THE REDIS DATABASE
#=================================================
ynh_script_progression --message="Removing the redis database..."
ynh_redis_remove_db "$redis_db"
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================