diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh new file mode 100644 index 0000000..2a6f88e --- /dev/null +++ b/.github/workflows/updater.sh @@ -0,0 +1,103 @@ +#!/bin/bash + +#================================================= +# PACKAGE UPDATING HELPER +#================================================= + +# This script is meant to be run by GitHub Actions +# The YunoHost-Apps organisation offers a template Action to run this script periodically +# Since each app is different, maintainers can adapt its contents so as to perform +# automatic actions when a new upstream release is detected. + +#================================================= +# FETCHING LATEST RELEASE AND ITS ASSETS +#================================================= + +# Fetching information +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="https://github.com/$repo/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. +if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then + 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 +# 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 +# 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 +fi + +#================================================= +# UPDATE SOURCE FILES +#================================================= + +# Let's download source tarball +asset_url=$assets +echo "Handling asset at $asset_url" +src="app" + +# Create the temporary directory +tempdir="$(mktemp -d)" + +# Download sources and calculate checksum +filename=${asset_url##*/} +curl --silent -4 -L $asset_url -o "$tempdir/$filename" +checksum=$(sha256sum "$tempdir/$filename" | head -c 64) + +# Delete temporary directory +rm -rf $tempdir + +# Get extension +if [[ $filename == *.tar.gz ]]; then + extension=tar.gz +else + extension=${filename##*.} +fi + +# Rewrite source file +cat < conf/$src.src +SOURCE_URL=$asset_url +SOURCE_SUM=$checksum +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=$extension +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= +EOT +echo "... conf/$src.src updated" + +#================================================= +# SPECIFIC UPDATE STEPS +#================================================= + +# Any action on the app's source code can be done. +# The GitHub Action workflow takes care of committing all changes after this script ends. + +#================================================= +# GENERIC FINALIZATION +#================================================= + +# Replace new version in manifest +echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json + +# No need to update the README, yunohost-bot takes care of it + +# The Action will proceed only if the PROCEED environment variable is set to true +echo "PROCEED=true" >> $GITHUB_ENV +exit 0 diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml new file mode 100644 index 0000000..a56d7cb --- /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@v3 + 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@v4 + 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 e93c769..d60f930 100644 --- a/README.md +++ b/README.md @@ -1,60 +1,50 @@ + + # Photoview for YunoHost -[![Integration level](https://dash.yunohost.org/integration/photoview.svg)](https://dash.yunohost.org/appci/app/photoview) ![](https://ci-apps.yunohost.org/ci/badges/photoview.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/photoview.maintain.svg) -[![Install photoview with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=photoview) +[![Integration level](https://dash.yunohost.org/integration/photoview.svg)](https://dash.yunohost.org/appci/app/photoview) ![Working status](https://ci-apps.yunohost.org/ci/badges/photoview.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/photoview.maintain.svg) + +[![Install Photoview with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=photoview) *[Lire ce readme en français.](./README_fr.md)* -> *This package allows you to install Photoview quickly and simply on a YunoHost server. +> *This package allows you to install Photoview 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 + Photoview is a simple and user-friendly photo gallery that's made for photographers and aims to provide an easy and fast way to navigate directories, with thousands of high resolution photos. -**Shipped version:** 2.3.9 + +**Shipped version:** 2.3.12~ynh1 + +**Demo:** https://photos.qpqp.dk/ ## Screenshots -![](https://github.com/photoview/photoview/raw/master/screenshots/timeline.png) +![Screenshot of Photoview](./doc/screenshots/screenshot1.png) -## Demo +## Documentation and resources -* [Official demo](https://photos.qpqp.dk/) Username: **demo** Password: **demo** - -## Configuration - -You can access an admin panel from the web interface. - -## Documentation - -* Official documentation: https://photoview.github.io/docs/ - -#### Multi-user support - -Are LDAP and HTTP auth supported? **No** -Can the app be used by multiple users? **Yes** - -#### Supported architectures - -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/photoview.svg)](https://ci-apps.yunohost.org/ci/apps/photoview/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/photoview.svg)](https://ci-apps-arm.yunohost.org/ci/apps/photoview/) - -## Links - -* Report a bug: https://github.com/YunoHost-Apps/photoview_ynh/issues -* App website: https://photoview.github.io/ -* Upstream app repository: https://github.com/photoview/photoview -* YunoHost website: https://yunohost.org/ - ---- +* Official app website: +* Official admin documentation: +* Upstream app code repository: +* YunoHost Store: +* Report a bug: ## Developer info Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/photoview_ynh/tree/testing). To try the testing branch, please proceed like that. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/photoview_ynh/tree/testing --debug or sudo yunohost app upgrade photoview -u https://github.com/YunoHost-Apps/photoview_ynh/tree/testing --debug ``` + +**More info regarding app packaging:** diff --git a/README_fr.md b/README_fr.md index 8667afd..cc34ac5 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,60 +1,50 @@ + + # Photoview pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/photoview.svg)](https://dash.yunohost.org/appci/app/photoview) ![](https://ci-apps.yunohost.org/ci/badges/photoview.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/photoview.maintain.svg) -[![Installer photoview avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=photoview) +[![Niveau d’intégration](https://dash.yunohost.org/integration/photoview.svg)](https://dash.yunohost.org/appci/app/photoview) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/photoview.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/photoview.maintain.svg) + +[![Installer Photoview avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=photoview) *[Read this readme in english.](./README.md)* -> *Ce package vous permet d'installer Photoview 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 Photoview 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 -Photoview est une galerie photos simple et facile à utiliser, conçue pour les photographes et qui vise à fournir un moyen simple et rapide pour naviguer dans les dossiers contenant des milliers de photos haute résolution. +## Vue d’ensemble -**Version incluse :** 2.3.9 +Galerie photos simple et facile à utiliser, faite pour les photographes. -## Captures d'écran -![](https://github.com/photoview/photoview/raw/master/screenshots/timeline.png) +**Version incluse :** 2.3.12~ynh1 -## Démo +**Démo :** https://photos.qpqp.dk/ -* [Démo officielle](https://photos.qpqp.dk/) Nom d'utilisateur: **demo** Mot de pase: **demo** +## Captures d’écran -## Configuration +![Capture d’écran de Photoview](./doc/screenshots/screenshot1.png) -Vous pouvez accéder à un panneau admin depuis l'interface web. +## Documentations et ressources -## Documentation - -* Documentation officielle : https://photoview.github.io/docs/ - -#### Support multi-utilisateur - -* L'authentification LDAP et HTTP est-elle prise en charge ? **Non** -* L'application peut-elle être utilisée par plusieurs utilisateurs ? **Oui** - -#### Architectures supportées - -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/photoview.svg)](https://ci-apps.yunohost.org/ci/apps/photoview/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/photoview.svg)](https://ci-apps-arm.yunohost.org/ci/apps/photoview/) - -## Liens - -* Signaler un bug : https://github.com/YunoHost-Apps/photoview_ynh/issues -* Site de l'application : https://photoview.github.io/ -* Dépôt de l'application principale : https://github.com/photoview/photoview -* Site web YunoHost : https://yunohost.org/ - ---- +* Site officiel de l’app : +* Documentation officielle de l’admin : +* Dépôt de code officiel de l’app : +* YunoHost Store: +* Signaler un bug : ## Informations pour les développeurs Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/photoview_ynh/tree/testing). Pour essayer la branche testing, procédez comme suit. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/photoview_ynh/tree/testing --debug ou sudo yunohost app upgrade photoview -u https://github.com/YunoHost-Apps/photoview_ynh/tree/testing --debug ``` + +**Plus d’infos sur le packaging d’applications :** \ No newline at end of file diff --git a/conf/app.src b/conf/app.src index 38ee37a..f88f803 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,7 +1,6 @@ -SOURCE_URL=https://github.com/photoview/photoview/archive/refs/tags/v2.3.9.tar.gz -SOURCE_SUM=f5daaab41061f86c94b029914131f363d0774b29ace5db942c4ef6511914708e +SOURCE_URL=https://github.com/photoview/photoview/archive/refs/tags/v2.3.12.tar.gz +SOURCE_SUM=f9de00fb2d854217655a71264c06f8451b06b67170d3a5bbd9160fc94f1dda0f SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=v2.3.9.tar.gz -SOURCE_EXTRACT=true +SOURCE_FILENAME= diff --git a/conf/libheif.src b/conf/libheif.src index 44a6069..24a3d49 100644 --- a/conf/libheif.src +++ b/conf/libheif.src @@ -1,7 +1,7 @@ -SOURCE_URL=https://github.com/strukturag/libheif/releases/download/v1.11.0/libheif-1.11.0.tar.gz -SOURCE_SUM=c550938f56ff6dac83702251a143f87cb3a6c71a50d8723955290832d9960913 +SOURCE_URL=https://github.com/strukturag/libheif/releases/download/v1.12.0/libheif-1.12.0.tar.gz +SOURCE_SUM=e1ac2abb354fdc8ccdca71363ebad7503ad731c84022cf460837f0839e171718 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=libheif-1.11.0.tar.gz +SOURCE_FILENAME=libheif-1.12.0.tar.gz SOURCE_EXTRACT=true diff --git a/doc/.gitkeep b/doc/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..5cdf2cb --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +Photoview is a simple and user-friendly photo gallery that's made for photographers and aims to provide an easy and fast way to navigate directories, with thousands of high resolution photos. diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..3424e7d --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1 @@ +Galerie photos simple et facile à utiliser, faite pour les photographes. diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md new file mode 100644 index 0000000..e69de29 diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md new file mode 100644 index 0000000..e69de29 diff --git a/doc/screenshots/.gitkeep b/doc/screenshots/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/doc/screenshots/screenshot1.png b/doc/screenshots/screenshot1.png new file mode 100644 index 0000000..6fcd323 Binary files /dev/null and b/doc/screenshots/screenshot1.png differ diff --git a/manifest.json b/manifest.json index 568a077..d75bb6a 100644 --- a/manifest.json +++ b/manifest.json @@ -6,15 +6,22 @@ "en": "Simple and user-friendly photo gallery that's made for photographers ", "fr": "Galerie photos simple et facile à utiliser, faite pour les photographes" }, - "version": "2.3.9~ynh2", + "version": "2.3.12~ynh1", "url": "https://photoview.github.io/", + "upstream": { + "license": "AGPL-3.0-only", + "website": "https://photoview.github.io/", + "demo": "https://photos.qpqp.dk/", + "admindoc": "https://photoview.github.io/docs/", + "code": "https://github.com/photoview/photoview" + }, "license": "AGPL-3.0-only", "maintainer": { "name": "Jules Bertholet", "email": "jules.bertholet@gmail.com" }, "requirements": { - "yunohost": ">= 4.1.7" + "yunohost": ">= 4.3.0" }, "multi_instance": true, "services": [ @@ -22,11 +29,15 @@ "mysql" ], "arguments": { - "install" : [ + "install": [ { "name": "domain", - "type": "domain", - "example": "example.com" + "type": "domain" + }, + { + "name": "is_public", + "type": "boolean", + "default": true }, { "name": "mapbox_token", @@ -41,11 +52,6 @@ "en": "Required for mapping features. You can get one for free at https://www.mapbox.com/", "fr": "Nécessaire pour les fonctionnalités cartographiques. Vous pouvez en obtenir une gratuitement à https://www.mapbox.com/" } - }, - { - "name": "is_public", - "type": "boolean", - "default": true } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index 78dbcc8..9b271f0 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -29,6 +29,9 @@ function setup_sources { } function build_libheif { + export GOPATH="$final_path/build/go" + export GOCACHE="$final_path/build/.cache" + pushd "$final_path/libheif" || ynh_die chown -R $app:$app "$final_path/libheif" mkdir -p "$final_path/local" @@ -49,6 +52,9 @@ function set_go_vars { ynh_install_go --go_version=1.16 ynh_use_go + export GOPATH="$final_path/build/go" + export GOCACHE="$final_path/build/.cache" + go_shims_path=$goenv_install_dir/shims go_path_full="$go_shims_path":"$(sudo -u $app bash -c 'echo $PATH')" heif_lib_path="$final_path/local/lib":"$(sudo -u $app bash -c 'echo $LIBRARY_PATH')" diff --git a/scripts/backup b/scripts/backup index c4a4396..8a1d93f 100755 --- a/scripts/backup +++ b/scripts/backup @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup() { +ynh_clean_setup () { true } # Exit if an error occurs during the execution of the script @@ -28,9 +28,9 @@ ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) -data_path=$(ynh_app_setting_get --app=$app --key=data_path) domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +data_path=$(ynh_app_setting_get --app=$app --key=data_path) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -69,18 +69,12 @@ ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/systemd/system/$app.service" -#================================================= -# BACKUP VARIOUS FILES -#================================================= - -ynh_backup --src_path="/var/log/$app" - #================================================= # BACKUP THE MYSQL DATABASE #================================================= ynh_print_info --message="Backing up the MySQL database..." -ynh_mysql_dump_db --database="$db_name" >db.sql +ynh_mysql_dump_db --database="$db_name" > db.sql #================================================= # END OF SCRIPT diff --git a/scripts/change_url b/scripts/change_url index 448926b..773a160 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -40,13 +40,14 @@ data_path=$(ynh_app_setting_get --app=$app --key=data_path) mapbox_token=$(ynh_app_setting_get --app=$app --key=mapbox_token) #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=35 # Backup the current version of the app ynh_backup_before_upgrade -ynh_clean_setup() { +ynh_clean_setup () { + ynh_clean_check_starting # 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" @@ -61,7 +62,8 @@ ynh_abort_if_errors #================================================= change_domain=0 -if [ "$old_domain" != "$new_domain" ]; then +if [ "$old_domain" != "$new_domain" ] +then change_domain=1 fi @@ -84,7 +86,8 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf # Change the domain for NGINX -if [ $change_domain -eq 1 ]; then +if [ $change_domain -eq 1 ] +then # Delete file checksum for the old conf file location ynh_delete_file_checksum --file="$nginx_conf_path" mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf @@ -107,6 +110,7 @@ ynh_add_config --template=".env" --destination="$final_path/output/.env" #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 +# Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" #================================================= diff --git a/scripts/install b/scripts/install index 8fed52e..5d82380 100755 --- a/scripts/install +++ b/scripts/install @@ -13,8 +13,8 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup() { - true +ynh_clean_setup () { + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -39,7 +39,6 @@ final_path=/opt/yunohost/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" data_path=/home/yunohost.app/$app -test ! -e "$data_path" || ynh_die --message="This path already contains a folder" # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url @@ -56,7 +55,7 @@ ynh_app_setting_set --app=$app --key=mapbox_token --value=$mapbox_token #================================================= # STANDARD MODIFICATIONS #================================================= -# FIND PORTS +# FIND A PORT #================================================= ynh_script_progression --message="Finding an available port..." --weight=1 @@ -136,11 +135,12 @@ build_ui ynh_script_progression --message="Configuring a systemd service..." --weight=1 # Create a dedicated systemd config -ynh_add_systemd_config --service=$app +ynh_add_systemd_config #================================================= # ADD A CONFIGURATION #================================================= +ynh_script_progression --message="Adding a configuration file..." ynh_add_config --template=".env" --destination="$final_path/output/.env" @@ -177,7 +177,8 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary -if [ $is_public -eq 1 ]; then +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" diff --git a/scripts/remove b/scripts/remove index 4a979d7..c040eff 100755 --- a/scripts/remove +++ b/scripts/remove @@ -44,6 +44,14 @@ ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Removing logrotate configuration..." --weight=1 + +# Remove the app-specific logrotate config +ynh_remove_logrotate + #================================================= # REMOVE THE MYSQL DATABASE #================================================= @@ -52,14 +60,6 @@ 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 DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=5 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - #================================================= # REMOVE APP MAIN DIR #================================================= @@ -88,12 +88,14 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- ynh_remove_nginx_config #================================================= -# REMOVE LOGROTATE CONFIGURATION +# REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=1 +ynh_script_progression --message="Removing dependencies..." --weight=5 -# Remove the app-specific logrotate config -ynh_remove_logrotate +# Remove metapackage and its dependencies +ynh_remove_go +ynh_remove_nodejs +ynh_remove_app_dependencies #================================================= # SPECIFIC REMOVE @@ -104,20 +106,6 @@ ynh_remove_logrotate # Remove the log files ynh_secure_remove --file="/var/log/$app" -#================================================= -# REMOVE GO -#================================================= -ynh_script_progression --message="Removing Go..." --weight=1 - -ynh_remove_go - -#================================================= -# REMOVE NODE -#================================================= -ynh_script_progression --message="Removing Node.js..." --weight=1 - -ynh_remove_nodejs - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 96c7095..5c0042c 100755 --- a/scripts/restore +++ b/scripts/restore @@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup() { - true + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -42,36 +42,26 @@ mapbox_token=$(ynh_app_setting_get --app=$app --key=mapbox_token) #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=1 -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 " +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 web server configuration..." 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=1 # Create the dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=30 - -# Define and install dependencies -install_dependencies - #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -84,7 +74,6 @@ set_permissions #================================================= # RESTORE THE APP DATA DIR #================================================= - ynh_script_progression --message="Restoring the app data directory..." --weight=1 ynh_restore_file --origin_path="$data_path" --not_mandatory @@ -93,6 +82,16 @@ set_permissions #================================================= # SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=30 + +# Define and install dependencies +install_dependencies +set_go_vars +set_node_vars + #================================================= # RESTORE THE MYSQL DATABASE #================================================= @@ -100,21 +99,7 @@ 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 - -#================================================= -# RESTORE GO -#================================================= -ynh_script_progression --message="Restoring Go..." --weight=1 - -set_go_vars - -#================================================= -# RESTORE NODE.JS -#================================================= -ynh_script_progression --message="Restoring Node.js..." --weight=1 - -set_node_vars +ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= # RESTORE SYSTEMD @@ -124,6 +109,15 @@ ynh_script_progression --message="Restoring the systemd configuration..." --weig ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the logrotate configuration..." + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + +set_permissions + #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= @@ -138,20 +132,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -#================================================= -# RESTORE VARIOUS FILES -#================================================= - -ynh_restore_file --origin_path="/var/log/$app" - -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" - -set_permissions - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 8f98769..0c5ecb2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -29,6 +29,7 @@ mapbox_token=$(ynh_app_setting_get --app=$app --key=mapbox_token) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -39,7 +40,8 @@ ynh_script_progression --message="Backing up the app before upgrading (may take # Backup the current version of the app ynh_backup_before_upgrade -ynh_clean_setup() { +ynh_clean_setup () { + ynh_clean_check_starting # Restore it if the upgrade fails ynh_restore_upgradebackup } @@ -55,6 +57,18 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." + +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + #================================================= # CREATE DEDICATED USER #================================================= @@ -63,13 +77,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" -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=1 - -install_dependencies - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -88,9 +95,18 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=1 + +install_dependencies + #================================================= # SPECIFIC UPGRADE #================================================= +# BUILD APP +#================================================= if [ "$upgrade_type" == "UPGRADE_APP" ]; then #================================================= @@ -121,11 +137,12 @@ fi ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 # Create a dedicated systemd config -ynh_add_systemd_config --service=$app +ynh_add_systemd_config #================================================= # UPDATE A CONFIG FILE #================================================= +ynh_script_progression --message="Updating a configuration file..." ynh_add_config --template=".env" --destination="$final_path/output/.env" diff --git a/sources/extra_files/app/.gitignore b/sources/extra_files/app/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/extra_files/app/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op] diff --git a/sources/patches/.gitignore b/sources/patches/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/patches/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op]