diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..2729a6b --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,55 @@ +--- +name: Bug report +about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently. + +--- + +**How to post a meaningful bug report** +1. *Read this whole template first.* +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.* + - *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 + +*A clear and concise description of what the bug is.* + +### Context + +- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* +- YunoHost version: x.x.x +- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* +- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes* + - If yes, please explain: +- Using, or trying to install package version/branch: +- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* + +### Steps to reproduce + +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + 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:* + 1. *Go to '...'* + 2. *Click on '...'* + 3. *Scroll down to '...'* + 4. *See error* + +### Expected behavior + +*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* + +### Logs + +*When an operation fails, YunoHost provides a simple way to share the logs.* +- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.* +- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.* + +*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)* + +*If applicable and useful, add screenshots to help explain your problem.* 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 4ace15c..79f86b1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ + + # phpMyAdmin for YunoHost [![Integration level](https://dash.yunohost.org/integration/phpmyadmin.svg)](https://dash.yunohost.org/appci/app/phpmyadmin) ![](https://ci-apps.yunohost.org/ci/badges/phpmyadmin.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/phpmyadmin.maintain.svg) @@ -5,56 +10,38 @@ *[Lire ce readme en français.](./README_fr.md)* -> *This package allow you to install phpMyAdmin quickly and simply on a YunoHost server. -If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* +> *This package allows you to install phpMyAdmin 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 + +Manage MySQL databases over the web + +**Shipped version:** 5.1.1~ynh1 + +**Demo:** https://demo.phpmyadmin.net/master-config + +## Screenshots + +![](./doc/screenshots/68747470733a2f2f7777772e7068706d7961646d696e2e6e65742f7374617469632f696d616765732f73637265656e73686f74732f7374727563747572652e706e67.png) + +## Disclaimers / important information ## Overview phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web. phpMyAdmin supports a wide range of operations on MySQL and MariaDB. Frequently used operations (managing databases, tables, columns, relations, indexes, users, permissions, etc) can be performed via the user interface, while you still have the ability to directly execute any SQL statement. +## Documentation and resources -**Shipped version:** 5.0.4 +* Official app website: http://www.phpmyadmin.net +* Official user documentation: https://yunohost.org/en/app_phpmyadmin +* Official admin documentation: https://www.phpmyadmin.net/docs/ +* Upstream app code repository: https://github.com/phpmyadmin/phpmyadmin +* YunoHost documentation for this app: https://yunohost.org/app_phpmyadmin +* Report a bug: https://github.com/YunoHost-Apps/phpmyadmin_ynh/issues -## Screenshots +## Developer info -![](https://www.phpmyadmin.net/static/images/screenshots/structure.png) - -## Demo - -* [YunoHost demo](https://demo.yunohost.org/phpmyadmin/) -* [Official demo](https://demo.phpmyadmin.net/master-config/) - -## Configuration - -## Documentation - - * Official documentation: https://www.phpmyadmin.net/docs/ - * YunoHost documentation: https://yunohost.org/#/app_phpmyadmin - -## YunoHost specific features - -#### Multi-users support - -#### Supported architectures - -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/phpmyadmin%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/phpmyadmin/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/phpmyadmin%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/phpmyadmin/) - -## Limitations - -## Additionnal informations - -## Links - - * Report a bug: https://github.com/YunoHost-Apps/phpmyadmin_ynh/issues - * phpMyAdmin website: https://www.phpmyadmin.net/ - * phpMyAdmin repository: https://github.com/phpmyadmin/phpmyadmin - * YunoHost website: https://yunohost.org/ - ---- - -## Developers infos - -Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/phpmyadmin_ynh/tree/testing). +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/phpmyadmin_ynh/tree/testing). To try the testing branch, please proceed like that. ``` @@ -62,3 +49,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/phpmyadmin_ynh/tree/t or sudo yunohost app upgrade phpmyadmin -u https://github.com/YunoHost-Apps/phpmyadmin_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 d65d55a..56e9cda 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,64 +1,49 @@ -# phpMyAdmin avec YunoHost +# phpMyAdmin pour YunoHost [![Niveau d'intégration](https://dash.yunohost.org/integration/phpmyadmin.svg)](https://dash.yunohost.org/appci/app/phpmyadmin) ![](https://ci-apps.yunohost.org/ci/badges/phpmyadmin.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/phpmyadmin.maintain.svg) -[![Installer phpMyAdmin avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=phpmyadmin) +[![Installer phpMyAdmin avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=phpmyadmin) -*[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 phpMyAdmin 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 phpMyAdmin 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 + +Application web de gestion des bases de données MySQL + +**Version incluse :** 5.1.1~ynh1 + +**Démo :** https://demo.phpmyadmin.net/master-config + +## Captures d'écran + +![](./doc/screenshots/68747470733a2f2f7777772e7068706d7961646d696e2e6e65742f7374617469632f696d616765732f73637265656e73686f74732f7374727563747572652e706e67.png) + +## Avertissements / informations importantes ## Vue d'ensemble phpMyAdmin est un outil logiciel libre écrit en PHP, destiné à gérer l'administration de MySQL sur le Web. phpMyAdmin prend en charge un large éventail d'opérations sur MySQL et MariaDB. Les opérations fréquemment utilisées (gestion des bases de données, des tables, des colonnes, des relations, des index, des utilisateurs, des autorisations, etc.) peuvent être effectuées via l'interface utilisateur, tandis que vous avez toujours la possibilité d'exécuter directement les instructions SQL. +## Documentations et ressources -**Version incluse :** 5.0.4 +* Site officiel de l'app : http://www.phpmyadmin.net +* Documentation officielle utilisateur : https://yunohost.org/en/app_phpmyadmin +* Documentation officielle de l'admin : https://www.phpmyadmin.net/docs/ +* Dépôt de code officiel de l'app : https://github.com/phpmyadmin/phpmyadmin +* Documentation YunoHost pour cette app : https://yunohost.org/app_phpmyadmin +* Signaler un bug : https://github.com/YunoHost-Apps/phpmyadmin_ynh/issues -## Captures d'écran +## Informations pour les développeurs -![](https://www.phpmyadmin.net/static/images/screenshots/structure.png) +Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/phpmyadmin_ynh/tree/testing). -## Démo - -* [Démo YunoHost](https://demo.yunohost.org/phpmyadmin/) -* [Démo officielle](https://demo.phpmyadmin.net/master-config/) - -## Configuration - -## Documentation - - * Documentation officielle : https://www.phpmyadmin.net/docs/ - * Documentation YunoHost : https://yunohost.org/#/app_phpmyadmin_fr - -## Caractéristiques spécifiques YunoHost - -#### Support multi-utilisateur - -#### Architectures supportées - -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/phpmyadmin%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/phpmyadmin/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/phpmyadmin%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/phpmyadmin/) - -## Limitations - -## Informations additionnelles - -## Liens - - * Signaler un bug : https://github.com/YunoHost-Apps/phpmyadmin_ynh/issues - * Site de l'application : https://www.phpmyadmin.net/ - * Dépôt de l'application principale : https://github.com/phpmyadmin/phpmyadmin - * Site web YunoHost : https://yunohost.org/ - ---- - -## Developers infos - -Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/phpmyadmin_ynh/tree/testing). - -To try the testing branch, please proceed like that. +Pour essayer la branche testing, procédez comme suit. ``` sudo yunohost app install https://github.com/YunoHost-Apps/phpmyadmin_ynh/tree/testing --debug -or +ou sudo yunohost app upgrade phpmyadmin -u https://github.com/YunoHost-Apps/phpmyadmin_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 201bb2d..35e66e0 100644 --- a/check_process +++ b/check_process @@ -1,8 +1,8 @@ ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) - admin="john" (USER) + domain="domain.tld" + path="/path" + admin="john" ; Checks pkg_linter=1 setup_sub_dir=1 @@ -11,15 +11,14 @@ setup_private=0 setup_public=0 upgrade=1 - upgrade=1 from_commit=09ad01673cdfb9f893c138d92fce3bc965f5f8ed + upgrade=1 from_commit=e8bcf5f9e61621256fa62f8813ba161443dd488b backup_restore=1 multi_instance=0 - port_already_use=0 change_url=1 ;;; Options Email= Notification=none ;;; Upgrade options - ; commit=09ad01673cdfb9f893c138d92fce3bc965f5f8ed - name=Force php5 for composer + ; commit=e8bcf5f9e61621256fa62f8813ba161443dd488b + name=Testing (#106) manifest_arg=domain=DOMAIN&path=PATH&admin=USER& diff --git a/conf/app.src b/conf/app.src index 7b7f8ad..c80e538 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://files.phpmyadmin.net/phpMyAdmin/5.0.4/phpMyAdmin-5.0.4-all-languages.tar.gz -SOURCE_SUM=fbb993b74a7c29ce2fcdb6b6be22b0b6c58bff8df3292ab42f6280871450c316 +SOURCE_URL=https://files.phpmyadmin.net/phpMyAdmin/5.1.1/phpMyAdmin-5.1.1-all-languages.tar.gz +SOURCE_SUM=8264b57aeaa1f91c6d859331777c71e80d26088bef7cdcd5f9431119747ed1c1 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/config.inc.php b/conf/config.inc.php index b42cffd..647750e 100644 --- a/conf/config.inc.php +++ b/conf/config.inc.php @@ -28,8 +28,8 @@ $i = 0; $i++; /* Authentication type */ $cfg['Servers'][$i]['auth_type'] = 'config'; -$cfg['Servers'][$i]['user'] = '__YNH_PMA_ADMIN_USER__'; -$cfg['Servers'][$i]['password'] = '__YNH_PMA_ADMIN_PASSWORD__'; +$cfg['Servers'][$i]['user'] = '__DB_ADMIN_USER__'; +$cfg['Servers'][$i]['password'] = '__DB_ADMIN_PWD__'; /* Server parameters */ /* $cfg['Servers'][$i]['host'] = 'localhost'; @@ -49,11 +49,11 @@ $cfg['Servers'][$i]['AllowNoPassword'] = false; /* User used to manipulate with storage */ // $cfg['Servers'][$i]['controlhost'] = ''; // $cfg['Servers'][$i]['controlport'] = ''; -$cfg['Servers'][$i]['controluser'] = '__YNH_PMA_USER__'; -$cfg['Servers'][$i]['controlpass'] = '__YNH_PMA_PASSWORD__'; +$cfg['Servers'][$i]['controluser'] = '__DB_USER__'; +$cfg['Servers'][$i]['controlpass'] = '__DB_PWD__'; /* Storage database and tables */ -$cfg['Servers'][$i]['pmadb'] = '__YNH_PMA_USER__'; +$cfg['Servers'][$i]['pmadb'] = '__DB_USER__'; $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark'; $cfg['Servers'][$i]['relation'] = 'pma__relation'; $cfg['Servers'][$i]['table_info'] = 'pma__table_info'; diff --git a/conf/create_db.sql b/conf/create_db.sql index d603e62..ed1ef72 100644 --- a/conf/create_db.sql +++ b/conf/create_db.sql @@ -14,14 +14,14 @@ -- -------------------------------------------------------- -DROP DATABASE `__YNH_PMA_USER__`; +DROP DATABASE `__DB_USER__`; -- --- Database : `__YNH_PMA_USER__` +-- Database : `__DB_USER__` -- -CREATE DATABASE IF NOT EXISTS `__YNH_PMA_USER__` +CREATE DATABASE IF NOT EXISTS `__DB_USER__` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; -USE __YNH_PMA_USER__; +USE __DB_USER__; -GRANT SELECT, INSERT, DELETE, UPDATE ON `__YNH_PMA_USER__`.* TO - '__YNH_PMA_USER__'@localhost; +GRANT SELECT, INSERT, DELETE, UPDATE ON `__DB_USER__`.* TO + '__DB_USER__'@localhost; diff --git a/doc/.DS_Store b/doc/.DS_Store new file mode 100644 index 0000000..c90376b Binary files /dev/null and b/doc/.DS_Store differ diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md new file mode 100644 index 0000000..e9f5ca8 --- /dev/null +++ b/doc/DISCLAIMER.md @@ -0,0 +1,3 @@ +## Overview + +phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web. phpMyAdmin supports a wide range of operations on MySQL and MariaDB. Frequently used operations (managing databases, tables, columns, relations, indexes, users, permissions, etc) can be performed via the user interface, while you still have the ability to directly execute any SQL statement. \ No newline at end of file diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md new file mode 100644 index 0000000..9d3bf51 --- /dev/null +++ b/doc/DISCLAIMER_fr.md @@ -0,0 +1,3 @@ +## Vue d'ensemble + +phpMyAdmin est un outil logiciel libre écrit en PHP, destiné à gérer l'administration de MySQL sur le Web. phpMyAdmin prend en charge un large éventail d'opérations sur MySQL et MariaDB. Les opérations fréquemment utilisées (gestion des bases de données, des tables, des colonnes, des relations, des index, des utilisateurs, des autorisations, etc.) peuvent être effectuées via l'interface utilisateur, tandis que vous avez toujours la possibilité d'exécuter directement les instructions SQL. \ No newline at end of file diff --git a/doc/screenshots/68747470733a2f2f7777772e7068706d7961646d696e2e6e65742f7374617469632f696d616765732f73637265656e73686f74732f7374727563747572652e706e67.png b/doc/screenshots/68747470733a2f2f7777772e7068706d7961646d696e2e6e65742f7374617469632f696d616765732f73637265656e73686f74732f7374727563747572652e706e67.png new file mode 100644 index 0000000..054eb79 Binary files /dev/null and b/doc/screenshots/68747470733a2f2f7777772e7068706d7961646d696e2e6e65742f7374617469632f696d616765732f73637265656e73686f74732f7374727563747572652e706e67.png differ diff --git a/manifest.json b/manifest.json index e8ea9e4..2795400 100644 --- a/manifest.json +++ b/manifest.json @@ -6,20 +6,28 @@ "en": "Manage MySQL databases over the web", "fr": "Application web de gestion des bases de données MySQL" }, - "version": "5.0.4~ynh1", + "version": "5.1.1~ynh1", "url": "http://www.phpmyadmin.net", + "upstream": { + "license": "GPL-2.0-only", + "website": "http://www.phpmyadmin.net", + "demo": "https://demo.phpmyadmin.net/master-config", + "admindoc": "https://www.phpmyadmin.net/docs/", + "userdoc": "https://yunohost.org/en/app_phpmyadmin", + "code": "https://github.com/phpmyadmin/phpmyadmin" + }, "license": "GPL-2.0-only", "maintainer": { "name": "julien", "email": "julien.malik@paraiso.me" }, "requirements": { - "yunohost": ">= 3.8.1" + "yunohost": ">= 4.2.0" }, "multi_instance": false, "services": [ "nginx", - "php7.0-fpm", + "php7.3-fpm", "mysql" ], "arguments": { @@ -27,29 +35,17 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain for phpMyAdmin", - "fr": "Choisissez un domaine pour phpMyAdmin" - }, "example": "domain.org" }, { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for phpMyAdmin", - "fr": "Choisissez un chemin pour phpMyAdmin" - }, "example": "/phpmyadmin", "default": "/phpmyadmin" }, { "name": "admin", "type": "user", - "ask": { - "en": "Choose the only allowed admin user", - "fr": "Choisissez l'unique utilisateur autorisé" - }, "example": "johndoe" } ] diff --git a/pull_request_template.md b/pull_request_template.md deleted file mode 100644 index 10bffa7..0000000 --- a/pull_request_template.md +++ /dev/null @@ -1,24 +0,0 @@ -## Problem -- *Description of why you made this PR* - -## Solution -- *And how you fix that* - -## PR Status -- [ ] Code finished. -- [ ] Tested with Package_check. -- [ ] Fix or enhancement tested. -- [ ] Upgrade from last version tested. -- [ ] Can be reviewed and tested. - -## Validation ---- -*Minor decision* -- **Upgrade previous version** : -- [ ] **Code review** : -- [ ] **Approval (LGTM)** : -- [ ] **Approval (LGTM)** : -- **CI succeeded** : -[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/phpmyadmin_ynh%20PR-NUM-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/phpmyadmin_ynh%20PR-NUM-/) -*Please replace '-NUM-' in this link by the PR number.* -When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. diff --git a/scripts/_common.sh b/scripts/_common.sh index 46ce7fb..45d51fa 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,74 +5,19 @@ #================================================= YNH_PHP_VERSION="7.3" + extra_php_dependencies="php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-mbstring" +YNH_COMPOSER_VERSION=2.0.14 + +#================================================= +# PERSONAL HELPERS +#================================================= #================================================= # EXPERIMENTAL HELPERS #================================================= -# Execute a command as another user -# usage: exec_as USER COMMAND [ARG ...] -ynh_exec_as() { - local USER=$1 - shift 1 - - if [[ $USER = $(whoami) ]]; then - eval "$@" - else - sudo -u "$USER" "$@" - fi -} - -# Execute a command with Composer -# -# usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands" -# | arg: -v, --phpversion - PHP version to use with composer -# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. -# | arg: -c, --commands - Commands to execute. -ynh_composer_exec () { - # Declare an array to define the options of this helper. - local legacy_args=vwc - declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= ) - local phpversion - local workdir - local commands - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - workdir="${workdir:-$final_path}" - phpversion="${phpversion:-$YNH_PHP_VERSION}" - - COMPOSER_HOME="$workdir/.composer" \ - php${phpversion} "$workdir/composer.phar" $commands \ - -d "$workdir" --quiet --no-interaction -} - -# Install and initialize Composer in the given directory -# -# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"] -# | arg: -v, --phpversion - PHP version to use with composer -# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. -# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include -ynh_install_composer () { - # Declare an array to define the options of this helper. - local legacy_args=vwa - declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args=) - local phpversion - local workdir - local install_args - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - workdir="${workdir:-$final_path}" - phpversion="${phpversion:-$YNH_PHP_VERSION}" - install_args="${install_args:-}" - - curl -sS https://getcomposer.org/installer \ - | COMPOSER_HOME="$workdir/.composer" \ - php${phpversion} -- --quiet --install-dir="$workdir" \ - || ynh_die "Unable to install Composer." - - # update dependencies to create composer.lock - ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \ - || ynh_die "Unable to update core dependencies with Composer." -} \ No newline at end of file +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/change_url b/scripts/change_url index dd32bb0..416724c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -29,6 +29,23 @@ ynh_script_progression --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#================================================= +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 + +# Backup the current version of the app +ynh_backup_before_upgrade +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 + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= @@ -89,4 +106,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for phpMyAdmin" --last +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index 7688b3a..809b57e 100644 --- a/scripts/install +++ b/scripts/install @@ -54,6 +54,7 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_script_progression --message="Creating a MySQL database..." db_name=$(ynh_sanitize_dbid --db_name=$app) +db_user=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name @@ -70,6 +71,14 @@ then FLUSH PRIVILEGES;" --database=mysql fi +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=3 + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -79,6 +88,10 @@ 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" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -87,14 +100,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=3 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=3 - -# Create a system user -ynh_system_user_create --username=$app - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -110,7 +115,7 @@ ynh_add_fpm_config --package="$extra_php_dependencies" #================================================= ynh_script_progression --message="Filling database..." --weight=3 -ynh_replace_string --match_string="__YNH_PMA_USER__" --replace_string="$db_name" --target_file=../conf/create_db.sql +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file=../conf/create_db.sql ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" \ < ../conf/create_db.sql ynh_replace_string --match_string="phpmyadmin" --replace_string="$db_name" --target_file=$final_path/sql/create_tables.sql @@ -122,15 +127,10 @@ ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name #================================================= ynh_script_progression --message="Configuring phpMyAdmin..." -ynh_replace_string --match_string="__YNH_PMA_ADMIN_USER__" --replace_string="$db_admin_user" --target_file=../conf/config.inc.php -ynh_replace_string --match_string="__YNH_PMA_ADMIN_PASSWORD__" --replace_string="$db_admin_pwd" --target_file=../conf/config.inc.php -ynh_replace_string --match_string="__YNH_PMA_USER__" --replace_string="$db_name" --target_file=../conf/config.inc.php -ynh_replace_string --match_string="__YNH_PMA_PASSWORD__" --replace_string="$db_pwd" --target_file=../conf/config.inc.php - -cp ../conf/config.inc.php $final_path - -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$final_path/config.inc.php" +ynh_add_config --template="../conf/config.inc.php" --destination="$final_path/config.inc.php" +# config.inc.php contains sensitive data, restrict its access +chown $app: $final_path/config.inc.php +chmod 640 $final_path/config.inc.php #================================================= # INSTALL DEPENDENCIES WITH COMPOSER @@ -150,11 +150,6 @@ ynh_composer_exec --commands="update --no-dev" # SECURE FILES AND DIRECTORIES #================================================= -# Set permissions to app files -chown -R root: $final_path -# config.inc.php contains sensitive data, restrict its access -chown root:$app $final_path/config.inc.php -chmod 640 $final_path/config.inc.php # Setup phpMyAdmin temporary folder mkdir -p $final_path/tmp chown $app: $final_path/tmp @@ -162,10 +157,10 @@ chown $app: $final_path/tmp #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --weight=3 +ynh_script_progression --message="Configuring permissions..." --weight=3 # Restrict access to admin only -yunohost app addaccess --users=$admin $app +ynh_permission_update --permission="main" --remove="all_users" --add=$admin #================================================= # RELOAD NGINX @@ -178,4 +173,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of phpMyAdmin completed" --last +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 47fc652..d95d4fd 100644 --- a/scripts/remove +++ b/scripts/remove @@ -72,4 +72,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of phpMyAdmin completed" --last +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 9f85bc0..4a7311d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -47,6 +47,14 @@ test ! -d $final_path \ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --weight=2 + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -54,6 +62,10 @@ ynh_script_progression --message="Restoring phpMyAdmin main directory..." 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 MYSQL DATABASE #================================================= @@ -74,21 +86,10 @@ then FLUSH PRIVILEGES;" --database=mysql fi -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=2 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # RESTORE USER RIGHTS #================================================= -# config.inc.php contains sensitive data, restrict its access -chown root:$app $final_path/config.inc.php - chown $app: $final_path/tmp #================================================= @@ -116,4 +117,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for phpMyAdmin" --last +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index 1e33017..38435b5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,6 +21,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) admin=$(ynh_app_setting_get --app=$app --key=admin) 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_admin_user=$(ynh_app_setting_get --app=$app --key=db_admin_user) db_admin_pwd=$(ynh_app_setting_get --app=$app --key=db_admin_pwd) @@ -71,6 +72,11 @@ if [ -z "$db_admin_user" ]; then fi fi +if ! ynh_permission_exists --permission="admin"; then + # Create the required permissions + ynh_permission_create --permission="admin" --allowed=$admin +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -85,6 +91,14 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# 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 --home_dir="$final_path" + #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -96,9 +110,13 @@ then ynh_script_progression --message="Upgrading source files..." --weight=5 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$final_path" --keep="$final_path/config.inc.php" fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -107,14 +125,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..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -151,35 +161,12 @@ then < $final_path/sql/create_tables.sql fi -#================================================= -# CONFIGURE PHPMYADMIN -#================================================= -ynh_script_progression --message="Reconfiguring phpMyAdmin..." - -# Verify the checksum and backup the file if it's different -ynh_backup_if_checksum_is_different --file="$final_path/config.inc.php" - -ynh_replace_string --match_string="__YNH_PMA_ADMIN_USER__" --replace_string="$db_admin_user" --target_file=../conf/config.inc.php -ynh_replace_string --match_string="__YNH_PMA_ADMIN_PASSWORD__" --replace_string="$db_admin_pwd" --target_file=../conf/config.inc.php -ynh_replace_string --match_string="__YNH_PMA_USER__" --replace_string="$db_name" --target_file=../conf/config.inc.php -ynh_replace_string --match_string="__YNH_PMA_PASSWORD__" --replace_string="$db_pwd" --target_file=../conf/config.inc.php - -cp ../conf/config.inc.php $final_path - -# Recalculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$final_path/config.inc.php" - #================================================= # GENERIC FINALIZATION #================================================= # SECURE FILES AND DIRECTORIES #================================================= -# Set permissions to app files -chown -R root: $final_path -# config.inc.php contains sensitive data, restrict its access -chown root:$app $final_path/config.inc.php -chmod 640 $final_path/config.inc.php # Setup phpMyAdmin temporary folder mkdir -p $final_path/tmp chown -R $app: $final_path/tmp @@ -199,14 +186,6 @@ then ynh_exec_warn_less ynh_composer_exec --commands=\"update --no-dev\" fi -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." - -# Restrict access to admin only -yunohost app addaccess --users=$admin $app - #================================================= # RELOAD NGINX #================================================= @@ -218,4 +197,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of phpMyAdmin completed" --last +ynh_script_progression --message="Upgrade of $app completed" --last