mirror of
https://github.com/YunoHost-Apps/loki_ynh.git
synced 2024-09-03 19:36:16 +02:00
commit
d2dc2bf51f
25 changed files with 162 additions and 680 deletions
140
.github/workflows/updater.sh
vendored
140
.github/workflows/updater.sh
vendored
|
@ -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
|
52
.github/workflows/updater.yml
vendored
52
.github/workflows/updater.yml
vendored
|
@ -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
|
20
README.md
20
README.md
|
@ -20,24 +20,18 @@ 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 you’re already using with Prometheus, enabling you to seamlessly switch between metrics and logs using the same labels that you’re 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 you’re already using with Prometheus, enabling you to seamlessly switch between metrics and logs using the same labels that you’re 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.
|
||||
|
||||
|
||||
**Shipped version:** 2.8.4~ynh1
|
||||
## Disclaimers / important information
|
||||
|
||||
- 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
|
||||
|
||||
## Documentation and resources
|
||||
|
||||
* Official app website: <https://grafana.com/docs/loki/latest/>
|
||||
|
|
20
README_fr.md
20
README_fr.md
|
@ -20,24 +20,18 @@ 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 you’re already using with Prometheus, enabling you to seamlessly switch between metrics and logs using the same labels that you’re 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 you’re already using with Prometheus, enabling you to seamlessly switch between metrics and logs using the same labels that you’re 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.
|
||||
|
||||
|
||||
**Version incluse :** 2.8.4~ynh1
|
||||
## Avertissements / informations importantes
|
||||
|
||||
- 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
|
||||
|
||||
## Documentations et ressources
|
||||
|
||||
* Site officiel de l’app : <https://grafana.com/docs/loki/latest/>
|
||||
|
|
|
@ -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
|
|
@ -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=
|
|
@ -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=
|
|
@ -1,8 +1,8 @@
|
|||
auth_enabled: false
|
||||
|
||||
server:
|
||||
http_listen_port: __HTTP_PORT__
|
||||
grpc_listen_port: __GRPC_PORT__
|
||||
http_listen_port: __PORT_HTTP__
|
||||
grpc_listen_port: __PORT_GRPC__
|
||||
|
||||
common:
|
||||
path_prefix: /tmp/loki
|
||||
|
|
|
@ -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 --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
|
||||
|
||||
|
|
|
@ -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=
|
|
@ -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=
|
|
@ -1,8 +1,8 @@
|
|||
server:
|
||||
http_listen_port: __PROMTAIL_PORT__
|
||||
http_listen_port: __PORT_PROMTAIL__
|
||||
|
||||
clients:
|
||||
- url: http://localhost:__HTTP_PORT__/loki/api/v1/push
|
||||
- url: http://localhost:__PORT_HTTP__/loki/api/v1/push
|
||||
|
||||
positions:
|
||||
filename: /tmp/promtail_positions.yaml
|
||||
|
|
|
@ -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 --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
1
doc/ADMIN.md
Normal 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
|
|
@ -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 you’re already using with Prometheus, enabling you to seamlessly switch between metrics and logs using the same labels that you’re 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 you’re already using with Prometheus, enabling you to seamlessly switch between metrics and logs using the same labels that you’re 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.
|
||||
|
|
|
@ -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
|
|
@ -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
61
manifest.toml
Normal 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"
|
||||
ram.build = "50M"
|
||||
ram.runtime = "50M"
|
||||
|
||||
[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
|
|
@ -6,9 +6,6 @@
|
|||
# PHP APP SPECIFIC
|
||||
#=================================================
|
||||
|
||||
# dependencies used by the app (must be on a single line)
|
||||
pkg_dependencies=""
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -10,26 +10,6 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
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
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
|
@ -39,29 +19,23 @@ 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
|
||||
#=================================================
|
||||
# BACKUP CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP LOGROTATE
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
ynh_backup --src_path="/etc/systemd/system/$app-promtail.service"
|
||||
|
||||
#=================================================
|
||||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/$app"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
105
scripts/install
105
scripts/install
|
@ -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"
|
||||
# Rename the binaries to remove arch
|
||||
mv "$install_dir"/loki-linux-* "$install_dir"/loki
|
||||
mv "$install_dir"/promtail-linux-* "$install_dir"/promtail
|
||||
|
||||
mkdir -p "/etc/$app/loki.d"
|
||||
chmod 700 "/etc/$app/loki.d"
|
||||
chown $app:www-data "/etc/$app/loki.d"
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
|
||||
mkdir -p "/etc/$app/promtail.d"
|
||||
chmod 700 "/etc/$app/promtail.d"
|
||||
chown $app:www-data "/etc/$app/promtail.d"
|
||||
mkdir -p "/etc/$app/loki.d" "/etc/$app/promtail.d"
|
||||
chmod 700 "/etc/$app"
|
||||
chown -R "$app:www-data" "/etc/$app"
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
|
|
|
@ -10,98 +10,25 @@ source _common.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
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)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app service integration..." --weight=1
|
||||
yunohost service remove $app
|
||||
yunohost service remove $app-promtail
|
||||
if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
|
||||
yunohost service remove "$app"
|
||||
yunohost service remove "$app-promtail"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
ynh_remove_systemd_config --service="$app-promtail"
|
||||
|
||||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
#=================================================
|
||||
# REMOVE CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
# Remove the data directory if --purge option is used
|
||||
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
|
||||
then
|
||||
ynh_script_progression --message="Removing app data directory..." --weight=1
|
||||
ynh_secure_remove --file="/etc/$app"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=1
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# CLOSE PORTS
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Closing ports..." --weight=1
|
||||
for port in $http_port $grpc_port $promtail_port
|
||||
do
|
||||
if yunohost firewall list | grep -q "\- $port$"
|
||||
then
|
||||
ynh_print_info --message="Closing port $port..." --weight=1
|
||||
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||
fi
|
||||
done
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$app
|
||||
ynh_secure_remove --file="/etc/$app"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -10,70 +10,20 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
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
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
arch=$YNH_ARCH
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# 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 "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# 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"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# RESTORE CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoring the configuration files..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/$app"
|
||||
|
@ -84,33 +34,22 @@ ynh_restore_file --origin_path="/etc/$app"
|
|||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service --quiet
|
||||
systemctl enable "$app.service" --quiet
|
||||
yunohost service add "$app" --description="Loki daemon" --log="/var/log/$app/loki.log"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-promtail.service"
|
||||
systemctl enable $app-promtail.service --quiet
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
|
||||
systemctl enable "$app-promtail.service" --quiet
|
||||
yunohost service add "$app-promtail" --description="Promtail daemon" --log="/var/log/$app/promtail.log"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
|
||||
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
|
||||
|
|
117
scripts/upgrade
117
scripts/upgrade
|
@ -9,39 +9,6 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
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)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
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
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
|
@ -49,54 +16,29 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
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"
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
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"
|
||||
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
ynh_systemd_action --service_name="$app-promtail" --action="stop" --log_path="/var/log/$app/promtail.log"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
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="$install_dir" --source_id="loki" --full_replace=1
|
||||
ynh_setup_source --dest_dir="$install_dir" --source_id="promtail"
|
||||
|
||||
# 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"
|
||||
fi
|
||||
# Rename the binaries to remove arch
|
||||
mv "$install_dir"/loki-linux-* "$install_dir"/loki
|
||||
mv "$install_dir"/promtail-linux-* "$install_dir"/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"
|
||||
|
||||
mkdir -p "/etc/$app/promtail.d"
|
||||
chmod 700 "/etc/$app/promtail.d"
|
||||
chown $app:www-data "/etc/$app/promtail.d"
|
||||
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# ...
|
||||
#=================================================
|
||||
mkdir -p "/etc/$app/loki.d" "/etc/$app/promtail.d"
|
||||
chmod 700 "/etc/$app"
|
||||
chown -R "$app:www-data" "/etc/$app"
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
|
@ -109,7 +51,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"
|
||||
|
||||
|
@ -117,42 +59,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
|
||||
# REAPPLY SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
||||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||||
|
||||
# Create a dedicated systemd config
|
||||
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="Upgrading logrotate configuration..." --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 app-specific logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
|
||||
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
|
||||
|
|
5
tests.toml
Normal file
5
tests.toml
Normal file
|
@ -0,0 +1,5 @@
|
|||
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
|
||||
|
||||
test_format = 1.0
|
||||
|
||||
[default]
|
Loading…
Add table
Reference in a new issue