diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh index c4d53fc..f50fe2b 100755 --- a/.github/workflows/updater.sh +++ b/.github/workflows/updater.sh @@ -9,9 +9,6 @@ # Since each app is different, maintainers can adapt its contents so as to perform # automatic actions when a new upstream release is detected. -# Remove this exit command when you are ready to run this Action -exit 1 - #================================================= # FETCHING LATEST RELEASE AND ITS ASSETS #================================================= @@ -21,64 +18,43 @@ current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') # Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) -assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) +assets="https://github.com/abantecart/abantecart-src/archive/refs/tags/$version.tar.gz" # Later down the script, we assume the version has only digits and dots # Sometimes the release name starts with a "v", so let's filter it out. -# You may need more tweaks here if the upstream repository has different naming conventions. +# You may need more tweaks here if the upstream repository has different naming conventions. if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then - version=${version:1} + version=${version:1} fi # Setting up the environment variables echo "Current version: $current_version" echo "Latest release from upstream: $version" echo "VERSION=$version" >> $GITHUB_ENV +echo "REPO=$repo" >> $GITHUB_ENV # For the time being, let's assume the script will fail echo "PROCEED=false" >> $GITHUB_ENV # Proceed only if the retrieved version is greater than the current one if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then - echo "::warning ::No new version available" - exit 0 + echo "::warning ::No new version available" + exit 0 # Proceed only if a PR for this new version does not already exist elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then - echo "::warning ::A branch already exists for this update" - exit 0 + echo "::warning ::A branch already exists for this update" + exit 0 fi -# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.) -echo "${#assets[@]} available asset(s)" - #================================================= # UPDATE SOURCE FILES #================================================= -# Here we use the $assets variable to get the resources published in the upstream release. -# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like. - -# Let's loop over the array of assets URLs -for asset_url in ${assets[@]}; do +# Let's download source tarball +asset_url=$assets echo "Handling asset at $asset_url" -# Assign the asset to a source file in conf/ directory -# Here we base the source file name upon a unique keyword in the assets url (admin vs. update) -# Leave $src empty to ignore the asset -case $asset_url in - *"admin"*) - src="app" - ;; - *"update"*) - src="app-upgrade" - ;; - *) - src="" - ;; -esac - -# If $src is not empty, let's process the asset -if [ ! -z "$src" ]; then +src="app" # Create the temporary directory tempdir="$(mktemp -d)" @@ -106,15 +82,10 @@ SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=$extension SOURCE_IN_SUBDIR=true SOURCE_FILENAME= +SOURCE_EXTRACT=true EOT echo "... conf/$src.src updated" -else -echo "... asset ignored" -fi - -done - #================================================= # SPECIFIC UPDATE STEPS #================================================= diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml new file mode 100644 index 0000000..fb72ba0 --- /dev/null +++ b/.github/workflows/updater.yml @@ -0,0 +1,49 @@ +# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected. +# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization. +# This file should be enough by itself, but feel free to tune it to your needs. +# It calls updater.sh, which is where you should put the app-specific update steps. +name: Check for new upstream releases +on: + # Allow to manually trigger the workflow + workflow_dispatch: + # Run it every day at 6:00 UTC + schedule: + - cron: '0 6 * * *' +jobs: + updater: + runs-on: ubuntu-latest + steps: + - name: Fetch the source code + uses: actions/checkout@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Run the updater script + id: run_updater + run: | + # Setting up Git user + git config --global user.name 'yunohost-bot' + git config --global user.email 'yunohost-bot@users.noreply.github.com' + # Run the updater script + /bin/bash .github/workflows/updater.sh + - name: Commit changes + id: commit + if: ${{ env.PROCEED == 'true' }} + run: | + git commit -am "Upgrade to v$VERSION" + - name: Create Pull Request + id: cpr + if: ${{ env.PROCEED == 'true' }} + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Update to version ${{ env.VERSION }} + committer: 'yunohost-bot ' + author: 'yunohost-bot ' + signoff: false + base: testing + branch: ci-auto-update-v${{ env.VERSION }} + delete-branch: true + title: 'Upgrade to version ${{ env.VERSION }}' + body: | + Upgrade to v${{ env.VERSION }} + draft: false diff --git a/README.md b/README.md index 7fc1e87..a9d9ffc 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ It shall NOT be edited by hand. # Abantecart for YunoHost -[![Integration level](https://dash.yunohost.org/integration/abantecart.svg)](https://dash.yunohost.org/appci/app/abantecart) ![](https://ci-apps.yunohost.org/ci/badges/abantecart.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/abantecart.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/abantecart.svg)](https://dash.yunohost.org/appci/app/abantecart) ![Working status](https://ci-apps.yunohost.org/ci/badges/abantecart.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/abantecart.maintain.svg) [![Install Abantecart with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=abantecart) *[Lire ce readme en français.](./README_fr.md)* @@ -20,35 +20,39 @@ AbanteCart is a free open source ecommerce platform to power online retail. Aban **Shipped version:** 1.3.2~ynh1 + **Demo:** https://www.abantecart.com/shopping-cart-demo ## Screenshots -![](./doc/screenshots/dashboard.png) +![Screenshot of Abantecart](./doc/screenshots/dashboard.png) ## Disclaimers / important information ### Important points to read before installing - Do not upgrade manually within the app, upgrade with Yunohost instead! +- Admin interface will be available at https://domain.tld/?s=admin + ## Documentation and resources -* Official app website: https://www.abantecart.com/ -* Official user documentation: https://abantecart.atlassian.net/wiki/spaces/AD/overview?homepageId=3506313 -* Official admin documentation: https://docs.abantecart.com/ -* Upstream app code repository: https://github.com/abantecart/abantecart-src -* YunoHost documentation for this app: https://yunohost.org/app_abantecart -* Report a bug: https://github.com/YunoHost-Apps/abantecart_ynh/issues +* Official app website: +* Official user documentation: +* 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/abantecart_ynh/tree/testing). To try the testing branch, please proceed like that. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/abantecart_ynh/tree/testing --debug or sudo yunohost app upgrade abantecart -u https://github.com/YunoHost-Apps/abantecart_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 3ee5d5f..05b4e91 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,10 +1,14 @@ + + # Abantecart pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/abantecart.svg)](https://dash.yunohost.org/appci/app/abantecart) ![](https://ci-apps.yunohost.org/ci/badges/abantecart.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/abantecart.maintain.svg) +[![Niveau d'intégration](https://dash.yunohost.org/integration/abantecart.svg)](https://dash.yunohost.org/appci/app/abantecart) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/abantecart.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/abantecart.maintain.svg) [![Installer Abantecart avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=abantecart) *[Read this readme in english.](./README.md)* -*[Lire ce readme en français.](./README_fr.md)* > *Ce package vous permet d'installer Abantecart 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.* @@ -14,37 +18,41 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour AbanteCart is a free open source ecommerce platform to power online retail. AbanteCart is a ready to run web application as well as reliable foundation to build custom eCommerce solutions. AbanteCart ecommerce platform is designed to fit a wide variety of online businesses and applications, as well as can be configured or customized to perform very specific business requirements. Chosen by many shop owners launching their business online for the first time, AbanteCart is also picked by developers looking for a user-friendly interface and powerful features set. -**Version incluse :** 1.3.2~ynh1 +**Version incluse :** 1.3.2~ynh1 + **Démo :** https://www.abantecart.com/shopping-cart-demo ## Captures d'écran -![](./doc/screenshots/dashboard.png) +![Capture d'écran de Abantecart](./doc/screenshots/dashboard.png) ## Avertissements / informations importantes ### Important points to read before installing - Do not upgrade manually within the app, upgrade with Yunohost instead! +- Admin interface will be available at https://domain.tld/?s=admin + ## Documentations et ressources -* Site officiel de l'app : https://www.abantecart.com/ -* Documentation officielle utilisateur : https://abantecart.atlassian.net/wiki/spaces/AD/overview?homepageId=3506313 -* Documentation officielle de l'admin : https://docs.abantecart.com/ -* Dépôt de code officiel de l'app : https://github.com/abantecart/abantecart-src -* Documentation YunoHost pour cette app : https://yunohost.org/app_abantecart -* Signaler un bug : https://github.com/YunoHost-Apps/abantecart_ynh/issues +* Site officiel de l'app : +* Documentation officielle utilisateur : +* 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/abantecart_ynh/tree/testing). Pour essayer la branche testing, procédez comme suit. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/abantecart_ynh/tree/testing --debug ou sudo yunohost app upgrade abantecart -u https://github.com/YunoHost-Apps/abantecart_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 728e84f..cd9baed 100644 --- a/check_process +++ b/check_process @@ -1,9 +1,9 @@ ;; Test complet ; Manifest domain="domain.tld" + is_public=1 admin="john" password="1Strong-Password" - is_public=1 ; Checks pkg_linter=1 setup_sub_dir=0 @@ -13,8 +13,11 @@ setup_public=1 upgrade=1 upgrade=1 from_commit=acdb6cfdf31a2f02baf5bbcbb5cc0cdaf0a3ac69 + # 1.3.2~ynh1 + upgrade=1 from_commit=4586e00bbf6ae98f49135623b282446613a9cb25 backup_restore=1 multi_instance=0 + port_already_use=0 change_url=0 ;;; Options Email= diff --git a/conf/app.src b/conf/app.src index 3054b0b..4225f82 100755 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,7 @@ -SOURCE_URL=https://github.com/abantecart/abantecart-src/archive/refs/tags/1.3.2.zip -SOURCE_SUM=631fd1032e5a32e3041c56e78048d611bcf28ef07bae1ac75bb467190f18f014 +SOURCE_URL=https://github.com/abantecart/abantecart-src/archive/refs/tags/1.3.2.tar.gz +SOURCE_SUM=58ed9007054e5f74826d8ac5d3358d893c612af34e04877107c9baf81f6d529f SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip +SOURCE_FORMAT=tar.gz +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= SOURCE_EXTRACT=true diff --git a/conf/nginx.conf b/conf/nginx.conf index 3e30c7c..93573eb 100755 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -7,48 +7,50 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { - # Path to source - alias __FINALPATH__/www/; + # Path to source + alias __FINALPATH__/www/; - index index.php; - if (!-e $request_filename) { - rewrite ^(.+)$ __PATH__/index.php?q=$1 last; - } + index index.php; + if (!-e $request_filename) { + rewrite ^(.+)$ __PATH__/index.php?q=$1 last; + } - client_max_body_size 30m; + # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file + client_max_body_size 50M; - location ~ [^/]\.php(/|$) { - fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; - fastcgi_index index.php; - include fastcgi_params; - fastcgi_param REMOTE_USER $remote_user; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param SCRIPT_FILENAME $request_filename; - } + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; - location ~ /\. { - deny all; - access_log off; - log_not_found off; - } + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $request_filename; + } + + location ~ /\. { + deny all; + access_log off; + log_not_found off; + } - location ~* \.(jpg|jpeg|png|gif|css|js|ico|webp)$ { - expires max; - log_not_found off; - } + location ~* \.(jpg|jpeg|png|gif|css|js|ico|webp)$ { + expires max; + log_not_found off; + } - location ~ /(system/logs|resources/download) { + location ~ /(system/logs|resources/download) { + deny all; + return 403; + } + + location /admin/ { + location ~ .*\.(php)?$ { deny all; return 403; } - - location /admin/ { - location ~ .*\.(php)?$ { - deny all; - return 403; - } - } + } # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index 6bcf295..aa62714 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -1,3 +1,4 @@ ### Important points to read before installing -- Do not upgrade manually within the app, upgrade with Yunohost instead! \ No newline at end of file +- Do not upgrade manually within the app, upgrade with Yunohost instead! +- Admin interface will be available at https://domain.tld/?s=admin diff --git a/manifest.json b/manifest.json index 3654fa1..31a2da4 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { - "id": "abantecart", "name": "Abantecart", + "id": "abantecart", "packaging_format": 1, "description": { "en": "Open source ecommerce platform to power online retail", @@ -14,7 +14,8 @@ "demo": "https://www.abantecart.com/shopping-cart-demo", "admindoc": "https://docs.abantecart.com/", "userdoc": "https://abantecart.atlassian.net/wiki/spaces/AD/overview?homepageId=3506313", - "code": "https://github.com/abantecart/abantecart-src" + "code": "https://github.com/abantecart/abantecart-src", + "cpe": "cpe:2.3:a:abantecart:abantecart" }, "license": "OSL-3.0", "maintainer": { @@ -31,27 +32,24 @@ "mysql" ], "arguments": { - "install" : [ + "install": [ { "name": "domain", "type": "domain" }, + { + "name": "is_public", + "type": "boolean", + "default": true + }, { "name": "admin", - "type": "user", - "help": { - "en": "Access admin page via https:////" - } + "type": "user" }, { "name": "password", "type": "password", "optional": false - }, - { - "name": "is_public", - "type": "boolean", - "default": true } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index d7614e9..03a6af2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,7 +4,10 @@ # COMMON VARIABLES #================================================= -YNH_PHP_VERSION="7.3" +php_dependencies="php$YNH_DEFAULT_PHP_VERSION-iconv php$YNH_DEFAULT_PHP_VERSION-mbstring php$YNH_DEFAULT_PHP_VERSION-mysqli php$YNH_DEFAULT_PHP_VERSION-mysql php$YNH_DEFAULT_PHP_VERSION-zip php$YNH_DEFAULT_PHP_VERSION-soap" + +# dependencies used by the app (must be on a single line) +pkg_dependencies="curl wget git libwebp-dev libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libpng-dev libxpm-dev libonig-dev libzip-dev mariadb-server mc net-tools libxml2-dev $php_dependencies" #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index 6f4f9c1..86cad22 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 @@ -13,6 +14,9 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors diff --git a/scripts/install b/scripts/install index 6fb34a2..bb0baa6 100644 --- a/scripts/install +++ b/scripts/install @@ -13,6 +13,9 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -22,13 +25,13 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" -password=$YNH_APP_ARG_PASSWORD is_public=$YNH_APP_ARG_IS_PUBLIC admin=$YNH_APP_ARG_ADMIN -phpversion=$YNH_PHP_VERSION -email=$(ynh_user_get_info --username=$admin --key=mail) +password=$YNH_APP_ARG_PASSWORD app=$YNH_APP_INSTANCE_NAME + +email=$(ynh_user_get_info --username=$admin --key=mail) src_version=$(ynh_app_upstream_version) #================================================= @@ -45,7 +48,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." +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 @@ -53,26 +56,23 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=src_version --value=$src_version +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=1 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # 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" -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE -#================================================= -ynh_script_progression --message="Setting up source files..." --weight=3 - -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/git_src" - -ln -s $final_path/git_src/public_html $final_path/www - #================================================= # CREATE A MYSQL DATABASE #================================================= @@ -84,40 +84,21 @@ 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 A MYSQL DATABASE +# DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Configuring a MySQL database..." --weight=2 +ynh_script_progression --message="Setting up source files..." --weight=3 -cat $final_path/www/install/cli_install.php -php_installer=$final_path/www/install/cli_install.php -php $php_installer install \ - --db_host=localhost \ - --db_user=$db_name \ - --db_password=$db_pwd \ - --db_name=$db_name \ - --db_driver=amysqli \ - --db_prefix=ac_ \ - --username=$admin \ - --admin_path=$admin \ - --password=$password \ - --email=$email \ - --http_server=https://$domain +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/git_src" +ln -s $final_path/git_src/public_html $final_path/www -ynh_secure_remove $final_path/www/install chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" find $final_path/www -type d -exec chmod 755 {} \; find $final_path/www -type f -exec chmod 644 {} \; -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=2 - -# Create a dedicated NGINX config -ynh_add_nginx_config - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -132,24 +113,63 @@ else fi # Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=$usage --footprint=low +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring NGINX web server..." --weight=2 + +# Create a dedicated NGINX config +ynh_add_nginx_config + +#================================================= +# SPECIFIC SETUP +#================================================= +# INSTALL APP +#================================================= +ynh_script_progression --message="Installing app..." --weight=2 + +php$phpversion $final_path/www/install/cli_install.php install \ + --db_host=localhost \ + --db_user=$db_name \ + --db_password=$db_pwd \ + --db_name=$db_name \ + --db_driver=amysqli \ + --db_prefix=ac_ \ + --username=$admin \ + --admin_path=admin \ + --password=$password \ + --email=$email \ + --http_server=https://$domain + +ynh_secure_remove $final_path/www/install + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" +find $final_path/www -type d -exec chmod 755 {} \; +find $final_path/www -type f -exec chmod 644 {} \; #================================================= # GENERIC FINALIZATION #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." +ynh_script_progression --message="Configuring permissions..." --weight=1 # 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 #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/remove b/scripts/remove index 30ecb13..f590974 100644 --- a/scripts/remove +++ b/scripts/remove @@ -39,6 +39,14 @@ ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely ynh_secure_remove --file="$final_path" +#================================================= +# REMOVE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Removing NGINX web server configuration..." --weight=2 + +# Remove the dedicated NGINX config +ynh_remove_nginx_config + #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= @@ -47,19 +55,12 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2 # Remove the dedicated PHP-FPM config ynh_remove_fpm_config -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=2 - -ynh_remove_nginx_config - #================================================= # GENERIC FINALIZATION #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." +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 dda4b05..539c28c 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 @@ -13,13 +14,16 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --weight=2 +ynh_script_progression --message="Loading installation settings..." --weight=2 app=$YNH_APP_INSTANCE_NAME @@ -39,32 +43,17 @@ fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=2 -test ! -d $final_path || ynh_die --message="There is already a directory: $final_path " +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1 - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - -#================================================= -# RESTORE THE MYSQL DATABASE -#================================================= - -ynh_script_progression --message="Restoring the MySQL database..." --weight=1 - -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql - #================================================= # 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" if [ -n "$password" ] @@ -86,22 +75,49 @@ chown -R $app:www-data "$final_path" find $final_path/www -type d -exec chmod 755 {} \; find $final_path/www -type f -exec chmod 644 {} \; +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=1 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Restoring PHP-FPM configuration..." --weight=2 +ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=2 ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" # Recreate a dedicated PHP-FPM config ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) + +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# RESTORE THE MYSQL DATABASE +#================================================= +ynh_script_progression --message="Restoring the MySQL database..." --weight=1 + +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." +ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 800e5d0..428b851 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,8 +22,7 @@ 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) src_version=$(ynh_app_setting_get --app=$app --key=src_version) - -phpversion=$YNH_PHP_VERSION +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) @@ -31,6 +30,7 @@ fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) @@ -48,6 +48,8 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -102,7 +104,33 @@ find $final_path/www -type f -exec chmod 644 {} \; ln -s $final_path/git_src/public_html $final_path/www #================================================= -# MYSQL CONFIGURATION +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=1 + +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 + +# Create a dedicated PHP-FPM config +ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 + +# Create a dedicated NGINX config +ynh_add_nginx_config + +#================================================= +# SPECIFIC UPGRADE +#================================================= +# UPGRADE MYSQL CONFIGURATION #================================================= ynh_script_progression --message="Upgrading MySQL configuration..." --weight=1 @@ -118,21 +146,7 @@ updated_src_version=$(ynh_app_upstream_version) ynh_app_setting_set --app=$app --key=src_version --value=$updated_src_version #================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 - -# Create a dedicated NGINX config -ynh_add_nginx_config - -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 - -# Create a dedicated PHP-FPM config -ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint - +# GENERIC FINALIZATION #================================================= # RELOAD NGINX #=================================================