diff --git a/README.md b/README.md index 69a80b2..84c33a9 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ It shall NOT be edited by hand. # 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) +[![Integration level](https://dash.yunohost.org/integration/snipeit.svg)](https://dash.yunohost.org/appci/app/snipeit) ![Working status](https://ci-apps.yunohost.org/ci/badges/snipeit.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/snipeit.maintain.svg) [![Install Snipe-IT with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=snipeit) *[Lire ce readme en français.](./README_fr.md)* @@ -17,31 +17,32 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Manage assets for IT operations -**Shipped version:** 5.3.1~ynh2 +**Shipped version:** 5.3.1~ynh3 **Demo:** https://snipeitapp.com/demo/ ## Screenshots -![](./doc/screenshots/screenshot-license-list.png) +![Screenshot of Snipe-IT](./doc/screenshots/screenshot-license-list.png) ## Documentation and resources -* 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 +* Official app website: +* Official admin documentation: +* Upstream app code repository: +* YunoHost documentation for this app: +* Report a bug: ## Developer info Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/snipeit_ynh/tree/testing). To try the testing branch, please proceed like that. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/snipeit_ynh/tree/testing --debug 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 +**More info regarding app packaging:** diff --git a/README_fr.md b/README_fr.md index 72f482c..ee5e1f9 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,10 +1,14 @@ + + # 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) +[![Niveau d'intégration](https://dash.yunohost.org/integration/snipeit.svg)](https://dash.yunohost.org/appci/app/snipeit) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/snipeit.status.svg) ![Statut de maintenance](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.* @@ -13,31 +17,32 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Gestionnaire de ressources informatiques -**Version incluse :** 5.3.1~ynh2 +**Version incluse :** 5.3.1~ynh3 **Démo :** https://snipeitapp.com/demo/ ## Captures d'écran -![](./doc/screenshots/screenshot-license-list.png) +![Capture d'écran de Snipe-IT](./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 +* Site officiel de l'app : +* Documentation officielle de l'admin : +* Dépôt de code officiel de l'app : +* Documentation YunoHost pour cette app : +* Signaler un bug : ## 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. -``` + +``` bash 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 +**Plus d'infos sur le packaging d'applications :** diff --git a/check_process b/check_process index 1976c32..5c1cc9e 100644 --- a/check_process +++ b/check_process @@ -1,10 +1,9 @@ ;; Test complet ; Manifest domain="domain.tld" - path="/path" - admin="john" - language="fr" is_public=1 + language="fr" + admin="john" ; Checks pkg_linter=1 setup_sub_dir=0 @@ -13,12 +12,14 @@ setup_private=1 setup_public=1 upgrade=1 - upgrade=1 from_commit=c0be2e5239ccad4cff25d5bd1584eabd11617220 + # 5.0.4~ynh1 + upgrade=1 from_commit=c0be2e5239ccad4cff25d5bd1584eabd11617220 + # 5.3.1~ynh2 + upgrade=1 from_commit=7461b1d0f1f0da643e348da3d7ac76c51fd7c576 backup_restore=1 multi_instance=0 - incorrect_path=1 + port_already_use=0 change_url=0 ;;; Options Email=anmol@datamol.org -Notification=change - +Notification=none diff --git a/conf/.env b/conf/.env index 715541e..c495a9f 100644 --- a/conf/.env +++ b/conf/.env @@ -3,7 +3,7 @@ # -------------------------------------------- APP_ENV=production APP_DEBUG=false -APP_KEY=__KEY__ +APP_KEY=__APP_KEY__ APP_URL=http://__DOMAIN__ APP_TIMEZONE='UTC' APP_LOCALE=__LANGUAGE__ @@ -79,7 +79,7 @@ CACHE_PREFIX=snipeit # -------------------------------------------- REDIS_HOST="127.0.0.1" REDIS_PASSWORD=null -REDIS_PORT=__REDIS_DB__ +REDIS_PORT=6379 # -------------------------------------------- # OPTIONAL: MEMCACHED SETTINGS diff --git a/conf/app.src b/conf/app.src index 21d8459..e2f2ad6 100644 --- a/conf/app.src +++ b/conf/app.src @@ -3,3 +3,5 @@ SOURCE_SUM=0870373e35dbe34574322d49da647a4c5cf8912a153ab520eb065cc4b06787e0 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= +SOURCE_EXTRACT=true diff --git a/conf/nginx.conf b/conf/nginx.conf index 82991f6..945405d 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,4 @@ -#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location ^~ __PATH__/ { # Path to source @@ -16,8 +16,8 @@ location ^~ __PATH__/ { fastcgi_index index.php; include fastcgi_params; - fastcgi_param REMOTE_USER $remote_user; - fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $request_filename; } diff --git a/manifest.json b/manifest.json index ef59458..bbc0564 100644 --- a/manifest.json +++ b/manifest.json @@ -6,19 +6,19 @@ "en": "Manage assets for IT operations", "fr": "Gestionnaire de ressources informatiques" }, - "version": "5.3.1~ynh2", - "url": "https://snipeitapp.com/", + "version": "5.3.1~ynh3", + "url": "https://snipeitapp.com", "upstream": { "license": "MIT", - "website": "https://snipeitapp.com/", + "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" + "name": "", + "email": "" }, "requirements": { "yunohost": ">= 4.3.0" @@ -30,15 +30,11 @@ "mysql" ], "arguments": { - "install" : [ + "install": [ { "name": "domain", "type": "domain" }, - { - "name": "admin", - "type": "user" - }, { "name": "is_public", "type": "boolean", @@ -53,6 +49,10 @@ }, "choices": ["en", "fr"], "default": "en" + }, + { + "name": "admin", + "type": "user" } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index d3386d2..01e0d3f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,11 +7,11 @@ # Packages requirements: https://snipe-it.readme.io/docs/requirements 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" - YNH_COMPOSER_VERSION=2.0.14 +# dependencies used by the app +pkg_dependencies="openssl redis php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-bcmath php${YNH_PHP_VERSION}-redis" + #================================================= # PERSONAL HELPERS #================================================= @@ -20,44 +20,3 @@ YNH_COMPOSER_VERSION=2.0.14 # EXPERIMENTAL HELPERS #================================================= -#================================================= -# REDIS HELPERS -#================================================= - -# get the first available redis database -# -# usage: ynh_redis_get_free_db -# | returns: the database number to use -ynh_redis_get_free_db() { - local result max db - result="$(redis-cli INFO keyspace)" - - # get the num - max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+") - - db=0 - # default Debian setting is 15 databases - for i in $(seq 0 "$max") - do - if ! echo "$result" | grep -q "db$i" - then - db=$i - break 1 - fi - db=-1 - done - - test "$db" -eq -1 && ynh_die --message="No available Redis databases..." - - echo "$db" -} - -# Create a master password and set up global settings -# Please always call this script in install and restore scripts -# -# usage: ynh_redis_remove_db database -# | arg: database - the database to erase -ynh_redis_remove_db() { - local db=$1 - redis-cli -n "$db" flushall -} diff --git a/scripts/backup b/scripts/backup index 796c5b4..99f5b6d 100755 --- 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 diff --git a/scripts/install b/scripts/install index 54f6d68..e294c32 100755 --- a/scripts/install +++ b/scripts/install @@ -25,12 +25,9 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN 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=$(ynh_string_random --length=24) -phpversion=$YNH_PHP_VERSION +admin=$YNH_APP_ARG_ADMIN app=$YNH_APP_INSTANCE_NAME @@ -52,9 +49,8 @@ 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=language --value=$language -ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion +ynh_app_setting_set --app=$app --key=admin --value=$admin #================================================= # STANDARD MODIFICATIONS @@ -65,6 +61,14 @@ ynh_script_progression --message="Installing dependencies..." --weight=3 ynh_install_app_dependencies $pkg_dependencies +#================================================= +# 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" + #================================================= # CREATE A MYSQL DATABASE #================================================= @@ -75,14 +79,6 @@ 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=3 - -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -92,14 +88,6 @@ 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" -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=5 - -# Create a dedicated NGINX config -ynh_add_nginx_config - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -107,6 +95,15 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 # Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=low --footprint=low +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring NGINX web server..." --weight=5 + +# Create a dedicated NGINX config +ynh_add_nginx_config #================================================= # SPECIFIC SETUP @@ -119,19 +116,21 @@ ynh_script_progression --message="Installing Composer..." --weight=21 ynh_install_composer #================================================= -# BUILDING +# ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Building..." - -# Configure redis -redis_db=$(ynh_redis_get_free_db) -ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" +ynh_script_progression --message="Adding a configuration file..." +app_key="" ynh_add_config --template="../conf/.env" --destination="$final_path/.env" chmod 600 "$final_path/.env" chown $app:$app "$final_path/.env" +#================================================= +# BUILDING +#================================================= +ynh_script_progression --message="Building..." + # setup application config pushd "$final_path" php$phpversion artisan key:generate -n --force --env @@ -140,12 +139,9 @@ pushd "$final_path" php$phpversion artisan config:cache -n popd -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." --weight=1 +app_key="$(grep "^APP_KEY=" "$final_path/.env" | cut -d= -f2)" +ynh_app_setting_set --app=$app --key=app_key --value=$app_key +ynh_store_file_checksum --file="$final_path/.env" # Set permissions to app files chown -R $app:www-data $final_path @@ -153,15 +149,19 @@ chmod -R o-rwx $final_path chmod -R 755 $final_path/storage chmod -R 755 $final_path/public/uploads +#================================================= +# GENERIC FINALIZATION #================================================= # SETUP SSOWAT #================================================= ynh_script_progression --message="Configuring permissions..." --weight=3 -# Make app public if necessary or protect it +# Make app public if necessary if [ $is_public -eq 1 ] then - ynh_permission_update --permission "main" --add "visitors" + # 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/remove b/scripts/remove index ae5943e..6a62cf1 100755 --- a/scripts/remove +++ b/scripts/remove @@ -20,37 +20,21 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name final_path=$(ynh_app_setting_get --app=$app --key=final_path) -redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) #================================================= # STANDARD REMOVE #================================================= # 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 -#================================================= -# REMOVE THE REDIS DATABASE -#================================================= -ynh_script_progression --message="Removing the redis database..." - -ynh_redis_remove_db "$redis_db" - -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies" --weight=2 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing Snipe-IT main directory" --weight=5 +ynh_script_progression --message="Removing app main directory..." --weight=5 # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -58,7 +42,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing NGINX web server configuration" --weight=1 +ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 # Remove the dedicated NGINX config ynh_remove_nginx_config @@ -66,17 +50,25 @@ ynh_remove_nginx_config #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Removing PHP-FPM configuration" --weight=2 +ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2 # Remove the dedicated PHP-FPM config ynh_remove_fpm_config +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=2 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + #================================================= # GENERIC FINALIZATION #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user" --weight=1 +ynh_script_progression --message="Removing the dedicated system user..." --weight=1 # Delete a system user ynh_system_user_delete --username=$app diff --git a/scripts/restore b/scripts/restore index 9f8a139..44e2195 100755 --- 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 @@ -22,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -43,13 +44,6 @@ test ! -d $final_path \ #================================================= # STANDARD RESTORATION STEPS -#================================================= -# 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" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -61,7 +55,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring Snipe-IT main directory..." --weight=7 +ynh_script_progression --message="Restoring the app main directory..." --weight=7 ynh_restore_file --origin_path="$final_path" @@ -69,17 +63,6 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" -#================================================= -# RESTORE THE PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring PHP-FPM configuration..." - -# Restore the file first, so it can have a backup if different -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 - #================================================= # SPECIFIC RESTORATION #================================================= @@ -90,6 +73,24 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=8 # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies +#================================================= +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the PHP-FPM configuration..." + +# Restore the file first, so it can have a backup if different +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 + +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + #================================================= # RESTORE THE MYSQL DATABASE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index aca058f..829886c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,37 +18,48 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) +language=$(ynh_app_setting_get --app=$app --key=language) admin=$(ynh_app_setting_get --app=$app --key=admin) 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) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +app_key=$(ynh_app_setting_get --app=$app --key=app_key) #================================================= # 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 Snipe-IT before upgrading (may take a while)..." --weight=4 +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=4 # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { - # 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 ynh_abort_if_errors +#================================================= +# STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + # If db_name doesn't exist, create it if [ -z "$db_name" ]; then db_name=$(ynh_sanitize_dbid --db_name=$app) @@ -61,11 +72,10 @@ if [ -z "$final_path" ]; then 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 +# If app_key doesn't exist, create it +if [ -z "$app_key" ]; then + app_key="$(grep "^APP_KEY=" "$final_path/.env" | cut -d= -f2)" + ynh_app_setting_set --app=$app --key=app_key --value=$app_key fi #================================================= @@ -76,8 +86,6 @@ 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 #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -90,14 +98,6 @@ then ynh_setup_source --dest_dir="$final_path" --keep="$final_path/.env" fi -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=3 - -# Create a dedicated NGINX config -ynh_add_nginx_config - #================================================= # UPGRADE DEPENDENCIES #================================================= @@ -113,6 +113,14 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 # Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=low --footprint=low +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=3 + +# Create a dedicated NGINX config +ynh_add_nginx_config + #================================================= # SPECIFIC UPGRADE #================================================= @@ -125,22 +133,25 @@ ynh_install_composer ynh_exec_warn_less ynh_composer_exec --commands="dump-autoload" -pushd "$final_path" - php$phpversion artisan migrate -n --force - php$phpversion artisan config:clear -n - php$phpversion artisan config:cache -n -popd +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a configuration file..." ynh_backup_if_checksum_is_different --file="$final_path/.env" # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$final_path/.env" #================================================= -# GENERIC FINALIZATION +# BUILDING #================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." --weight=1 +ynh_script_progression --message="Building..." + +pushd "$final_path" + php$phpversion artisan migrate -n --force + php$phpversion artisan config:clear -n + php$phpversion artisan config:cache -n +popd # Set permissions on app files chown -R $app:www-data $final_path @@ -148,6 +159,8 @@ chmod -R o-rwx $final_path chmod -R 755 $final_path/storage chmod -R 755 $final_path/public/uploads +#================================================= +# GENERIC FINALIZATION #================================================= # RELOAD NGINX #=================================================