1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/loki_ynh.git synced 2024-09-03 19:36:16 +02:00

Manifest v2

This commit is contained in:
Salamandar 2024-01-30 00:27:51 +01:00
parent 2692133280
commit c586e14024
21 changed files with 147 additions and 422 deletions

View file

@ -1,140 +0,0 @@
#!/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=($(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
echo "REPO=$repo" >> $GITHUB_ENV
# For the time being, let's assume the script will fail
echo "PROCEED=false" >> $GITHUB_ENV
# Proceed only if the retrieved version is greater than the current one
if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
echo "::warning ::No new version available"
exit 0
# 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
*"promtail-linux-amd64.zip")
src="promtail-amd64"
;;
*"promtail-linux-arm64.zip")
src="promtail-arm64"
;;
*"loki-linux-amd64.zip")
src="loki-amd64"
;;
*"loki-linux-arm64.zip")
src="loki-arm64"
;;
*)
src=""
;;
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=$extension
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=
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

View file

@ -1,52 +0,0 @@
# 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 <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 }}
[See upstream release page](${{ env.RELEASE }})
Provided description:
${{ env.DESCRIPTION }}
draft: false

View file

@ -1,23 +0,0 @@
# See here for more information
# https://github.com/YunoHost/package_check#syntax-check_process-file
# Move this file from check_process.default to check_process when you have filled it.
;; Test complet
; Manifest
port="3100"
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=0
setup_nourl=1
setup_private=1
setup_public=0
upgrade=1
backup_restore=1
multi_instance=1
port_already_use=1
change_url=1
;;; Options
Email=
Notification=none

View file

@ -1,6 +0,0 @@
SOURCE_URL=https://github.com/grafana/loki/releases/download/v2.8.4/loki-linux-amd64.zip
SOURCE_SUM=26a49c76219810566221ab7d5880ddb0ccba1ffeee4768c5ae919c4e36094d8a
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=

View file

@ -1,6 +0,0 @@
SOURCE_URL=https://github.com/grafana/loki/releases/download/v2.8.4/loki-linux-arm64.zip
SOURCE_SUM=ce856173e609dd39df845e05c2a17fe9061175072e76b9f8a7c6a28a33e023c3
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=

View file

@ -6,8 +6,8 @@ After=network.target
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__/
ExecStart=/bin/bash -c '__FINALPATH__/loki-linux-__ARCH__ --config.file <(/bin/bash __FINALPATH__/merge_yaml.sh /etc/__APP__/loki-default.yaml /etc/__APP__/loki.d/*.y{a,}ml)'
WorkingDirectory=__INSTALL_DIR__/
ExecStart=/bin/bash -c '__INSTALL_DIR__/loki-linux-__ARCH__ --config.file <(/bin/bash __INSTALL_DIR__/merge_yaml.sh /etc/__APP__/loki-default.yaml /etc/__APP__/loki.d/*.y{a,}ml)'
StandardOutput=append:/var/log/__APP__/loki.log
StandardError=inherit

View file

@ -1,6 +0,0 @@
SOURCE_URL=https://github.com/grafana/loki/releases/download/v2.8.4/promtail-linux-amd64.zip
SOURCE_SUM=05799bd94b5550b12ec975b6d4f82cd93cb50f79d13ab8e8fd9573aef8455372
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=

View file

@ -1,6 +0,0 @@
SOURCE_URL=https://github.com/grafana/loki/releases/download/v2.8.4/promtail-linux-arm64.zip
SOURCE_SUM=959069f64d21e42f840a2942e3b6351d0029a9c0448dcc79dd54b1a5fe5e40a2
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=

View file

@ -6,8 +6,8 @@ After=network.target
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__/
ExecStart=/bin/bash -c '__FINALPATH__/promtail-linux-__ARCH__ --config.file <(/bin/bash __FINALPATH__/merge_yaml.sh /etc/__APP__/promtail-default.yaml /etc/__APP__/promtail.d/*.y{a,}ml)'
WorkingDirectory=__INSTALL_DIR__/
ExecStart=/bin/bash -c '__INSTALL_DIR__/promtail-linux-__ARCH__ --config.file <(/bin/bash __INSTALL_DIR__/merge_yaml.sh /etc/__APP__/promtail-default.yaml /etc/__APP__/promtail.d/*.y{a,}ml)'
StandardOutput=append:/var/log/__APP__/promtail.log
StandardError=inherit

