From 4bc706f8d0a063e79a98e400a72b7994b438d8d1 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 5 Apr 2021 23:05:06 +0200 Subject: [PATCH] Fix --- conf/config.json | 2 +- conf/nginx.conf | 4 ++++ scripts/install | 19 +++++++++++++++---- scripts/restore | 6 ++++-- scripts/upgrade | 11 +++++++---- 5 files changed, 31 insertions(+), 11 deletions(-) diff --git a/conf/config.json b/conf/config.json index 598421d..68b2272 100644 --- a/conf/config.json +++ b/conf/config.json @@ -5,7 +5,7 @@ "dbconfig": "postgres://__DB_NAME__:__DB_PWD__@localhost/__DB_NAME__?sslmode=disable&connect_timeout=10", "useSSL": false, "webpath": "./pack", - "filespath": "./files", + "filespath": "/home/yunohost.app/__APP__/files", "telemetry": false, "session_expire_time": 2592000, "session_refresh_time": 18000, diff --git a/conf/nginx.conf b/conf/nginx.conf index 67ac08b..7af9fdd 100755 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,3 +1,4 @@ +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { # Force usage of https @@ -47,3 +48,6 @@ location __PATH__/ws/ { proxy_read_timeout 1d; } +location __PATH__/uploads/ { + alias __FILES_PATH__/uploads/ ; +} diff --git a/scripts/install b/scripts/install index a64e968..38c71ea 100755 --- a/scripts/install +++ b/scripts/install @@ -73,7 +73,7 @@ ynh_install_app_dependencies $pkg_dependencies ynh_script_progression --message="Configuring system user..." --weight=11 # Create a system user -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # CREATE A POSTGRESQL DATABASE @@ -94,13 +94,22 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" +#================================================= +# CREATE DIRECTORIES +#================================================= + +files_path=/home/yunohost.app/$app +ynh_app_setting_set --app=$app --key=files_path --value=$files_path + +mkdir -p $files_path/files + #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Configuring NGINX web server..." --weight=2 # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_add_nginx_config "files_path" #================================================= # SETUP SYSTEMD @@ -124,7 +133,9 @@ ynh_add_config --template="../conf/config.json" --destination="$final_path/confi # Set permissions to app files chown -R $app:$app $final_path -chmod -R o-rwx "$final_path" +chown -R $app:$app $files_path +#chmod -R o-rwx $final_path +chmod -R 755 $files_path chmod 600 $final_path/config.json #================================================= @@ -140,7 +151,7 @@ yunohost service add $app --description="A short description of the app" --log=" ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -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="/var/log/$app/$app.log" #================================================= # SETUP SSOWAT diff --git a/scripts/restore b/scripts/restore index d01a311..a265fc6 100755 --- a/scripts/restore +++ b/scripts/restore @@ -66,7 +66,7 @@ ynh_restore_file --origin_path="$final_path" ynh_script_progression --message="Recreating the dedicated system user..." --weight=2 # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE USER RIGHTS @@ -74,7 +74,9 @@ ynh_system_user_create --username=$app # Restore permissions on app files chown -R $app:$app $final_path -chmod -R o-rwx "$final_path" +chown -R $app:$app $files_path +#chmod -R o-rwx $final_path +chmod -R 755 $files_path chmod 600 $final_path/config.json #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 7b2d89a..5fdf70e 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,6 +20,7 @@ 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) +files_path=$(ynh_app_setting_get --app=$app --key=files_path) #================================================= # CHECK VERSION @@ -60,7 +61,7 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -95,7 +96,7 @@ ynh_install_app_dependencies $pkg_dependencies ynh_script_progression --message="Making sure dedicated system user exists..." --weight=3 # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # SETUP SYSTEMD @@ -119,7 +120,9 @@ ynh_add_config --template="some_config_file" --destination="$final_path/some_con # Set permissions on app files chown -R $app:$app $final_path -chmod -R o-rwx "$final_path" +chown -R $app:$app $files_path +#chmod -R o-rwx "$final_path" +chmod -R 755 $files_path chmod 600 $final_path/config.json #================================================= @@ -142,7 +145,7 @@ yunohost service add $app --description="A short description of the app" --log=" #================================================= 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="/var/log/$app/$app.log" #================================================= # RELOAD NGINX