diff --git a/README.md b/README.md index 908b417..16157ee 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,8 @@ Can the app be used by multiple users? **Yes** #### Supported architectures -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/lufi%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/lufi/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/lufi%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lufi/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/lufi.svg)](https://ci-apps.yunohost.org/ci/apps/lufi/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/lufi.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lufi/) ## Links diff --git a/README_fr.md b/README_fr.md index eea48f0..d1ede40 100644 --- a/README_fr.md +++ b/README_fr.md @@ -43,8 +43,8 @@ La clé de déchiffrement est une ancre (voir [Fragment Identifier](https://en.w #### Architectures supportées -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/lufi%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/lufi/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/lufi%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lufi/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/lufi.svg)](https://ci-apps.yunohost.org/ci/apps/lufi/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/lufi.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lufi/) ## Liens diff --git a/scripts/change_url b/scripts/change_url index a98a4f3..17b4b74 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -141,10 +141,13 @@ else fi ynh_store_file_checksum --file="$config" +chmod 600 $final_path/lufi.conf +chown $app:$app $final_path/lufi.conf + #================================================= # UPDATE SSOWAT #================================================= -ynh_script_progression --message="Reconfigure SSOwat" +ynh_script_progression --message="Reconfiguring permissions..." ynh_permission_update --permission="main" --add="visitors" diff --git a/scripts/install b/scripts/install index b3ae194..918714e 100644 --- a/scripts/install +++ b/scripts/install @@ -76,6 +76,14 @@ ynh_script_progression --message="Installing dependencies..." ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app + #================================================= # CREATE A POSTGRESQL DATABASE #================================================= @@ -106,14 +114,6 @@ ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config ynh_add_nginx_config max_file_size -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -# Create a system user -ynh_system_user_create --username=$app - #================================================= # SPECIFIC SETUP #================================================= @@ -144,6 +144,9 @@ fi ynh_store_file_checksum --file="$config" +chmod 600 $final_path/lufi.conf +chown $app:$app $final_path/lufi.conf + #================================================= # INSTALL LUFI #================================================= @@ -158,9 +161,6 @@ popd #================================================= ynh_script_progression --message="Setuping a cron..." -# cp ../conf/cron_lufi /etc/cron.d/$app -# ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path/" --target_file="/etc/cron.d/$app" -# ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="/etc/cron.d/$app" ynh_add_config --template="../conf/cron_lufi" --destination="/etc/cron.d/$app" chmod +x $final_path/script/lufi diff --git a/scripts/remove b/scripts/remove index 7640fa9..0cca7d3 100644 --- a/scripts/remove +++ b/scripts/remove @@ -83,16 +83,6 @@ ynh_script_progression --message="Removing logrotate configuration..." # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_script_progression --message="Closing port $port..." - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi - #================================================= # SPECIFIC REMOVE #================================================= diff --git a/scripts/restore b/scripts/restore index 8790bf1..a6153c4 100644 --- a/scripts/restore +++ b/scripts/restore @@ -53,13 +53,6 @@ ynh_script_progression --message="Restoring NGINX configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= -ynh_script_progression --message="Restoring the app main directory..." - -ynh_restore_file --origin_path="$final_path" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -68,6 +61,13 @@ ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create --username=$app +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring the app main directory..." + +ynh_restore_file --origin_path="$final_path" + #================================================= # RESTORE USER RIGHTS #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index a47faf4..bea6a94 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -39,19 +39,18 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." +# If db_name doesn't exist, create it +if [ -z "$db_name" ]; then + db_name=$(ynh_sanitize_dbid --db_name=$app) + ynh_app_setting_set --app=$app --key=db_name --value=$db_name +fi + # If final_path doesn't exist, create it if [ -z "$final_path" ]; then final_path=/var/www/$app ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi -if [ -z "$db_pwd" ]; then - # Need to install new dependencies before creating the new database - need_migration_from_sqlite_to_psql=1 -else - need_migration_from_sqlite_to_psql=0 -fi - if [ -z "$max_file_size" ]; then max_file_size=100 # 100 Mo ynh_app_setting_set --app=$app --key=max_file_size --value=$max_file_size @@ -86,7 +85,15 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="$final_path/log/production.log" +ynh_systemd_action --service_name=$app --action=stop --log_path="$final_path/log/production.log" + +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -115,36 +122,10 @@ ynh_script_progression --message="Upgrading dependencies..." ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - -#================================================= -# SPECIFIC UPGRADE -#================================================= -# CREATE A POSTGRESQL DATABASE IF NEEDED -#================================================= - -if [ $need_migration_from_sqlite_to_psql -eq 1 ]; then - ynh_print_info --message="Creating a PostgreSQL database..." - # Create postgresql database - ynh_psql_test_if_first_run - db_name=$(ynh_sanitize_dbid --db_name=$app) - db_user=$db_name - ynh_app_setting_set --app=$app --key=db_name --value=$db_name - # Initialize database and store postgres password for upgrade - ynh_psql_setup_db --db_user=$db_user --db_name=$db_name - db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) # Password created in ynh_psql_setup_db function -fi - #================================================= # SETUP LUFI #================================================= -ynh_script_progression --message="Configuring lufi..." +ynh_script_progression --message="Configuring Lufi..." config=${final_path}/lufi.conf ynh_backup_if_checksum_is_different --file="$config" @@ -170,28 +151,16 @@ fi ynh_store_file_checksum --file="$config" +chmod 600 $final_path/lufi.conf +chown $app:$app $final_path/lufi.conf + #================================================= # BUILD LUFI #================================================= ynh_script_progression --message="Building Lufi..." pushd $final_path -# Migrate from SQLite to PostgreSQL -if [ $need_migration_from_sqlite_to_psql -eq 1 ]; then - # Preinstall with sqlite - carton install --deployment --without=mysql --without=htpasswd --without=test - - # if /var/log/$app/production.log is a symbolic link, then move it to $final_path/log/production.log - if [ ! -L "/var/log/$app/production.log" ] - then - mv "/var/log/$app/production.log" "$final_path/log/production.log" - chown -R $app: "$final_path/log/production.log" - fi - - carton exec script/lufi sqliteToOtherDB -fi - -carton install --deployment --without=sqlite --without=mysql --without=htpasswd --without=test + carton install --deployment --without=sqlite --without=mysql --without=htpasswd --without=test popd #================================================= @@ -233,12 +202,12 @@ ynh_add_systemd_config ynh_script_progression --message="Securing files and directories..." # Set permissions on app files -chown -R $app: $final_path +chown -R $app:$app $final_path #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." +ynh_script_progression --message="Upgrading permissions..." ynh_permission_update --permission="main" --add="visitors"