diff --git a/issue_template.md b/.github/ISSUE_TEMPLATE.md similarity index 91% rename from issue_template.md rename to .github/ISSUE_TEMPLATE.md index 3d8f0e6..2729a6b 100644 --- a/issue_template.md +++ b/.github/ISSUE_TEMPLATE.md @@ -6,11 +6,11 @@ about: When creating a bug report, please use the following template to provide **How to post a meaningful bug report** 1. *Read this whole template first.* -2. *Make sure you are on the right place:* +2. *Determine if you are on the right place:* - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.* - - *In doubt, ask here and we will figure it out together.* -3. *Delete these italic comments as you write over them below, and remove this guide.* + - *When in doubt, post here and we will figure it out together.* +3. *Delete the italic comments as you write over them below, and remove this guide.* --- ### Describe the bug @@ -31,7 +31,7 @@ about: When creating a bug report, please use the following template to provide - *If you performed a command from the CLI, the command itself is enough. For example:* ```sh - sudo yunohost app install mantis + sudo yunohost app install the_app ``` - *If you used the webadmin, please perform the equivalent command from the CLI first.* - *If the error occurs in your browser, explain what you did:* diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ef70e18 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,16 @@ +## Problem + +- *Description of why you made this PR* + +## Solution + +- *And how do you fix that problem* + +## PR Status + +- [ ] Code finished and ready to be reviewed/tested +- [ ] The fix/enhancement were manually tested (if applicable) + +## Automatic tests + +Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization) diff --git a/README.md b/README.md index 52a5e1c..9641203 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ + + # Mantis for YunoHost [![Integration level](https://dash.yunohost.org/integration/mantis.svg)](https://dash.yunohost.org/appci/app/mantis) ![](https://ci-apps.yunohost.org/ci/badges/mantis.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mantis.maintain.svg) @@ -5,56 +10,25 @@ *[Lire ce readme en français.](./README_fr.md)* -> *This package allows you to install Mantis quickly and simply on a YunoHost server. +> *This package allows you to install Mantis quickly and simply on a YunoHost server. If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview -Mantis Bug Tracker is a free and open source, web-based bug tracking system. The most common use of MantisBT is to track software defects. However, MantisBT is often configured by users to serve as a more generic issue tracking system and project management tool. +Bug tracking system. -**Shipped version:** 2.25.0 +**Shipped version:** 2.25.2~ynh1 -## Screenshots +**Demo:** https://mantisbt.org/bugs/my_view_page.php -![](https://github.com/mantisbt/mantisbt/blob/master/doc/modern_my_view.png) +## Documentation and resources -## Demo - -* [Official demo](https://mantisbt.org/bugs/my_view_page.php) - -## Documentation - - * Official documentation: https://mantisbt.org/documentation.php - * YunoHost documentation: https://yunohost.org/en/app_mantis - -## YunoHost specific features - -#### Multi-user support - -* Are LDAP and HTTP auth supported ? **Yes** -* Can the app be used by multiple users? **Yes** - -#### Supported architectures - -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mantis.svg)](https://ci-apps.yunohost.org/ci/apps/mantis/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mantis.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mantis/) - -## Limitations - -* Any known limitations. - -## Additional information - -* Other info you would like to add about this app. - -## Links - - * Report a bug: https://github.com/YunoHost-Apps/mantis_ynh/issues - * App website: https://mantisbt.org/ - * Upstream app repository: https://github.com/mantisbt/mantisbt/ - * YunoHost website: https://yunohost.org/ - ---- +* Official app website: https://mantisbt.org/ +* Official user documentation: https://yunohost.org/en/app_mantis +* Official admin documentation: https://mantisbt.org/documentation.php +* Upstream app code repository: https://github.com/mantisbt/mantisbt/ +* YunoHost documentation for this app: https://yunohost.org/app_mantis +* Report a bug: https://github.com/YunoHost-Apps/mantis_ynh/issues ## Developer info @@ -66,3 +40,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/mantis_ynh/tree/testi or sudo yunohost app upgrade mantis -u https://github.com/YunoHost-Apps/mantis_ynh/tree/testing --debug ``` + +**More info regarding app packaging:** https://yunohost.org/packaging_apps \ No newline at end of file diff --git a/README_fr.md b/README_fr.md index 08d2727..d094c98 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,60 +1,30 @@ # Mantis pour YunoHost -[![Integration level](https://dash.yunohost.org/integration/mantis.svg)](https://dash.yunohost.org/appci/app/mantis) ![](https://ci-apps.yunohost.org/ci/badges/mantis.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mantis.maintain.svg) -[![Installer Mantis pour YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mantis) +[![Niveau d'intégration](https://dash.yunohost.org/integration/mantis.svg)](https://dash.yunohost.org/appci/app/mantis) ![](https://ci-apps.yunohost.org/ci/badges/mantis.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mantis.maintain.svg) +[![Installer Mantis avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mantis) -*[Read this readme in english.](./README.md)* +*[Read this readme in english.](./README.md)* +*[Lire ce readme en français.](./README_fr.md)* -> *Ce package vous permet d'installer Mantis rapidement et simplement sur un serveur YunoHost. -Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.* +> *Ce package vous permet d'installer Mantis rapidement et simplement sur un serveur YunoHost. +Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* ## Vue d'ensemble -Mantis Bug Tracker est un système de suivi des bogues gratuit et open source. L'utilisation la plus courante de MantisBT est de suivre les bogues logiciels. Cependant, MantisBT est souvent configuré par les utilisateurs pour servir de système de suivi des problèmes plus générique et d'outil de gestion de projet. +Système de suivi des bugs. -**Version incluse :** 2.25.0 +**Version incluse :** 2.25.2~ynh1 -## Captures d'écran +**Démo :** https://mantisbt.org/bugs/my_view_page.php -![](https://github.com/mantisbt/mantisbt/blob/master/doc/modern_my_view.png) +## Documentations et ressources -## Démo - -* [Démo officielle](https://mantisbt.org/bugs/my_view_page.php) - -## Documentation - - * Documentation officielle : https://mantisbt.org/documentation.php - * Documentation YunoHost : https://yunohost.org/fr/app_mantis - -## Caractéristiques spécifiques YunoHost - -#### Support multi-utilisateur - -* L'authentification LDAP et HTTP est-elle prise en charge ? **Oui** -* L'application peut-elle être utilisée par plusieurs utilisateurs ? **Oui** - -#### Architectures supportées - -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mantis.svg)](https://ci-apps.yunohost.org/ci/apps/mantis/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mantis.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mantis/) - -## Limitations - -* Limitations connues. - -## Informations additionnelles - -* Autres informations que vous souhaitez ajouter sur cette application. - -## Liens - - * Signaler un bug : https://github.com/YunoHost-Apps/mantis_ynh/issues - * Site de l'application : https://mantisbt.org/ - * Dépôt de l'application principale : https://github.com/mantisbt/mantisbt/ - * Site web YunoHost : https://yunohost.org/ - ---- +* Site officiel de l'app : https://mantisbt.org/ +* Documentation officielle utilisateur : https://yunohost.org/en/app_mantis +* Documentation officielle de l'admin : https://mantisbt.org/documentation.php +* Dépôt de code officiel de l'app : https://github.com/mantisbt/mantisbt/ +* Documentation YunoHost pour cette app : https://yunohost.org/app_mantis +* Signaler un bug : https://github.com/YunoHost-Apps/mantis_ynh/issues ## Informations pour les développeurs @@ -63,6 +33,8 @@ Merci de faire vos pull request sur la [branche testing](https://github.com/Yuno Pour essayer la branche testing, procédez comme suit. ``` sudo yunohost app install https://github.com/YunoHost-Apps/mantis_ynh/tree/testing --debug -or +ou sudo yunohost app upgrade mantis -u https://github.com/YunoHost-Apps/mantis_ynh/tree/testing --debug ``` + +**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps \ No newline at end of file diff --git a/check_process b/check_process index 0b557c3..9d05038 100644 --- a/check_process +++ b/check_process @@ -1,14 +1,9 @@ -# See here for more information -# https://github.com/YunoHost/package_check#syntax-check_process-file - -# Move this file from check_process.default to check_process when you have filled it. - ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - path="/mantis" (PATH) - admin="john" (USER) - is_public=1 (PUBLIC|public=1|private=0) + domain="domain.tld" + path="/path" + admin="john" + is_public=1 default_access_level="REPORTER" ; Checks pkg_linter=1 @@ -29,4 +24,3 @@ Notification=none ; commit=888c0e02d4fa4afae4800d7599ee3e145c942548 name=Testing (#9) manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& - diff --git a/conf/app.src b/conf/app.src index 753f9cc..5451c92 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://sourceforge.net/projects/mantisbt/files/mantis-stable/2.25.0/mantisbt-2.25.0.tar.gz/download -SOURCE_SUM=d8973d3677ecb2ccbfee95e2267b3128049fbdcc59aa1f007686a342d93a4c0a +SOURCE_URL=https://sourceforge.net/projects/mantisbt/files/mantis-stable/2.25.2/mantisbt-2.25.2.tar.gz/download +SOURCE_SUM=8b087e71594fd70d2d2e39d2d2e1285b47a9919d8d8fd268df009df76ebc3671 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md new file mode 100644 index 0000000..e69de29 diff --git a/doc/screenshot/modern_my_view.png b/doc/screenshot/modern_my_view.png new file mode 100644 index 0000000..73fb933 Binary files /dev/null and b/doc/screenshot/modern_my_view.png differ diff --git a/manifest.json b/manifest.json index 5298108..f57b1ae 100644 --- a/manifest.json +++ b/manifest.json @@ -3,18 +3,26 @@ "id": "mantis", "packaging_format": 1, "description": { - "en": "Bug tracking system based on a web interface.", - "fr": "Système de suivi des bugs reposant sur une interface web." + "en": "Bug tracking system.", + "fr": "Système de suivi des bugs." }, - "version": "2.25.0~ynh2", + "version": "2.25.2~ynh1", "url": "https://www.mantisbt.org/", + "upstream": { + "license": "GPL-3.0-only", + "website": "https://mantisbt.org/", + "demo": "https://mantisbt.org/bugs/my_view_page.php", + "admindoc": "https://mantisbt.org/documentation.php", + "userdoc": "https://yunohost.org/en/app_mantis", + "code": "https://github.com/mantisbt/mantisbt/" + }, "license": "GPL-3.0-only", "maintainer": { "name": "liberodark", "email": "liberodark@gmail.com" }, "requirements": { - "yunohost": ">= 4.1.7" + "yunohost": ">= 4.2.4" }, "multi_instance": true, "services": [ @@ -23,7 +31,8 @@ "mysql" ], "arguments": { - "install": [{ + "install" : [ + { "name": "domain", "type": "domain", "example": "example.com" @@ -33,17 +42,17 @@ "type": "path", "example": "/mantis", "default": "/mantis" - }, - { - "name": "is_public", - "type": "boolean", - "default": true }, { "name": "admin", "type": "user", "example": "johndoe" }, + { + "name": "is_public", + "type": "boolean", + "default": true + }, { "name": "default_access_level", "type": "string", diff --git a/pull_request_template.md b/pull_request_template.md deleted file mode 100644 index 6c28fc5..0000000 --- a/pull_request_template.md +++ /dev/null @@ -1,16 +0,0 @@ -## Problem -- *Description of why you made this PR* - -## Solution -- *And how do you fix that problem* - -## PR Status -- [ ] Code finished. -- [ ] Tested with Package_check. -- [ ] Fix or enhancement tested. -- [ ] Upgrade from last version tested. -- [ ] Can be reviewed and tested. - -## Package_check results ---- -* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"* diff --git a/scripts/backup b/scripts/backup index a1bf498..50516c7 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -61,4 +62,4 @@ ynh_mysql_dump_db --database="$db_name" > db.sql # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for Mantis. (YunoHost will then actually copy those files to the archive)." +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index 60b37a7..905d02d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -33,11 +33,12 @@ 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=db_pwd) +default_access_level=$(ynh_app_setting_get --app=$app --key=default_access_level) #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up Mantis before changing its URL (may take a while)..." --weight=7 +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=7 # Backup the current version of the app ynh_backup_before_upgrade @@ -45,7 +46,7 @@ ynh_clean_setup () { # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script @@ -98,6 +99,14 @@ then ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi +#================================================= +# MODIFY A CONFIG FILE +#================================================= + +random=$(ynh_string_random --length=20) +domain="$new_domain" +ynh_add_config --template="../conf/config_inc.php" --destination="$final_path/config/config_inc.php" + #================================================= # GENERIC FINALISATION #================================================= @@ -111,4 +120,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for Mantis" --last +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index 3f13534..a6cd744 100644 --- a/scripts/install +++ b/scripts/install @@ -19,11 +19,10 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -# Retrieve arguments domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC admin=$YNH_APP_ARG_ADMIN +is_public=$YNH_APP_ARG_IS_PUBLIC default_access_level=$YNH_APP_ARG_DEFAULT_ACCESS_LEVEL app=$YNH_APP_INSTANCE_NAME @@ -34,7 +33,7 @@ app=$YNH_APP_INSTANCE_NAME ynh_script_progression --message="Validating installation parameters..." --weight=1 final_path=/var/www/$app -test ! -e "$final_path" || ynh_die "This path already contains a folder" +test ! -e "$final_path" || ynh_die --message="This path already contains a folder" # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url @@ -47,8 +46,19 @@ ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=admin --value=$admin +ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_app_setting_set --app=$app --key=default_access_level --value=$default_access_level +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=1 + +# Create a system user +ynh_system_user_create --username=$app --home_dir=$final_path + #================================================= # CREATE A MYSQL DATABASE #================================================= @@ -59,6 +69,14 @@ db_user=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=1 + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -68,6 +86,11 @@ 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" +# Set permissions to app files +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -76,51 +99,44 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=10 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -ynh_system_user_create --username=$app - #================================================= # PHP-FPM CONFIGURATION #================================================= ynh_script_progression --message="Configuring PHP-FPM..." --weight=3 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --package="$extra_php_dependencies" +ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies" phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= -# MODIFY A CONFIG FILE +# SPECIFIC SETUP #================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." random=$(ynh_string_random --length=20) ynh_add_config --template="../conf/config_inc.php" --destination="$final_path/config/config_inc.php" -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions to app files -chown -R $app: $final_path -chmod -R 755 $final_path +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # SETUP APPLICATION WITH CURL #================================================= +ynh_script_progression --message="Setuping application with CURL..." -# Set the app as temporarily public for cURL call +# Set the app as temporarily public for curl call +ynh_script_progression --message="Configuring SSOwat..." +# Making the app public for curl ynh_permission_update --permission="main" --add="visitors" # Reload NGINX ynh_systemd_action --service_name=nginx --action=reload +# Installation with curl ynh_script_progression --message="Finalizing installation..." --weight=10 # Installation with cURL @@ -131,20 +147,27 @@ ynh_local_curl $installUrl "install=2" "db_type=mysqli" "hostname=localhost" "db # Remove the `admin/` directory from within the MantisBT installation path. # The scripts within this directory should not be accessible on a live MantisBT site # or on any installation that is accessible via the Internet. -ynh_secure_remove "$final_path/admin" +ynh_secure_remove --file="$final_path/admin" # Set the user chosen at installation as administrator ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" <<< "UPDATE ${db_name}_user_table SET username = '$admin' WHERE id = 1;" +# Remove the public access +ynh_permission_update --permission="main" --remove="visitors" + +#================================================= +# GENERIC FINALIZATION #================================================= # SETUP SSOWAT #================================================= ynh_script_progression --message="Configuring permissions..." --weight=1 -# Make app public if necessary or protect it -if [ $is_public -eq 0 ] +# Make app public if necessary +if [ $is_public -eq 1 ] then - ynh_permission_update --permission="main" --remove="visitors" + # Everyone can access the app. + # The "main" permission is automatically created before the install script. + ynh_permission_update --permission="main" --add="visitors" fi #================================================= @@ -158,4 +181,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of Mantis completed" --last +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index aa0bf3e..ddf745f 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -23,18 +23,10 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service" --weight=1 - -# Remove the dedicated systemd config -ynh_remove_systemd_config - #================================================= # REMOVE THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Removing the MySQL database" --weight=1 +ynh_script_progression --message="Removing the MySQL database..." --weight=1 # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name @@ -50,10 +42,10 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing Mantis main directory..." --weight=4 +ynh_script_progression --message="Removing app main directory..." --weight=4 # Remove the app directory securely -ynh_secure_remove "$final_path" +ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index c1d845a..50cff37 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -44,31 +45,28 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the 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 Mantis main directory..." --weight=5 - -ynh_restore_file --origin_path="$final_path" - #================================================= # RECREATE THE DEDICATED USER #================================================= ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # 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 +# RESTORE THE APP MAIN DIR #================================================= +ynh_script_progression --message="Restoring app main directory..." --weight=5 -# Restore permissions on app files -chown -R $app: $final_path -chmod -R 755 $final_path +ynh_restore_file --origin_path="$final_path" + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # RESTORE THE PHP-FPM CONFIGURATION @@ -103,4 +101,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for Mantis" --last +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index fe20fea..9a1d911 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,18 +19,36 @@ 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) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) db_user=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) default_access_level=$(ynh_app_setting_get --app=$app --key=default_access_level) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up app before upgrading (may take a while)..." --weight=5 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -62,18 +80,20 @@ if ynh_legacy_permissions_exists; then fi #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Backing up Mantis before upgrading (may take a while)..." --weight=5 +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir=$final_path + +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -100,6 +120,11 @@ then ynh_secure_remove --file="$tmpdir" fi +# Set permissions to app files +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -108,14 +133,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -125,29 +142,18 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 ynh_add_fpm_config --package="$extra_php_dependencies" #================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions to app files -chown -R $app: $final_path -chmod -R 755 $final_path - +# SPECIFIC UPGRADE #================================================= # SETUP APPLICATION WITH CURL #================================================= # Set the app as temporarily public for cURL call -ynh_permission_has_user --permission="main" --user="visitors" -contains_visitors=$? - -if [ $contains_visitors -eq 1 ] -then - ynh_permission_update --permission="main" --add="visitors" -fi +ynh_permission_update --permission="main" --add="visitors" # Reload NGINX ynh_systemd_action --service_name=nginx --action=reload +# Installation with curl ynh_script_progression --message="Finalizing installation..." --weight=10 # Installation with cURL @@ -158,15 +164,10 @@ ynh_local_curl $installUrl "install=2" "db_type=mysqli" "hostname=localhost" "db # Remove the `admin/` directory from within the MantisBT installation path. # The scripts within this directory should not be accessible on a live MantisBT site # or on any installation that is accessible via the Internet. -ynh_secure_remove "$final_path/admin" +ynh_secure_remove --file="$final_path/admin" -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 - -# Make app public if necessary or protect it -if [ $contains_visitors -eq 1 ] +# Make app public if necessary +if [ $is_public -eq 0 ] then ynh_permission_update --permission="main" --remove="visitors" fi @@ -181,4 +182,5 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of Mantis completed" --last + +ynh_script_progression --message="Upgrade of $app completed" --last