1
doc/ADMIN.md Normal file
View file

@ -0,0 +1 @@
- If you want to add pieces of configuration or overwrite the configuration, add a new file in `/etc/loki/loki.d/` for Loki or in `/etc/loki/promtail.d/` for promtail

View file

@ -2,13 +2,12 @@ Loki is a horizontally-scalable, highly-available, multi-tenant log aggregation
Compared to other log aggregation systems, Loki:
- does not do full text indexing on logs. By storing compressed, unstructured logs and only indexing metadata, Loki is simpler to operate and cheaper to run.
- indexes and groups log streams using the same labels youre already using with Prometheus, enabling you to seamlessly switch between metrics and logs using the same labels that youre already using with Prometheus.
- is an especially good fit for storing Kubernetes Pod logs. Metadata such as Pod labels is automatically scraped and indexed.
- has native support in Grafana (needs Grafana v6.0).
- does not do full text indexing on logs. By storing compressed, unstructured logs and only indexing metadata, Loki is simpler to operate and cheaper to run.
- indexes and groups log streams using the same labels youre already using with Prometheus, enabling you to seamlessly switch between metrics and logs using the same labels that youre already using with Prometheus.
- is an especially good fit for storing Kubernetes Pod logs. Metadata such as Pod labels is automatically scraped and indexed.
- has native support in Grafana (needs Grafana v6.0).
A Loki-based logging stack consists of 3 components:
- Promtail (included in this package) is the agent, responsible for gathering logs and sending them to Loki.
- Loki is the main server, responsible for storing logs and processing queries.
- [Grafana](https://github.com/Yunohost-Apps/grafana_ynh) for querying and displaying the logs.
- Promtail (included in this package) is the agent, responsible for gathering logs and sending them to Loki.
- Loki is the main server, responsible for storing logs and processing queries.
- [Grafana](https://github.com/Yunohost-Apps/grafana_ynh) for querying and displaying the logs.

View file

@ -1,2 +0,0 @@
- Loki is not exposed to the web;
- If you want to add pieces of configuration or overwrite the configuration, add a new file in `/etc/loki/loki.d/` for Loki or in `/etc/loki/promtail.d/` for promtail

View file

@ -1,30 +0,0 @@
{
"name": "Loki + Promtail",
"id": "loki",
"packaging_format": 1,
"description": {
"en": "Grafana Loki is a set of components that can be composed into a fully featured logging stack.",
"fr": "Grafana Loki est un ensemble de composants qui peuvent être composés pour former une pile de journalisation complète."
},
"version": "2.8.4~ynh1",
"url": "https://grafana.com/docs/loki/latest/",
"upstream": {
"license": "AGPL-3.0",
"website": "https://grafana.com/docs/loki/latest/",
"admindoc": "https://grafana.com/docs/loki/latest/",
"code": "https://github.com/grafana/loki"
},
"license": "AGPL-3.0",
"maintainer": {
"name": "fflorent",
"email": "florent.git@zeteo.me"
},
"requirements": {
"yunohost": ">= 11.0.0"
},
"multi_instance": true,
"services": [],
"arguments": {
"install": []
}
}

61
manifest.toml Normal file
View file

@ -0,0 +1,61 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "loki"
name = "Loki + Promtail"
description.en = "Grafana Loki is a set of components that can be composed into a fully featured logging stack."
description.fr = "Grafana Loki est un ensemble de composants qui peuvent être composés pour former une pile de journalisation complète."
version = "2.8.4~ynh1"
maintainers = ["fflorent"]
[upstream]
license = "AGPL-3.0"
website = "https://grafana.com/docs/loki/latest/"
admindoc = "https://grafana.com/docs/loki/latest/"
code = "https://github.com/grafana/loki"
cpe = "cpe:2.3:a:grafana:loki"
[integration]
yunohost = ">= 11.0.0"
architectures = ["amd64", "arm64"]
multi_instance = true
ldap = "not_relevant"
sso = "not_relevant"
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
[install]
[resources]
[resources.sources]
[resources.sources.loki]
amd64.url = "https://github.com/grafana/loki/releases/download/v2.8.4/loki-linux-amd64.zip"
amd64.sha256 = "26a49c76219810566221ab7d5880ddb0ccba1ffeee4768c5ae919c4e36094d8a"
arm64.url = "https://github.com/grafana/loki/releases/download/v2.8.4/loki-linux-arm64.zip"
arm64.sha256 = "ce856173e609dd39df845e05c2a17fe9061175072e76b9f8a7c6a28a33e023c3"
in_subdir = false
[resources.sources.promtail]
amd64.url = "https://github.com/grafana/loki/releases/download/v2.8.4/promtail-linux-amd64.zip"
amd64.sha256 = "05799bd94b5550b12ec975b6d4f82cd93cb50f79d13ab8e8fd9573aef8455372"
arm64.url = "https://github.com/grafana/loki/releases/download/v2.8.4/promtail-linux-arm64.zip"
arm64.sha256 = "959069f64d21e42f840a2942e3b6351d0029a9c0448dcc79dd54b1a5fe5e40a2"
in_subdir = false
[resources.system_user]
[resources.install_dir]
[resources.permissions]
[resources.ports]
http.default = 3100
grpc.default = 9096
promtail.default = 9080

View file

@ -6,9 +6,6 @@
# PHP APP SPECIFIC
#=================================================
# dependencies used by the app (must be on a single line)
pkg_dependencies=""
#=================================================
# PERSONAL HELPERS
#=================================================

View file

@ -14,21 +14,21 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
#REMOVEME? 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
#REMOVEME? ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
#REMOVEME? ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
@ -39,7 +39,7 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
ynh_backup --src_path="$install_dir"
#=================================================
# SPECIFIC BACKUP

View file

@ -9,79 +9,25 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
app=$YNH_APP_INSTANCE_NAME
arch=$YNH_ARCH
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding available ports..." --weight=1
http_port=$(ynh_find_port --port=3100)
ynh_app_setting_set --app=$app --key=http_port --value=$http_port
grpc_port=$(ynh_find_port --port=9096)
ynh_app_setting_set --app=$app --key=grpc_port --value=$grpc_port
promtail_port=$(ynh_find_port --port=9080)
ynh_app_setting_set --app=$app --key=promtail_port --value=$promtail_port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
ynh_setup_source --dest_dir="$final_path" --source_id="loki-$YNH_ARCH"
ynh_setup_source --dest_dir="$final_path" --source_id="promtail-$YNH_ARCH"
ynh_setup_source --dest_dir="$install_dir" --source_id="loki"
ynh_setup_source --dest_dir="$install_dir" --source_id="promtail"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
mkdir -p "/etc/$app/loki.d"
chmod 700 "/etc/$app/loki.d"
chown $app:www-data "/etc/$app/loki.d"
chown "$app:www-data" "/etc/$app/loki.d"
mkdir -p "/etc/$app/promtail.d"
chmod 700 "/etc/$app/promtail.d"
chown $app:www-data "/etc/$app/promtail.d"
chown "$app:www-data" "/etc/$app/promtail.d"
#=================================================
# ADD A CONFIGURATION
@ -94,7 +40,7 @@ ynh_add_config --template="loki-default.yaml" --destination="/etc/$app/loki-defa
# You may need to use chmod 600 instead of 400,
# for example if the app is expected to be able to modify its own config
chmod 400 "/etc/$app/loki-default.yaml"
chown $app:www-data "/etc/$app/loki-default.yaml"
chown "$app:www-data" "/etc/$app/loki-default.yaml"
ynh_add_config --template="promtail-default.yaml" --destination="/etc/$app/promtail-default.yaml"
@ -102,42 +48,29 @@ ynh_add_config --template="promtail-default.yaml" --destination="/etc/$app/promt
# You may need to use chmod 600 instead of 400,
# for example if the app is expected to be able to modify its own config
chmod 400 "/etc/$app/promtail-default.yaml"
chown $app:www-data "/etc/$app/promtail-default.yaml"
chown "$app:www-data" "/etc/$app/promtail-default.yaml"
#=================================================
# SETUP SYSTEMD
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
ynh_add_systemd_config --template="loki.service"
ynh_add_systemd_config --template="promtail.service" --service="$app-promtail"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
yunohost service add "$app" --description="Loki daemon" --log="/var/log/$app/loki.log"
yunohost service add "$app-promtail" --description="Promtail daemon" --log="/var/log/$app/promtail.log"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Loki daemon" --log="/var/log/$app/loki.log"
yunohost service add $app-promtail --description="Promtail daemon" --log="/var/log/$app/promtail.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
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/loki.log"
ynh_systemd_action --service_name=$app-promtail --action="start" --log_path="/var/log/$app/promtail.log"
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/loki.log"
ynh_systemd_action --service_name="$app-promtail" --action="start" --log_path="/var/log/$app/promtail.log"
#=================================================
# END OF SCRIPT

View file

@ -12,14 +12,14 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
http_port=$(ynh_app_setting_get --app=$app --key=http_port)
grpc_port=$(ynh_app_setting_get --app=$app --key=grpc_port)
promtail_port=$(ynh_app_setting_get --app=$app --key=promtail_port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#REMOVEME? http_port=$(ynh_app_setting_get --app=$app --key=http_port)
#REMOVEME? grpc_port=$(ynh_app_setting_get --app=$app --key=grpc_port)
#REMOVEME? promtail_port=$(ynh_app_setting_get --app=$app --key=promtail_port)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#=================================================
# STANDARD REMOVE
@ -55,10 +55,10 @@ ynh_remove_logrotate
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=1
#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#REMOVEME? ynh_secure_remove --file="$install_dir"
#=================================================
# REMOVE CONFIGURATION
@ -74,10 +74,10 @@ fi
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#REMOVEME? ynh_remove_app_dependencies
#=================================================
# CLOSE PORTS
@ -98,10 +98,10 @@ done
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=$app
#REMOVEME? ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT

View file

@ -14,61 +14,61 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
#REMOVEME? 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
#REMOVEME? ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
arch=$YNH_ARCH
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#REMOVEME? test ! -d $install_dir \
|| ynh_die --message="There is already a directory: $install_dir "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
#REMOVEME? 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"
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path"
ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE CONFIGURATION

View file

@ -12,15 +12,15 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
arch=$YNH_ARCH
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
http_port=$(ynh_app_setting_get --app=$app --key=http_port)
grpc_port=$(ynh_app_setting_get --app=$app --key=grpc_port)
promtail_port=$(ynh_app_setting_get --app=$app --key=promtail_port)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? http_port=$(ynh_app_setting_get --app=$app --key=http_port)
#REMOVEME? grpc_port=$(ynh_app_setting_get --app=$app --key=grpc_port)
#REMOVEME? promtail_port=$(ynh_app_setting_get --app=$app --key=promtail_port)
#=================================================
# CHECK VERSION
@ -31,16 +31,16 @@ upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
#REMOVEME? ynh_backup_before_upgrade
#REMOVEME? ynh_clean_setup () {
# Restore it if the upgrade fails
ynh_restore_upgradebackup
#REMOVEME? ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
@ -54,10 +54,10 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -68,13 +68,13 @@ then
ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" --source_id="loki-$YNH_ARCH"
ynh_setup_source --dest_dir="$final_path" --source_id="promtail-$YNH_ARCH"
ynh_setup_source --dest_dir="$install_dir" --source_id="loki-$YNH_ARCH"
ynh_setup_source --dest_dir="$install_dir" --source_id="promtail-$YNH_ARCH"
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
mkdir -p "/etc/$app/loki.d"
chmod 700 "/etc/$app/loki.d"
@ -88,9 +88,9 @@ chown $app:www-data "/etc/$app/promtail.d"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
#=================================================
# SPECIFIC UPGRADE

5
tests.toml Normal file
View file

@ -0,0 +1,5 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
test_format = 1.0
[default]