mirror of
https://github.com/YunoHost-Apps/grocy_ynh.git
synced 2024-09-03 19:25:54 +02:00
parent
72bab0738b
commit
1ce6d72095
13 changed files with 331 additions and 18 deletions
130
.github/workflows/updater.sh
vendored
Executable file
130
.github/workflows/updater.sh
vendored
Executable file
|
@ -0,0 +1,130 @@
|
|||
#!/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
|
||||
*"grocy_"*".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 <<EOT > conf/$src.src
|
||||
SOURCE_URL=$asset_url
|
||||
SOURCE_SUM=$checksum
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=zip
|
||||
SOURCE_IN_SUBDIR=false
|
||||
SOURCE_EXTRACT=true
|
||||
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
|
49
.github/workflows/updater.yml
vendored
Normal file
49
.github/workflows/updater.yml
vendored
Normal file
|
@ -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 <yunohost-bot@users.noreply.github.com>'
|
||||
author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
|
||||
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
|
|
@ -15,9 +15,9 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
|
|||
|
||||
## Overview
|
||||
|
||||
Web-based groceries & household management solution for your home
|
||||
grocy is a web-based self-hosted groceries & household management solution for your home.
|
||||
|
||||
**Shipped version:** 3.1.3~ynh2
|
||||
**Shipped version:** 3.1.3~ynh3
|
||||
|
||||
**Demo:** https://en.demo.grocy.info/stockoverview
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
|
|||
|
||||
## Vue d'ensemble
|
||||
|
||||
Solution Web de gestion d'épicerie et de gestion de la maison
|
||||
grocy is a web-based self-hosted groceries & household management solution for your home.
|
||||
|
||||
**Version incluse :** 3.1.3~ynh2
|
||||
**Version incluse :** 3.1.3~ynh3
|
||||
|
||||
**Démo :** https://en.demo.grocy.info/stockoverview
|
||||
|
||||
|
|
|
@ -3,11 +3,6 @@ location / {
|
|||
# Path to source
|
||||
alias __FINALPATH__/public/ ;
|
||||
|
||||
# Force usage of https
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
||||
index index.php;
|
||||
|
||||
client_max_body_size 50M;
|
||||
|
|
25
config_panel.toml
Normal file
25
config_panel.toml
Normal file
|
@ -0,0 +1,25 @@
|
|||
version = "1.0"
|
||||
|
||||
[main]
|
||||
name = "Grocy configuration"
|
||||
|
||||
[main.php_fpm_config]
|
||||
name = "PHP-FPM configuration"
|
||||
|
||||
[main.php_fpm_config.fpm_footprint]
|
||||
ask = "Memory footprint of the service?"
|
||||
choices = ["low", "medium", "high", "specific"]
|
||||
default = "low"
|
||||
help = "low <= 20Mb per pool. medium between 20Mb and 40Mb per pool. high > 40Mb per pool.<br>Use specific to set a value with the following option."
|
||||
|
||||
[main.php_fpm_config.free_footprint]
|
||||
ask = "Memory footprint of the service?"
|
||||
type = "number"
|
||||
default = "0"
|
||||
help = "Free field to specify exactly the footprint in Mb if you don't want to use one of the three previous values."
|
||||
|
||||
[main.php_fpm_config.fpm_usage]
|
||||
ask = "Expected usage of the service?"
|
||||
choices = ["low", "medium", "high"]
|
||||
default = "low"
|
||||
help = "low: Personal usage, behind the SSO. No RAM footprint when not used, but the impact on the processor can be high if many users are using the service.<br>medium: Low usage, few people or/and publicly accessible. Low RAM footprint, medium processor footprint when used.<br>high: High usage, frequently visited website. High RAM footprint, but lower on processor usage and quickly responding."
|
|
@ -0,0 +1 @@
|
|||
grocy is a web-based self-hosted groceries & household management solution for your home.
|
|
@ -6,7 +6,7 @@
|
|||
"en": "Web-based groceries & household management solution for your home",
|
||||
"fr": "Solution Web de gestion d'épicerie et de gestion de la maison"
|
||||
},
|
||||
"version": "3.1.3~ynh2",
|
||||
"version": "3.1.3~ynh3",
|
||||
"url": "https://grocy.info",
|
||||
"upstream": {
|
||||
"license": "MIT",
|
||||
|
|
95
scripts/config
Normal file
95
scripts/config
Normal file
|
@ -0,0 +1,95 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
current_fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC GETTERS FOR TOML SHORT KEY
|
||||
#=================================================
|
||||
|
||||
get__fpm_footprint() {
|
||||
# Free footprint value for php-fpm
|
||||
# Check if current_fpm_footprint is an integer
|
||||
if [ "$current_fpm_footprint" -eq "$current_fpm_footprint" ] 2> /dev/null
|
||||
then
|
||||
echo "specific"
|
||||
else
|
||||
echo "$current_fpm_footprint"
|
||||
fi
|
||||
}
|
||||
|
||||
get__free_footprint() {
|
||||
# Free footprint value for php-fpm
|
||||
# Check if current_fpm_footprint is an integer
|
||||
if [ "$current_fpm_footprint" -eq "$current_fpm_footprint" ] 2> /dev/null
|
||||
then
|
||||
# If current_fpm_footprint is an integer, that's a numeric value for the footprint
|
||||
echo "$current_fpm_footprint"
|
||||
else
|
||||
echo "0"
|
||||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETTERS FOR TOML SHORT KEYS
|
||||
#=================================================
|
||||
|
||||
set__fpm_footprint() {
|
||||
if [ "$fpm_footprint" != "specific" ]
|
||||
then
|
||||
ynh_app_setting_set --app=$app --key=fpm_footprint --value="$fpm_footprint"
|
||||
fi
|
||||
}
|
||||
|
||||
set__free_footprint() {
|
||||
if [ "$fpm_footprint" = "specific" ]
|
||||
then
|
||||
ynh_app_setting_set --app=$app --key=fpm_footprint --value="$free_footprint"
|
||||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
||||
ynh_app_config_validate() {
|
||||
_ynh_app_config_validate
|
||||
|
||||
if [ "${changed[fpm_usage]}" == "true" ] || [ "${changed[fpm_footprint]}" == "true" ] || [ "${changed[free_footprint]}" == "true" ]; then
|
||||
# If fpm_footprint is set to 'specific', use $free_footprint value.
|
||||
if [ "$fpm_footprint" = "specific" ]
|
||||
then
|
||||
fpm_footprint=$free_footprint
|
||||
fi
|
||||
|
||||
if [ "$fpm_footprint" == "0" ]
|
||||
then
|
||||
ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below."
|
||||
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
ynh_app_config_apply() {
|
||||
_ynh_app_config_apply
|
||||
|
||||
ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
|
||||
}
|
||||
|
||||
ynh_app_config_run $1
|
|
@ -90,7 +90,7 @@ ynh_add_nginx_config
|
|||
ynh_script_progression --message="Configuring PHP-FPM..." --weight=3
|
||||
|
||||
# Create a dedicated PHP-FPM config
|
||||
ynh_add_fpm_config
|
||||
ynh_add_fpm_config --usage=low --footprint=low
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -25,7 +25,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
ynh_script_progression --message="Removing $app main directory..." --weight=4
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove "$final_path"
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
|
|
|
@ -28,13 +28,15 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
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)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||
|
||||
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
|
||||
|
@ -77,8 +79,9 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
ynh_script_progression --message="Restoring PHP-FPM configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
# Recreate a dedicated PHP-FPM config
|
||||
#ynh_add_fpm_config
|
||||
|
||||
# Recreate a dedicated php-fpm config
|
||||
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
|
|
@ -20,7 +20,10 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
language=$(ynh_app_setting_get --app=$app --key=language)
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
phpversion=$YNH_PHP_VERSION
|
||||
|
||||
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
|
@ -53,6 +56,18 @@ if [ -z "$final_path" ]; then
|
|||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
fi
|
||||
|
||||
# If fpm_footprint doesn't exist, create it
|
||||
if [ -z "$fpm_footprint" ]; then
|
||||
fpm_footprint=low
|
||||
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
|
||||
fi
|
||||
|
||||
# If fpm_usage doesn't exist, create it
|
||||
if [ -z "$fpm_usage" ]; then
|
||||
fpm_usage=low
|
||||
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
|
||||
fi
|
||||
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
@ -110,7 +125,7 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config
|
||||
ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
|
|
Loading…
Reference in a new issue