Merge pull request #2 from YunoHost-Apps/testing

Testing
This commit is contained in:
Florent 2023-01-04 19:25:50 +01:00 committed by GitHub
commit b74cc58cb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 265 additions and 332 deletions

View file

@ -9,9 +9,6 @@
# Since each app is different, maintainers can adapt its contents so as to perform # Since each app is different, maintainers can adapt its contents so as to perform
# automatic actions when a new upstream release is detected. # 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 LATEST RELEASE AND ITS ASSETS
#================================================= #=================================================
@ -21,11 +18,10 @@ current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') 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) # 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) 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 # 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. # 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 if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then
version=${version:1} version=${version:1}
fi fi
@ -40,47 +36,37 @@ echo "PROCEED=false" >> $GITHUB_ENV
# Proceed only if the retrieved version is greater than the current one # Proceed only if the retrieved version is greater than the current one
if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
echo "::warning ::No new version available" echo "::warning ::No new version available"
exit 0 exit 0
# Proceed only if a PR for this new version does not already exist # 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 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" echo "::warning ::A branch already exists for this update"
exit 0 exit 0
fi fi
# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.) # Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.)
echo "${#assets[@]} available asset(s)" echo "1 available asset(s)"
#================================================= #=================================================
# UPDATE SOURCE FILES # UPDATE SOURCE FILES
#================================================= #=================================================
# Here we use the $assets variable to get the resources published in the upstream release. for arch in "x64" "arm64"; do
# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like. asset_url="https://artifacts.opensearch.org/releases/bundle/opensearch/$version/opensearch-$version-linux-$arch.tar.gz"
# Let's loop over the array of assets URLs
for asset_url in ${assets[@]}; do
echo "Handling asset at $asset_url" echo "Handling asset at $asset_url"
# Assign the asset to a source file in conf/ directory # 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) # 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 # Leave $src empty to ignore the asset
case $asset_url in case $arch in
*"admin"*) "x64")
src="app" src="amd64"
;; ;;
*"update"*) "arm64")
src="app-upgrade" src="arm64"
;;
*)
src=""
;; ;;
esac esac
# If $src is not empty, let's process the asset
if [ ! -z "$src" ]; then
# Create the temporary directory # Create the temporary directory
tempdir="$(mktemp -d)" tempdir="$(mktemp -d)"
@ -92,12 +78,7 @@ checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
# Delete temporary directory # Delete temporary directory
rm -rf $tempdir rm -rf $tempdir
# Get extension extension=tar.gz
if [[ $filename == *.tar.gz ]]; then
extension=tar.gz
else
extension=${filename##*.}
fi
# Rewrite source file # Rewrite source file
cat <<EOT > conf/$src.src cat <<EOT > conf/$src.src
@ -110,10 +91,6 @@ SOURCE_FILENAME=
EOT EOT
echo "... conf/$src.src updated" echo "... conf/$src.src updated"
else
echo "... asset ignored"
fi
done done
#================================================= #=================================================

49
.github/workflows/updater.yml vendored Normal file
View 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

View file

@ -15,39 +15,23 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## Overview ## Overview
Some long and extensive description of what the app is and does, lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. OpenSearch makes it easy to ingest, search, visualize, and analyze your data.
### Features ### Features
- Ut enim ad minim veniam, quis nostrud exercitation ullamco ; OpenSearch is a scalable, flexible, and extensible open-source software suite for search, analytics, and observability applications licensed under Apache 2.0. Powered by Apache Lucene and driven by the OpenSearch Project community, OpenSearch offers a vendor-agnostic toolset you can use to build secure, high-performance, cost-efficient applications. Use OpenSearch as an end-to-end solution or connect it with your preferred open-source tools or partner projects.
- Laboris nisi ut aliquip ex ea commodo consequat ;
- Duis aute irure dolor in reprehenderit in voluptate ;
- Velit esse cillum dolore eu fugiat nulla pariatur ;
- Excepteur sint occaecat cupidatat non proident, sunt in culpa."
**Shipped version:** 1.0~ynh1 **Shipped version:** 2.4.1~ynh1
**Demo:** https://playground.opensearch.org/app/home **Demo:** https://playground.opensearch.org/app/home
## Screenshots
![Screenshot of OpenSearch](./doc/screenshots/example.jpg)
## Disclaimers / important information ## Disclaimers / important information
* Any known limitations, constrains or stuff not working, such as (but not limited to): ### Limitations
* requiring a full dedicated domain ? - Currently the security is disabled
* architectures not supported ? - Therefore, the package is configured to remain not public for now (i.e. not accessible through the web, the apps depending on it should be installed on the same server)
* not-working single-sign on or LDAP integration ? - Not scalable for now
* the app requires an important amount of RAM / disk / .. to install or to work properly
* etc...
* Other infos that people should be aware of, such as:
* any specific step to perform after installing (such as manually finishing the install, specific admin credentials, ...)
* how to configure / administrate the application if it ain't obvious
* upgrade process / specificities / things to be aware of ?
* security considerations ?
## Documentation and resources ## Documentation and resources

View file

@ -15,39 +15,23 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
## Vue d'ensemble ## Vue d'ensemble
Some long and extensive description of what the app is and does, lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. OpenSearch makes it easy to ingest, search, visualize, and analyze your data.
### Features ### Features
- Ut enim ad minim veniam, quis nostrud exercitation ullamco ; OpenSearch is a scalable, flexible, and extensible open-source software suite for search, analytics, and observability applications licensed under Apache 2.0. Powered by Apache Lucene and driven by the OpenSearch Project community, OpenSearch offers a vendor-agnostic toolset you can use to build secure, high-performance, cost-efficient applications. Use OpenSearch as an end-to-end solution or connect it with your preferred open-source tools or partner projects.
- Laboris nisi ut aliquip ex ea commodo consequat ;
- Duis aute irure dolor in reprehenderit in voluptate ;
- Velit esse cillum dolore eu fugiat nulla pariatur ;
- Excepteur sint occaecat cupidatat non proident, sunt in culpa."
**Version incluse :** 1.0~ynh1 **Version incluse :** 2.4.1~ynh1
**Démo :** https://playground.opensearch.org/app/home **Démo :** https://playground.opensearch.org/app/home
## Captures d'écran
![Capture d'écran de OpenSearch](./doc/screenshots/example.jpg)
## Avertissements / informations importantes ## Avertissements / informations importantes
* Any known limitations, constrains or stuff not working, such as (but not limited to): ### Limitations
* requiring a full dedicated domain ? - Currently the security is disabled
* architectures not supported ? - Therefore, the package is configured to remain not public for now (i.e. not accessible through the web, the apps depending on it should be installed on the same server)
* not-working single-sign on or LDAP integration ? - Not scalable for now
* the app requires an important amount of RAM / disk / .. to install or to work properly
* etc...
* Other infos that people should be aware of, such as:
* any specific step to perform after installing (such as manually finishing the install, specific admin credentials, ...)
* how to configure / administrate the application if it ain't obvious
* upgrade process / specificities / things to be aware of ?
* security considerations ?
## Documentations et ressources ## Documentations et ressources

View file

@ -5,30 +5,18 @@
;; Test complet ;; Test complet
; Manifest ; Manifest
domain="domain.tld"
path="/path"
is_public=1
language="fr"
admin="john"
password="1Strong-Password"
port="666"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=0
setup_root=1 setup_root=0
setup_nourl=0 setup_nourl=1
setup_private=1 setup_private=0
setup_public=1 setup_public=0
upgrade=1 upgrade=1
upgrade=1 from_commit=CommitHash
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
port_already_use=0 port_already_use=1
change_url=1 change_url=0
;;; Options ;;; Options
Email= Email=
Notification=none Notification=none
;;; Upgrade options
; commit=CommitHash
name=Name and date of the commit.
manifest_arg=domain=DOMAIN&path=PATH&is_public=1&language=fr&admin=USER&password=pass&port=666&

View file

@ -0,0 +1,3 @@
# Increase the number of allowed map count
# See: https://opensearch.org/docs/latest/install-and-configure/install-opensearch/index/#important-settings
vm.max_map_count=262144

6
conf/amd64.src Normal file
View file

@ -0,0 +1,6 @@
SOURCE_URL=https://artifacts.opensearch.org/releases/bundle/opensearch/2.4.1/opensearch-2.4.1-linux-x64.tar.gz
SOURCE_SUM=f2b71818ad84cdab1b736211efbdd79d33835a92d46f66a237fa1182d012410d
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=

View file

@ -1,6 +0,0 @@
SOURCE_URL=https://artifacts.opensearch.org/releases/bundle/opensearch/2.4.0/opensearch-2.4.0-linux-x64.tar.gz
SOURCE_SUM=82bee5f68ea3d74a7d835d35f1479509b8497d01c1ae758a4737f5ea799e38e8
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_EXTRACT=true

6
conf/arm64.src Normal file
View file

@ -0,0 +1,6 @@
SOURCE_URL=https://artifacts.opensearch.org/releases/bundle/opensearch/2.4.1/opensearch-2.4.1-linux-arm64.tar.gz
SOURCE_SUM=fa3151423ce747ed8e1d7afa7d84418e4f216f753e8e300d49a373f0cdc78ec3
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=

23
conf/jvm.options Normal file
View file

@ -0,0 +1,23 @@
## JVM configuration
################################################################
## IMPORTANT: JVM heap size
################################################################
##
## You should always set the min and max JVM heap
## size to the same value. For example, to set
## the heap to 4 GB, set:
##
## -Xms4g
## -Xmx4g
##
## See https://opensearch.org/docs/opensearch/install/important-settings/
## for more information
##
################################################################
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
-Xms__XMS__
-Xmx__XMX__

37
config_panel.toml Normal file
View file

@ -0,0 +1,37 @@
version = "1.0"
[main]
name.en = "OpenSearch configuration"
name.fr = "Configuration d'OpenSearch"
services = ["__APP__"]
[main.jvm]
name.en = "JVM (Java Virtual Machine) configuration"
name.fr = "Configuration de la JVM (machine virtuelle Java)"
optional = false
[main.jvm.xms]
ask.en = "Initial heap space"
ask.fr = "Espace initial réservé pour le tas (ou « Heap »)"
help = """\
Indicate a size followed by a unit (either m for megabytes or g for gigabytes) with no space. Examples: \
"512m"\
"2g"\
"""
type = "string"
pattern.regexp = '^(\d+)[mMgG]$'
pattern.error = "Please respect the format describe in help text"
[main.jvm.xmx]
ask.en = "Maximum heap space"
ask.fr = "Espace maximal pour le tas (ou « Heap »)"
help = """\
Indicate a size followed by a unit (either m for megabytes or g for gigabytes) with no space. Examples: \
"512m"\
"2g"\
"""
type = "string"
pattern.regexp = '^(\d+)[mMgG]$'
pattern.error = "Please respect the format describe in help text"

View file

@ -1,9 +1,6 @@
Some long and extensive description of what the app is and does, lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. OpenSearch makes it easy to ingest, search, visualize, and analyze your data.
### Features ### Features
- Ut enim ad minim veniam, quis nostrud exercitation ullamco ; OpenSearch is a scalable, flexible, and extensible open-source software suite for search, analytics, and observability applications licensed under Apache 2.0. Powered by Apache Lucene and driven by the OpenSearch Project community, OpenSearch offers a vendor-agnostic toolset you can use to build secure, high-performance, cost-efficient applications. Use OpenSearch as an end-to-end solution or connect it with your preferred open-source tools or partner projects.
- Laboris nisi ut aliquip ex ea commodo consequat ;
- Duis aute irure dolor in reprehenderit in voluptate ;
- Velit esse cillum dolore eu fugiat nulla pariatur ;
- Excepteur sint occaecat cupidatat non proident, sunt in culpa."

View file

@ -1,12 +1,4 @@
* Any known limitations, constrains or stuff not working, such as (but not limited to): ### Limitations
* requiring a full dedicated domain ? - Currently the security is disabled
* architectures not supported ? - Therefore, the package is configured to remain not public for now (i.e. not accessible through the web, the apps depending on it should be installed on the same server)
* not-working single-sign on or LDAP integration ? - Not scalable for now
* the app requires an important amount of RAM / disk / .. to install or to work properly
* etc...
* Other infos that people should be aware of, such as:
* any specific step to perform after installing (such as manually finishing the install, specific admin credentials, ...)
* how to configure / administrate the application if it ain't obvious
* upgrade process / specificities / things to be aware of ?
* security considerations ?

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

View file

@ -6,7 +6,7 @@
"en": "Open source distributed and RESTful search engine.", "en": "Open source distributed and RESTful search engine.",
"fr": "Moteur de recherche RESTful et open-source." "fr": "Moteur de recherche RESTful et open-source."
}, },
"version": "1.0~ynh1", "version": "2.4.1~ynh1",
"url": "https://github.com/opensearch-project/OpenSearch", "url": "https://github.com/opensearch-project/OpenSearch",
"upstream": { "upstream": {
"license": "Apache-2.0", "license": "Apache-2.0",

View file

@ -10,7 +10,14 @@ pkg_dependencies=""
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================
IS_PACKAGE_CHECK () {
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]
then
return 0
else
return 1
fi
}
#================================================= #=================================================
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================

View file

@ -56,6 +56,12 @@ ynh_backup --src_path="$datadir" --is_big
ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/sysctl.d/90-max_map_count-opensearch.conf"
#================================================= #=================================================
# BACKUP SYSTEMD # BACKUP SYSTEMD
#================================================= #=================================================

View file

@ -1,134 +0,0 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Add settings here as needed by your application
#db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#db_user=$db_name
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# 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"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
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"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
# Change the domain for NGINX
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
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# ...
#=================================================
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
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"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -1,10 +1,10 @@
#!/bin/bash #!/bin/bash
# In simple cases, you don't need a config script. # In simple cases, you don't need a config script.
# With a simple config_panel.toml, you can write in the app settings, in the # With a simple config_panel.toml, you can write in the app settings, in the
# upstream config file or replace complete files (logo ...) and restart services. # upstream config file or replace complete files (logo ...) and restart services.
# The config scripts allows you to go further, to handle specific cases # The config scripts allows you to go further, to handle specific cases
# (validation of several interdependent fields, specific getter/setter for a value, # (validation of several interdependent fields, specific getter/setter for a value,
# display dynamic informations or choices, pre-loading of config type .cube... ). # display dynamic informations or choices, pre-loading of config type .cube... ).
@ -28,72 +28,36 @@ final_path=$(ynh_app_setting_get $app final_path)
# SPECIFIC GETTERS FOR TOML SHORT KEY # SPECIFIC GETTERS FOR TOML SHORT KEY
#================================================= #=================================================
get__amount() { get__xms() {
# Here we can imagine to have an API call to stripe to know the amount of donation during a month ynh_app_setting_get --app=$app --key=xms
local amount = 200
# It's possible to change some properties of the question by overriding it:
if [ $amount -gt 100 ]
then
cat << EOF
style: success
value: $amount
ask:
en: A lot of donation this month: **$amount €**
EOF
else
cat << EOF
style: danger
value: $amount
ask:
en: Not so much donation this month: $amount €
EOF
fi
} }
get__prices() { get__xmx() {
local prices = "$(grep "DONATION\['" "$final_path/settings.py" | sed -r "s@^DONATION\['([^']*)'\]\['([^']*)'\] = '([^']*)'@\1/\2/\3@g" | sed -z 's/\n/,/g;s/,$/\n/')" ynh_app_setting_get --app=$app --key=xmx
if [ "$prices" == "," ];
then
# Return YNH_NULL if you prefer to not return a value at all.
echo YNH_NULL
else
echo $prices
fi
} }
#================================================= #=================================================
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS # SPECIFIC VALIDATORS FOR TOML SHORT KEYS
#================================================= #=================================================
validate__publishable_key() {
# We can imagine here we test if the key is really a publisheable key
(is_secret_key $publishable_key) &&
echo 'This key seems to be a secret key'
}
#================================================= #=================================================
# SPECIFIC SETTERS FOR TOML SHORT KEYS # SPECIFIC SETTERS FOR TOML SHORT KEYS
#================================================= #=================================================
set__prices() {
#--------------------------------------------- regenerate_jvm_options() {
# IMPORTANT: setter are trigger only if a change is detected ynh_add_config --template="jvm.options" --destination="$final_path/config/jvm.options.d/yunohost.options"
#--------------------------------------------- chown $app:$app "$final_path/config/jvm.options.d/yunohost.options"
for price in $(echo $prices | sed "s/,/ /"); do chmod 400 "$final_path/config/jvm.options.d/yunohost.options"
frequency=$(echo $price | cut -d/ -f1) }
currency=$(echo $price | cut -d/ -f2)
price_id=$(echo $price | cut -d/ -f3)
sed "d/DONATION\['$frequency'\]\['$currency'\]" "$final_path/settings.py"
echo "DONATION['$frequency']['$currency'] = '$price_id'" >> "$final_path/settings.py" set__xms() {
done ynh_app_setting_set --app=$app --key=xms --value=$xms
regenerate_jvm_options
#--------------------------------------------- }
# IMPORTANT: to be able to upgrade properly, you have to saved the value in settings too
#--------------------------------------------- set__xmx() {
ynh_app_setting_set $app prices $prices ynh_app_setting_set --app=$app --key=xmx --value=$xmx
regenerate_jvm_options
} }
#================================================= #=================================================

View file

@ -41,6 +41,16 @@ ynh_script_progression --message="Finding an available port..." --weight=1
port=$(ynh_find_port --port=9200) port=$(ynh_find_port --port=9200)
ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# DEFAULT VALUES FOR CONFIGURATION
#=================================================
xms=256m
ynh_app_setting_set --app=$app --key=xms --value=$xms
xmx=1g
ynh_app_setting_set --app=$app --key=xmx --value=$xmx
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
@ -61,13 +71,9 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=15 ynh_script_progression --message="Setting up source files..." --weight=15
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
### downloaded from an upstream source, like a git repository.
### `ynh_setup_source` use the file conf/app.src
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path" --source_id="$YNH_ARCH"
chmod 750 "$final_path" chmod 750 "$final_path"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
@ -98,14 +104,30 @@ chmod 700 "/run/$app"
chown $app:$app "/run/$app" chown $app:$app "/run/$app"
#================================================= #=================================================
# ADD A CONFIGURATION # ADD CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_script_progression --message="Adding the configuration files..." --weight=1
ynh_add_config --template="opensearch.yml" --destination="$final_path/config/opensearch.yml" ynh_add_config --template="opensearch.yml" --destination="$final_path/config/opensearch.yml"
ynh_add_config --template="jvm.options" --destination="$final_path/config/jvm.options.d/yunohost.options"
chmod 400 "$final_path/config/opensearch.yml" "$final_path/config/jvm.options.d/yunohost.options"
chown $app:$app "$final_path/config/opensearch.yml" "$final_path/config/jvm.options.d/yunohost.options"
#=================================================
# INCREASE MAX_MAP_COUNT
#=================================================
ynh_script_progression --message="Increasing maximum map count (sysctl)..."
# Increase the maximum number of files inotify can monitor.
cp -a ../conf/90-max_map_count-opensearch.conf /etc/sysctl.d/
# Then, reload the kernel configuration.
if ! IS_PACKAGE_CHECK # LXC doesn't allow sysctl to play with kernel options.
then
sysctl -p /etc/sysctl.d/90-max_map_count-opensearch.conf
fi
chmod 400 "$final_path/config/opensearch.yml"
chown $app:$app "$final_path/config/opensearch.yml"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD

View file

@ -93,6 +93,18 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..."
ynh_restore_file --origin_path="/etc/sysctl.d/90-max_map_count-opensearch.conf"
if ! IS_PACKAGE_CHECK # LXC doesn't allow sysctl to play with kernel options.
then
sysctl -p /etc/sysctl.d/90-max_map_count-opensearch.conf
fi
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================

View file

@ -19,6 +19,8 @@ app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) datadir=$(ynh_app_setting_get --app=$app --key=datadir)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
xms=$(ynh_app_setting_get --app=$app --key=xms)
xmx=$(ynh_app_setting_get --app=$app --key=xmx)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -92,7 +94,7 @@ then
ynh_script_progression --message="Upgrading source files..." --weight=20 ynh_script_progression --message="Upgrading source files..." --weight=20
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" --keep="config/opensearch.yml" ynh_setup_source --dest_dir="$final_path" --source_id="$YNH_ARCH" --keep="config/opensearch.yml config/jvm.options.d/yunohost.conf"
fi fi
chmod 750 "$final_path" chmod 750 "$final_path"
@ -112,9 +114,23 @@ ynh_install_app_dependencies $pkg_dependencies
ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_script_progression --message="Updating a configuration file..." --weight=1
ynh_add_config --template="opensearch.yml" --destination="$final_path/config/opensearch.yml" ynh_add_config --template="opensearch.yml" --destination="$final_path/config/opensearch.yml"
ynh_add_config --template="jvm.options" --destination="$final_path/config/jvm.options.d/yunohost.options"
chmod 400 "$final_path/config/opensearch.yml" chmod 400 "$final_path/config/opensearch.yml" "$final_path/config/jvm.options.d/yunohost.options"
chown $app:$app "$final_path/config/opensearch.yml" chown $app:$app "$final_path/config/opensearch.yml" "$final_path/config/jvm.options.d/yunohost.options"
#=================================================
# INCREASE MAX_MAP_COUNT
#=================================================
ynh_script_progression --message="Increasing maximum map count (sysctl)..."
# Increase the maximum number of files inotify can monitor.
cp -a ../conf/90-max_map_count-opensearch.conf /etc/sysctl.d/
# Then, reload the kernel configuration.
if ! IS_PACKAGE_CHECK # LXC doesn't allow sysctl to play with kernel options.
then
sysctl -p /etc/sysctl.d/90-max_map_count-opensearch.conf
fi
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD