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-08-31 21:26:01 +02:00
parent 58dbb3edfe
commit d36de2367b
No known key found for this signature in database
GPG key ID: 574F281483054D44
11 changed files with 71 additions and 10 deletions

View file

@ -8,7 +8,7 @@
password="password"
; Checks
pkg_linter=1
setup_sub_dir=0
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=1
@ -16,7 +16,7 @@
upgrade=1
#upgrade=1 from_commit=CommitHash
backup_restore=1
multi_instance=0
multi_instance=1
change_url=1
;;; Options
Email=

View file

@ -1,12 +1,21 @@
{
"url": "http://127.0.0.1:__PORT__",
"url": "https://__DOMAIN____PATH__",
"secret": "__SECRET__",
"database": "postgres",
"port": "__PORT__",
"database": "redis",
"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__"
}
}

View file

@ -1,4 +1,5 @@
location / {
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
# Force usage of https
if ($scheme = http) {

View file

@ -24,7 +24,7 @@
"requirements": {
"yunohost": ">> 4.2.4"
},
"multi_instance": false,
"multi_instance": true,
"services": [
"nginx"
],
@ -35,6 +35,12 @@
"type": "domain",
"example": "example.com"
},
{
"name": "path",
"type": "path",
"example": "/forum",
"default": "/forum"
},
{
"name": "admin",
"type": "user",

View file

@ -5,7 +5,7 @@
#=================================================
# dependencies used by the app
pkg_dependencies="redis-server"
pkg_dependencies="postgresql redis-server"
nodejs_version=14

View file

@ -30,6 +30,10 @@ app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
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)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
@ -62,6 +66,13 @@ ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# BACKUP THE POSTGRESQL DATABASE
#=================================================
ynh_print_info --message="Backing up the PostgreSQL database..."
ynh_psql_dump_db --database="$db_name" > db.sql
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -107,7 +107,7 @@ fi
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
#=================================================
# RELOAD NGINX

View file

@ -22,7 +22,7 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN
is_public=$YNH_APP_ARG_IS_PUBLIC
path_url="/"
path_url=$YNH_APP_ARG_PATH
secret=$(ynh_string_random)
password=$YNH_APP_ARG_PASSWORD
admin=$YNH_APP_ARG_ADMIN
@ -88,6 +88,16 @@ ynh_script_progression --message="Configuring system user..." --weight=3
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE A POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2
db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_name --db_name=$db_name
#=================================================
# SPECIFIC SETUP
#=================================================

View file

@ -19,6 +19,8 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
#=================================================
# STANDARD REMOVE
@ -41,6 +43,14 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=2
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE DEPENDENCIES
#=================================================

View file

@ -31,6 +31,9 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
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)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
@ -76,6 +79,15 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
# Install Nodejs
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
#=================================================
# RESTORE SYSTEMD
#=================================================

View file

@ -21,7 +21,9 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
language=$(ynh_app_setting_get --app=$app --key=language)
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)
#=================================================
# CHECK VERSION