From 378d1db56b05cf93161e891825fa7fa624dca6a1 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 21 Sep 2021 23:04:18 +0200 Subject: [PATCH 1/4] Fix --- manifest.json | 3 +-- scripts/backup | 7 ------- scripts/restore | 4 ---- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/manifest.json b/manifest.json index c197287..b095949 100644 --- a/manifest.json +++ b/manifest.json @@ -33,8 +33,7 @@ "arguments": { "install": [{ "name": "domain", - "type": "domain", - "example": "example.com" + "type": "domain" }, { diff --git a/scripts/backup b/scripts/backup index 6d8e73f..5f502ba 100644 --- a/scripts/backup +++ b/scripts/backup @@ -14,10 +14,6 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -69,9 +65,6 @@ ynh_backup --src_path="/etc/logrotate.d/$app" #================================================= ynh_print_info --message="Backing up the MySQL database..." -### (However, things like MySQL dumps *do* take some time to run, though the -### copy of the generated dump to the archive still happens later) - ynh_mysql_dump_db --database="$db_name" > db.sql #================================================= diff --git a/scripts/restore b/scripts/restore index d3cddcf..7731523 100644 --- a/scripts/restore +++ b/scripts/restore @@ -14,10 +14,6 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - #### Remove this function if there's nothing to clean before calling the remove script. - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors From d3f3b0042d1f6d184d15f1a718da566be2501ebd Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 20 Nov 2021 22:57:18 +0100 Subject: [PATCH 2/4] Fix --- .DS_Store | Bin 6148 -> 6148 bytes .github/ISSUE_TEMPLATE.md | 55 +++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 0 .github/workflows/updater.sh | 131 +++++++++++++++++++++++++++++++ conf/nginx.conf | 5 -- manifest.json | 5 +- scripts/_common.sh | 3 +- scripts/install | 12 ++- scripts/remove | 8 ++ scripts/restore | 8 ++ scripts/upgrade | 7 ++ 11 files changed, 222 insertions(+), 12 deletions(-) create mode 100755 .github/ISSUE_TEMPLATE.md mode change 100644 => 100755 .github/PULL_REQUEST_TEMPLATE.md create mode 100755 .github/workflows/updater.sh diff --git a/.DS_Store b/.DS_Store index 5418636d5ff4d3eab72b4d0225b468e8dc2a9ce7..b56e147091514bdee3fa8430589519c49d2c26f6 100644 GIT binary patch delta 324 zcmZoMXfc=|#>B!ku~2NHo}wrV0|Nsi1A_nqLk2@BLsC+CaY0hfW<%!X%r+n?b_P9$ zbcRfZ5@hN8B%mJYq=KBx;t~UcTZ~N1EUawo9GqO-JluTT0z7=&e3NaNGV5c4GgDHN z5{tq!Q%W-81w;diQp++^%L5YgQo}NfGm|oNGD|9>gER8Wp$ft5fW(pvpe9a%y__7J z@d6Un)kfx)Itr#{hP65h)#l~~ItnJnX0^2(oE#jo+FoHvm2Hz(Z$EtG*zpr5pFDjA zbTkk!0{vtHW{H4F1o0fmMDtZya8X`PeqK6IhH*0w(-Nl5>>T_Yz%T-a!*}M%{34DV PK;xJ|W^9fSS;Gtf=wnZi delta 85 zcmZoMXfc=|#>B)qu~2NHo}wrd0|Nsi1A_oVQh9MfQcivnkpE?4;c~{w1|lq*(^wZW kZEOf<-ptOy&jHl5S&-v9^JIPzM-HGekUo~p5h81t0fD6x`Tzg` diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100755 index 0000000..2729a6b --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,55 @@ +--- +name: Bug report +about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently. + +--- + +**How to post a meaningful bug report** +1. *Read this whole template first.* +2. *Determine if you are on the right place:* + - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* + - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.* + - *When in doubt, post here and we will figure it out together.* +3. *Delete the italic comments as you write over them below, and remove this guide.* +--- + +### Describe the bug + +*A clear and concise description of what the bug is.* + +### Context + +- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* +- YunoHost version: x.x.x +- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* +- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes* + - If yes, please explain: +- Using, or trying to install package version/branch: +- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* + +### Steps to reproduce + +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + sudo yunohost app install the_app + ``` +- *If you used the webadmin, please perform the equivalent command from the CLI first.* +- *If the error occurs in your browser, explain what you did:* + 1. *Go to '...'* + 2. *Click on '...'* + 3. *Scroll down to '...'* + 4. *See error* + +### Expected behavior + +*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* + +### Logs + +*When an operation fails, YunoHost provides a simple way to share the logs.* +- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.* +- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.* + +*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)* + +*If applicable and useful, add screenshots to help explain your problem.* diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md old mode 100644 new mode 100755 diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh new file mode 100755 index 0000000..58b3d7b --- /dev/null +++ b/.github/workflows/updater.sh @@ -0,0 +1,131 @@ +#!/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. + +# Remove this exit command when you are ready to run this Action +#exit 1 + +#================================================= +# 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=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) + +# 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 + +# 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 + +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 + "phpipam-v"*".zip") + src="app" + ;; +esac + +# If $src is not empty, let's process the asset +if [ ! -z "$src" ]; then + +# 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=zip +SOURCE_IN_SUBDIR=true +SOURCE_EXTRACT=true +SOURCE_FILENAME=phpipam.zip +EOT +echo "... conf/$src.src updated" + +else +echo "... asset ignored" +fi + +done + +#================================================= +# 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/conf/nginx.conf b/conf/nginx.conf index cfdefca..179ee75 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -4,11 +4,6 @@ location __PATH__/ { # Path to source alias __FINALPATH__/ ; - # Force usage of https - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } - index index.php; try_files $uri $uri/ index.php; diff --git a/manifest.json b/manifest.json index b095949..750fbe6 100644 --- a/manifest.json +++ b/manifest.json @@ -6,14 +6,13 @@ "en": "Web IP address management application", "fr": "Application web de gestion d'adresses IP" }, - "version": "1.4.4~ynh1", + "version": "1.4.4~ynh2", "url": "https://phpipam.net/", "upstream": { "license": "GPL-3.0-only", "website": "https://phpipam.net", "demo": "http://demo.phpipam.net", "admindoc": "https://phpipam.net/documents/", - "userdoc": "https://yunohost.org/apps", "code": "https://github.com/phpipam/phpipam" }, "license": "GPL-3.0-only", @@ -22,7 +21,7 @@ "email": "liberodark@gmail.com" }, "requirements": { - "yunohost": ">= 4.2.4" + "yunohost": ">= 4.3.0" }, "multi_instance": true, "services": [ diff --git a/scripts/_common.sh b/scripts/_common.sh index cca3315..b256aa7 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,7 +6,7 @@ YNH_PHP_VERSION="7.3" -extra_php_dependencies="php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-opcache php${YNH_PHP_VERSION}-fileinfo php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml" +pkg_dependencies="php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-opcache php${YNH_PHP_VERSION}-fileinfo php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml" #================================================= # PERSONAL HELPERS @@ -20,7 +20,6 @@ extra_php_dependencies="php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-mysql ph # FUTURE OFFICIAL HELPERS #================================================= - # Send an email to inform the administrator # # usage: ynh_send_readme_to_admin app_message [recipients] diff --git a/scripts/install b/scripts/install index 9426dee..6ba4dff 100644 --- a/scripts/install +++ b/scripts/install @@ -23,6 +23,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC +phpversion=$YNH_PHP_VERSION app=$YNH_APP_INSTANCE_NAME @@ -44,6 +45,14 @@ 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 +ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion + +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=1 + +ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER @@ -90,8 +99,7 @@ ynh_add_nginx_config ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --package="$extra_php_dependencies" -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +ynh_add_fpm_config #================================================= # ADD A CONFIGURATION diff --git a/scripts/remove b/scripts/remove index 0c7f610..c4c54fc 100644 --- a/scripts/remove +++ b/scripts/remove @@ -30,6 +30,14 @@ 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=1 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + #================================================= # REMOVE APP MAIN DIR #================================================= diff --git a/scripts/restore b/scripts/restore index 7731523..a23054f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -74,6 +74,14 @@ ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weig ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=1 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + #================================================= # RESTORE THE MYSQL DATABASE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 5cd3849..3772034 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -87,6 +87,13 @@ 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 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # PHP-FPM CONFIGURATION #================================================= From e757c0775b91a1e826ac53a5e0d5974305d14cfd Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 20 Nov 2021 21:57:24 +0000 Subject: [PATCH 3/4] Auto-update README --- README.md | 3 +-- README_fr.md | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3efdd78..3a91929 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Web IP address management application -**Shipped version:** 1.4.4~ynh1 +**Shipped version:** 1.4.4~ynh2 **Demo:** http://demo.phpipam.net @@ -29,7 +29,6 @@ Web IP address management application ## Documentation and resources * Official app website: https://phpipam.net -* Official user documentation: https://yunohost.org/apps * Official admin documentation: https://phpipam.net/documents/ * Upstream app code repository: https://github.com/phpipam/phpipam * YunoHost documentation for this app: https://yunohost.org/app_phpipam diff --git a/README_fr.md b/README_fr.md index 05676a5..43971a9 100644 --- a/README_fr.md +++ b/README_fr.md @@ -13,7 +13,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Application web de gestion d'adresses IP -**Version incluse :** 1.4.4~ynh1 +**Version incluse :** 1.4.4~ynh2 **Démo :** http://demo.phpipam.net @@ -25,7 +25,6 @@ Application web de gestion d'adresses IP ## Documentations et ressources * Site officiel de l'app : https://phpipam.net -* Documentation officielle utilisateur : https://yunohost.org/apps * Documentation officielle de l'admin : https://phpipam.net/documents/ * Dépôt de code officiel de l'app : https://github.com/phpipam/phpipam * Documentation YunoHost pour cette app : https://yunohost.org/app_phpipam From cbefea94e6a17d9215387e3160db17454961f6e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 20 Nov 2021 22:58:08 +0100 Subject: [PATCH 4/4] Create updater.yml --- .github/workflows/updater.yml | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/updater.yml 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