1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/nodebb_ynh.git synced 2024-09-03 19:46:29 +02:00
This commit is contained in:
ericgaspar 2021-09-01 15:32:18 +02:00
parent 2c9aa9b766
commit f11ba8bc80
No known key found for this signature in database
GPG key ID: 574F281483054D44
6 changed files with 2 additions and 69 deletions

View file

@ -1,3 +0,0 @@
export admin__username="__ADMIN__"
export admin__password="__PASSWORD__"
export admin__password__confirm="__PASSWORD__"

View file

@ -8,20 +8,11 @@
"admin__password__confirm":"__PASSWORD__",
"trust_proxy": true,
"isCluster": false,
"redis": {
"host": "127.0.0.1",
"port": "6379",
"password": "",
"database": "__REDIS_DB__"
},
"postgres": {
"host": "localhost",
"port": "5432",
"username": "__DB_NAME__",
"password": "__DB_PWD__",
"database": "__DB_NAME__"
},
"socket.io": {
"transports": ["websocket"]
}
}

View file

@ -5,7 +5,7 @@
#=================================================
# dependencies used by the app
pkg_dependencies="postgresql redis-server"
pkg_dependencies="postgresql"
nodejs_version=14
@ -22,41 +22,3 @@ nodebb_version=v1.18.x
#=================================================
# FUTURE OFFICIAL 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

@ -34,7 +34,6 @@ admin=$(ynh_app_setting_get --app=$app --key=admin)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================

View file

@ -72,15 +72,6 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
# Install Nodejs
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# CREATE A REDIS DATABASE
#=================================================
ynh_script_progression --message="Creating a Redis database..." --weight=5
# Configure redis
redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
#=================================================
# CREATE DEDICATED USER
#=================================================
@ -143,7 +134,7 @@ chown $app "$final_path/config.json"
#=================================================
pushd $final_path
ynh_exec_as $app env $ynh_node_load_PATH $final_path/nodebb setup #-l > $install_log
ynh_exec_as $app env $ynh_node_load_PATH $final_path/nodebb setup
popd
#=================================================

View file

@ -60,13 +60,6 @@ ynh_script_progression --message="Removing dependencies..." --weight=1
ynh_remove_app_dependencies
ynh_remove_nodejs
#=================================================
# REMOVE THE REDIS DATABASE
#=================================================
ynh_script_progression --message="Removing the Redis database..."
ynh_redis_remove_db "$redis_db"
#=================================================
# REMOVE APP MAIN DIR
#=================================================