diff --git a/issue_template.md b/.github/ISSUE_TEMPLATE.md similarity index 89% rename from issue_template.md rename to .github/ISSUE_TEMPLATE.md index a975880..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 @@ -22,7 +22,7 @@ about: When creating a bug report, please use the following template to provide - 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* +- 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`* @@ -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 snipeit + 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 1c8d02f..0d16df9 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,37 @@ + + # Snipe-IT for YunoHost [![Integration level](https://dash.yunohost.org/integration/snipeit.svg)](https://dash.yunohost.org/appci/app/snipeit) ![](https://ci-apps.yunohost.org/ci/badges/snipeit.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/snipeit.maintain.svg) -[![Install Snipe-IT with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=snipeit) +[![Install Snipe-IT with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=snipeit) -> *This package allows you to install Snipe-IT quickly and simply on a YunoHost server. +*[Lire ce readme en français.](./README_fr.md)* + +> *This package allows you to install Snipe-IT 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 -Snipe-IT is a FOSS project for asset management in IT Operations. Knowing who has which laptop, when it was purchased in order to depreciate it correctly, handling software licenses, etc. It is built on Laravel 5.4. -**Shipped version:** 5.0.4 +Manage assets for IT operations + +**Shipped version:** 5.3.1~ynh1 + +**Demo:** https://snipeitapp.com/demo/ ## Screenshots -![](https://snipeitapp.com/img/screenshots/screenshot-license-list.png) +![](./doc/screenshots/screenshot-license-list.png) -## Demo +## Documentation and resources -* [Official demo](https://snipeitapp.com/demo/) - -## Configuration - - 1. Require dedicated domain like **asset.domain.tld**. - 1. No LDAP support yet. - 1. This app is multi-instance (you can have more then one instance of this app running on a YunoHost server) - -#### Supported architectures - -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/snipeit%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/snipeit/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/snipeit%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/snipeit/) - -## Links - - * Report a bug: https://github.com/YunoHost-Apps/snipeit_ynh/issues - * App website: https://snipeitapp.com/ - * Upstream app repository: https://github.com/snipe/snipe-it - * YunoHost website: https://yunohost.org/ - ---- +* Official app website: https://snipeitapp.com/ +* Official admin documentation: https://snipe-it.readme.io/docs +* Upstream app code repository: https://github.com/snipe/snipe-it +* YunoHost documentation for this app: https://yunohost.org/app_snipeit +* Report a bug: https://github.com/YunoHost-Apps/snipeit_ynh/issues ## Developer info @@ -49,3 +43,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/snipeit_ynh/tree/test or sudo yunohost app upgrade snipeit -u https://github.com/YunoHost-Apps/snipeit_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 new file mode 100644 index 0000000..a1a56d4 --- /dev/null +++ b/README_fr.md @@ -0,0 +1,43 @@ +# Snipe-IT pour YunoHost + +[![Niveau d'intégration](https://dash.yunohost.org/integration/snipeit.svg)](https://dash.yunohost.org/appci/app/snipeit) ![](https://ci-apps.yunohost.org/ci/badges/snipeit.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/snipeit.maintain.svg) +[![Installer Snipe-IT avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=snipeit) + +*[Read this readme in english.](./README.md)* +*[Lire ce readme en français.](./README_fr.md)* + +> *Ce package vous permet d'installer Snipe-IT 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 + +Gestionnaire de ressources informatiques + +**Version incluse :** 5.3.1~ynh1 + +**Démo :** https://snipeitapp.com/demo/ + +## Captures d'écran + +![](./doc/screenshots/screenshot-license-list.png) + +## Documentations et ressources + +* Site officiel de l'app : https://snipeitapp.com/ +* Documentation officielle de l'admin : https://snipe-it.readme.io/docs +* Dépôt de code officiel de l'app : https://github.com/snipe/snipe-it +* Documentation YunoHost pour cette app : https://yunohost.org/app_snipeit +* Signaler un bug : https://github.com/YunoHost-Apps/snipeit_ynh/issues + +## Informations pour les développeurs + +Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/snipeit_ynh/tree/testing). + +Pour essayer la branche testing, procédez comme suit. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/snipeit_ynh/tree/testing --debug +ou +sudo yunohost app upgrade snipeit -u https://github.com/YunoHost-Apps/snipeit_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 5f43ac5..1976c32 100644 --- a/check_process +++ b/check_process @@ -1,15 +1,10 @@ -# 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="/path" (PATH) - admin="john" (USER) + domain="domain.tld" + path="/path" + admin="john" language="fr" - is_public=1 (PUBLIC|public=1|private=0) + is_public=1 ; Checks pkg_linter=1 setup_sub_dir=0 @@ -18,15 +13,11 @@ setup_private=1 setup_public=1 upgrade=1 - upgrade=1 from_commit=f0ce10dd27b78009dd754c4210111aa0eff12ad9 + upgrade=1 from_commit=c0be2e5239ccad4cff25d5bd1584eabd11617220 backup_restore=1 multi_instance=0 incorrect_path=1 - port_already_use=0 change_url=0 -;;; Levels - # If the level 5 (Package linter) is forced to 1. Please add justifications here. - Level 5=auto ;;; Options Email=anmol@datamol.org Notification=change diff --git a/conf/.env b/conf/.env index 129bc5d..45fba08 100644 --- a/conf/.env +++ b/conf/.env @@ -15,7 +15,7 @@ DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_DATABASE=__DB_NAME__ DB_USERNAME=__DB_USER__ -DB_PASSWORD=__DB_PASS__ +DB_PASSWORD=__DB_PWD__ DB_PREFIX=null DB_DUMP_PATH='/usr/bin' DB_CHARSET=utf8mb4 diff --git a/conf/app.src b/conf/app.src index ed58018..21d8459 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,5 @@ -SOURCE_URL=https://github.com/snipe/snipe-it/archive/v5.0.4.tar.gz -SOURCE_SUM=b06eef8d8f7a3063d93ebfcfe10c1d238c8879d555d0b48e01cc854e9d3d1d44 +SOURCE_URL=https://github.com/snipe/snipe-it/archive/v5.3.1.tar.gz +SOURCE_SUM=0870373e35dbe34574322d49da647a4c5cf8912a153ab520eb065cc4b06787e0 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= diff --git a/doc/screenshots/screenshot-license-list.png b/doc/screenshots/screenshot-license-list.png new file mode 100644 index 0000000..5e174f8 Binary files /dev/null and b/doc/screenshots/screenshot-license-list.png differ diff --git a/manifest.json b/manifest.json index f742d29..bf748d6 100644 --- a/manifest.json +++ b/manifest.json @@ -6,49 +6,42 @@ "en": "Manage assets for IT operations", "fr": "Gestionnaire de ressources informatiques" }, - "version": "5.0.4~ynh1", + "version": "5.3.1~ynh1", "url": "https://snipeitapp.com/", + "upstream": { + "license": "MIT", + "website": "https://snipeitapp.com/", + "demo": "https://snipeitapp.com/demo/", + "admindoc": "https://snipe-it.readme.io/docs", + "code": "https://github.com/snipe/snipe-it" + }, "license": "MIT", "maintainer": { "name": "Anmol Sharma", "email": "anmol@datamol.org" }, "requirements": { - "yunohost": ">= 4.0.0" + "yunohost": ">= 4.3.0" }, "multi_instance": false, "services": [ "nginx", - "php7.0-fpm", + "php7.3-fpm", "mysql" ], "arguments": { "install" : [ { "name": "domain", - "type": "domain", - "ask": { - "en": "Choose a domain name for Snipe-IT", - "fr": "Choisissez un nom de domaine pour Snipe-IT" - }, - "example": "example.com" + "type": "domain" }, { "name": "admin", - "type": "user", - "ask": { - "en": "Choose an admin user", - "fr": "Choisissez l'administrateur" - }, - "example": "johndoe" + "type": "user" }, { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une application publique ?" - }, "default": true }, { diff --git a/pull_request_template.md b/pull_request_template.md deleted file mode 100644 index 346abfd..0000000 --- a/pull_request_template.md +++ /dev/null @@ -1,18 +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 ---- -*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* - -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/snipeit_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/snipeit_ynh%20PR-NUM-%20(USERNAME)/) diff --git a/scripts/_common.sh b/scripts/_common.sh index 2f36635..9e24f07 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,12 +6,11 @@ # Packages requirements: https://snipe-it.readme.io/docs/requirements -# dependencies used by the app -pkg_dependencies="openssl" +YNH_PHP_VERSION="7.3" -YNH_PHP_VERSION=7.3 +pkg_dependencies="openssl php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-bcmath php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-gd" -extra_php_dependencies="php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-bcmath php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-common php${YNH_PHP_VERSION}-gd" +YNH_COMPOSER_VERSION=2.0.14 #================================================= # PERSONAL HELPERS @@ -21,79 +20,6 @@ extra_php_dependencies="php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-cur # EXPERIMENTAL HELPERS #================================================= -# Execute a command as another user -# usage: exec_as USER COMMAND [ARG ...] -exec_as() { - local USER=$1 - shift 1 - - if [[ $USER = $(whoami) ]]; then - eval $@ - else - sudo -u "$USER" $@ - fi -} - #================================================= # FUTURE OFFICIAL HELPERS #================================================= - -readonly YNH_DEFAULT_COMPOSER_VERSION=1.10.17 -# Declare the actual composer version to use. -# A packager willing to use another version of composer can override the variable into its _common.sh. -YNH_COMPOSER_VERSION=${YNH_COMPOSER_VERSION:-$YNH_DEFAULT_COMPOSER_VERSION} - -# 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"] [--composerversion=composerversion] -# | 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 -# | arg: -c, --composerversion - Composer version to install -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= [c]=composerversion=) - local phpversion - local workdir - local install_args - local composerversion - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - workdir="${workdir:-$final_path}" - phpversion="${phpversion:-$YNH_PHP_VERSION}" - install_args="${install_args:-}" - composerversion="${composerversion:-$YNH_COMPOSER_VERSION}" - - curl -sS https://getcomposer.org/installer \ - | COMPOSER_HOME="$workdir/.composer" \ - php${phpversion} -- --quiet --install-dir="$workdir" --version=$composerversion \ - || ynh_die --message="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 --message="Unable to update core dependencies with Composer." -} diff --git a/scripts/install b/scripts/install index 5789a32..1e256fd 100755 --- a/scripts/install +++ b/scripts/install @@ -28,6 +28,8 @@ path_url="/" admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC language=$YNH_APP_ARG_LANGUAGE +email=$(ynh_user_get_info --username=$admin --key=mail) +key= app=$YNH_APP_INSTANCE_NAME @@ -50,7 +52,6 @@ ynh_script_progression --message="Storing installation settings..." --weight=2 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=language --value=$language #================================================= @@ -103,7 +104,7 @@ ynh_system_user_create --username=$app ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies" +ynh_add_fpm_config --usage=low --footprint=low phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= @@ -121,17 +122,10 @@ ynh_install_composer #================================================= ynh_script_progression --message="Building..." -# Get admin email -email=$(ynh_user_get_info $admin 'mail') +ynh_add_config --template="../conf/.env" --destination="$final_path/.env" -# setup application config -cp ../conf/.env $final_path/.env - -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/.env" -ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="$final_path/.env" -ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_name" --target_file="$final_path/.env" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/.env" -ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/.env" +chmod 600 "$final_path/.env" +chown $app:$app "$final_path/.env" # setup application config pushd "$final_path" @@ -141,14 +135,6 @@ pushd "$final_path" php$phpversion artisan config:cache -n popd -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= -ynh_script_progression --message="Storing the config file checksum..." --weight=1 - -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum "$final_path/.env" - #================================================= # GENERIC FINALIZATION #================================================= @@ -158,6 +144,7 @@ ynh_script_progression --message="Securing files and directories..." --weight=1 # Set permissions to app files chown -R $app: $final_path +chmod -R o-rwx $final_path chmod -R 755 $final_path/storage chmod -R 755 $final_path/public/uploads @@ -169,8 +156,6 @@ ynh_script_progression --message="Configuring SSOwat..." --weight=3 # Make app public if necessary or protect it if [ $is_public -eq 1 ] then - # Everyone can access the app. - # The "main" permission is automatically created before the install script. ynh_permission_update --permission "main" --add "visitors" fi diff --git a/scripts/restore b/scripts/restore index 2508374..c509ffe 100755 --- a/scripts/restore +++ b/scripts/restore @@ -38,8 +38,6 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=2 -ynh_webpath_available --domain=$domain --path_url=$path_url \ - || ynh_die --message="Path not available: ${domain}${path_url}" test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " @@ -74,6 +72,7 @@ ynh_script_progression --message="Restoring user rights..." # Restore permissions on app files chown -R $app: $final_path +chmod -R o-rwx $final_path #================================================= # RESTORE THE PHP-FPM CONFIGURATION @@ -84,7 +83,7 @@ ynh_script_progression --message="Restoring PHP-FPM configuration..." ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" # Recreate a dedicated php-fpm config -ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies" +ynh_add_fpm_config --usage=low --footprint=low #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index 6129e57..ee22f88 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,7 +19,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) admin=$(ynh_app_setting_get --app=$app --key=admin) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) 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) @@ -28,36 +27,9 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 - -# Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=0 - is_public=0 -fi - -# 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 - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -72,6 +44,30 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 + +# 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 + +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -83,7 +79,7 @@ then ynh_script_progression --message="Upgrading source files..." --weight=7 # 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/.env" fi #================================================= @@ -115,7 +111,7 @@ ynh_system_user_create --username=$app ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies" +ynh_add_fpm_config --usage=low --footprint=low #================================================= # SPECIFIC UPGRADE @@ -127,7 +123,7 @@ ynh_script_progression --message="Installing Composer..." --weight=15 # Install composer ynh_install_composer -ynh_exec_warn_less ynh_composer_exec --commands=\"dump-autoload\" +ynh_exec_warn_less ynh_composer_exec --commands="dump-autoload" pushd "$final_path" php$phpversion artisan migrate -n --force @@ -148,21 +144,10 @@ ynh_script_progression --message="Securing files and directories..." --weight=1 # Set permissions on app files chown -R $app: $final_path +chmod -R o-rwx $final_path chmod -R 755 $final_path/storage chmod -R 755 $final_path/public/uploads -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." - -# Make app public if necessary -if [ $is_public -eq 1 ] -then - # unprotected_uris allows SSO credentials to be passed anyway - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" -fi - #================================================= # RELOAD NGINX #=================================================