1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/grafana_ynh.git synced 2024-09-03 20:36:29 +02:00

Merge branch 'testing' into pr/96

This commit is contained in:
Éric Gaspar 2023-12-28 21:16:02 +01:00
commit 2c55840f89
23 changed files with 1711 additions and 721 deletions

View file

@ -1,72 +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)
# 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
#=================================================
# UPDATE SOURCE FILES
#=================================================
sed -i "s/GRAFANA_VERSION=.*/GRAFANA_VERSION=\"$version\"/" scripts/_common.sh
echo "... scripts/_common.sh updated"
#=================================================
# 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,50 +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 }}
draft: false

View file

@ -1,45 +0,0 @@
Changelog
=========
## Unreleased
- Nothing for now...
## [7.4.0~ynh1](https://github.com/YunoHost-Apps/grafana_ynh/pull/23) - 2021-02-05
#### Changed
* Upgrade to upstream version 7.4.0
## [7.3.3~ynh1](https://github.com/YunoHost-Apps/grafana_ynh/pull/22) - 2020-11-15
#### Changed
* Upgrade to upstream version 7.3.3
* Migrate NetData configuration from deprecated backend configuration to Exporting Engine configuration
## [7.0.3~ynh1](https://github.com/YunoHost-Apps/grafana_ynh/pull/21) - 2020-06-13
#### Changed
* Upgrade to upstream version 7.0.3
## [7.0.1~ynh1](https://github.com/YunoHost-Apps/grafana_ynh/pull/21) - 2020-05-31
#### Changed
* Upgrade to upstream version 7.0.1
## [7.0.0~ynh1](https://github.com/YunoHost-Apps/grafana_ynh/pull/21) - 2020-05-24
#### Changed
* Upgrade to upstream version 7.0.0
## [6.7.3~ynh1](https://github.com/YunoHost-Apps/grafana_ynh/pull/21) - 2020-05-15
#### Added
* Add changelog
* Add issue template
#### Fixed
* fix buster support
#### Changed
* Use latest package guidelines
* Update default netdata dashboard
* Use Grafana official Debian repository for x86 and ARM

View file

@ -16,32 +16,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## Overview
Metric & analytic dashboards for monitoring
**Shipped version:** 9.4.7~ynh1
**Demo:** https://play.grafana.org
## Screenshots
![Screenshot of Grafana](./doc/screenshots/Grafana8_Kubernetes.jpg)
## Disclaimers / important information
## Configuration
**Important at first login:**
* you have to go the Grafana Menu (Grafana icon), select your account menu and select *Switch to Main Org.*
* you can now access the default NetData dashboard via the Home menu
**Don't hesitate to create new dashboards**: the default dashboard contains metrics from NetData, but only generic ones that are generated on every machine. NetData dynamically detects services and applications (e.g.redis, nginx, etc.) and enriches its dashboard and generated metrics. Many NetData metrics don't appear in the provided default Grafana dashboard!
## Documentation
* Official Grafana documentation: https://grafana.com/docs/grafana/latest/
* Official InfluxdB documentation: https://docs.influxdata.com/influxdb/
* YunoHost documentation: If specific documentation is needed, feel free to contribute.
Grafana is a multi-platform open source analytics and interactive visualization web application. It provides charts, graphs, and alerts for the web when connected to supported data sources.
## YunoHost specific features
@ -51,24 +26,20 @@ Metric & analytic dashboards for monitoring
* creates a Grafana Data Source to fetch data from InfluxDB (and hence NetData!)
* creates a default dashboard to plot some data from NetData (doesn't cover every metric, can be greatly enhanced!)
#### General architecture
![image](https://cloud.githubusercontent.com/assets/2662304/20649711/29f182ba-b4ce-11e6-97c8-ab2c0ab59833.png)
**Shipped version:** 10.1.5~ynh2
#### Multi-users support
**Demo:** https://play.grafana.org
LDAP and HTTP auth are supported.
## Screenshots
## Limitations
* The default dashboard may be updated in a further release of this package, so please make sure you create your own dashboards!
* Organizations creation doesn't play well with LDAP integration; it is disabled for standard users, but can't be disabled for administrators: **please do not create organizations**!
![Screenshot of Grafana](./doc/screenshots/Grafana8_Kubernetes.jpg)
## Documentation and resources
* Official app website: <https://grafana.com/>
* Upstream app code repository: <https://github.com/grafana/grafana>
* YunoHost documentation for this app: <https://yunohost.org/app_grafana>
* YunoHost Store: <https://apps.yunohost.org/app/grafana>
* Report a bug: <https://github.com/YunoHost-Apps/grafana_ynh/issues>
## Developer info

View file

@ -16,32 +16,7 @@ Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po
## Vue densemble
Tableaux de bord de supervision
**Version incluse :** 9.4.7~ynh1
**Démo :** https://play.grafana.org
## Captures décran
![Capture décran de Grafana](./doc/screenshots/Grafana8_Kubernetes.jpg)
## Avertissements / informations importantes
## Configuration
**Important at first login:**
* you have to go the Grafana Menu (Grafana icon), select your account menu and select *Switch to Main Org.*
* you can now access the default NetData dashboard via the Home menu
**Don't hesitate to create new dashboards**: the default dashboard contains metrics from NetData, but only generic ones that are generated on every machine. NetData dynamically detects services and applications (e.g.redis, nginx, etc.) and enriches its dashboard and generated metrics. Many NetData metrics don't appear in the provided default Grafana dashboard!
## Documentation
* Official Grafana documentation: https://grafana.com/docs/grafana/latest/
* Official InfluxdB documentation: https://docs.influxdata.com/influxdb/
* YunoHost documentation: If specific documentation is needed, feel free to contribute.
Grafana is a multi-platform open source analytics and interactive visualization web application. It provides charts, graphs, and alerts for the web when connected to supported data sources.
## YunoHost specific features
@ -51,24 +26,20 @@ Tableaux de bord de supervision
* creates a Grafana Data Source to fetch data from InfluxDB (and hence NetData!)
* creates a default dashboard to plot some data from NetData (doesn't cover every metric, can be greatly enhanced!)
#### General architecture
![image](https://cloud.githubusercontent.com/assets/2662304/20649711/29f182ba-b4ce-11e6-97c8-ab2c0ab59833.png)
**Version incluse :** 10.1.5~ynh2
#### Multi-users support
**Démo :** https://play.grafana.org
LDAP and HTTP auth are supported.
## Captures décran
## Limitations
* The default dashboard may be updated in a further release of this package, so please make sure you create your own dashboards!
* Organizations creation doesn't play well with LDAP integration; it is disabled for standard users, but can't be disabled for administrators: **please do not create organizations**!
![Capture décran de Grafana](./doc/screenshots/Grafana8_Kubernetes.jpg)
## Documentations et ressources
* Site officiel de lapp : <https://grafana.com/>
* Dépôt de code officiel de lapp : <https://github.com/grafana/grafana>
* Documentation YunoHost pour cette app : <https://yunohost.org/app_grafana>
* YunoHost Store: <https://apps.yunohost.org/app/grafana>
* Signaler un bug : <https://github.com/YunoHost-Apps/grafana_ynh/issues>
## Informations pour les développeurs

View file

@ -1,30 +0,0 @@
;; Complete test
auto_remove=1
; Manifest
domain="domain.tld"
path="/path"
is_public=1
admin="john"
port="3000"
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
upgrade=1 from_commit=893b873f00c2f9793369b7cd5d034b06605aaa8a
# 8.3.3~ynh1
upgrade=1 from_commit=993c3b904f558057de4278c1833448fc124e8626
backup_restore=1
multi_instance=0
port_already_use=1
change_url=1
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=893b873f00c2f9793369b7cd5d034b06605aaa8a
name=Upgrade to upstream version 7.0.0
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&admin_password=secret&language=en&is_public=1&

1582
conf/grafana.ini Normal file

File diff suppressed because it is too large Load diff

View file

@ -78,4 +78,6 @@ group_dn = "*"
org_role = "Admin"
# The Grafana organization database id, optional, if left out the default org (id 1) will be used
org_id = 1
# Make users grafana admins
grafana_admin = true

View file

@ -1,4 +1,3 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
proxy_redirect off;

9
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1,9 @@
Grafana is a multi-platform open source analytics and interactive visualization web application. It provides charts, graphs, and alerts for the web when connected to supported data sources.
## YunoHost specific features
* installs InfluxDB as time series database
* if the NetData package is installed, configures NetData to feed InfluxDB every minute
* installs Grafana as dashboard server
* creates a Grafana Data Source to fetch data from InfluxDB (and hence NetData!)
* creates a default dashboard to plot some data from NetData (doesn't cover every metric, can be greatly enhanced!)

View file

@ -1,35 +0,0 @@
## Configuration
**Important at first login:**
* you have to go the Grafana Menu (Grafana icon), select your account menu and select *Switch to Main Org.*
* you can now access the default NetData dashboard via the Home menu
**Don't hesitate to create new dashboards**: the default dashboard contains metrics from NetData, but only generic ones that are generated on every machine. NetData dynamically detects services and applications (e.g.redis, nginx, etc.) and enriches its dashboard and generated metrics. Many NetData metrics don't appear in the provided default Grafana dashboard!
## Documentation
* Official Grafana documentation: https://grafana.com/docs/grafana/latest/
* Official InfluxdB documentation: https://docs.influxdata.com/influxdb/
* YunoHost documentation: If specific documentation is needed, feel free to contribute.
## YunoHost specific features
* installs InfluxDB as time series database
* if the NetData package is installed, configures NetData to feed InfluxDB every minute
* installs Grafana as dashboard server
* creates a Grafana Data Source to fetch data from InfluxDB (and hence NetData!)
* creates a default dashboard to plot some data from NetData (doesn't cover every metric, can be greatly enhanced!)
#### General architecture
![image](https://cloud.githubusercontent.com/assets/2662304/20649711/29f182ba-b4ce-11e6-97c8-ab2c0ab59833.png)
#### Multi-users support
LDAP and HTTP auth are supported.
## Limitations
* The default dashboard may be updated in a further release of this package, so please make sure you create your own dashboards!
* Organizations creation doesn't play well with LDAP integration; it is disabled for standard users, but can't be disabled for administrators: **please do not create organizations**!

8
doc/POST_INSTALL.md Normal file
View file

@ -0,0 +1,8 @@
## Configuration
**Important at first login:**
* you have to go the Grafana Menu (Grafana icon), select your account menu and select *Switch to Main Org.*
* you can now access the default NetData dashboard via the Home menu
**Don't hesitate to create new dashboards**: the default dashboard contains metrics from NetData, but only generic ones that are generated on every machine. NetData dynamically detects services and applications (e.g.redis, nginx, etc.) and enriches its dashboard and generated metrics. Many NetData metrics don't appear in the provided default Grafana dashboard!

4
doc/PRE_INSTALL.md Normal file
View file

@ -0,0 +1,4 @@
## Limitations
* The default dashboard may be updated in a further release of this package, so please make sure you create your own dashboards!
* Organizations creation doesn't play well with LDAP integration; it is disabled for standard users, but can't be disabled for administrators: **please do not create organizations**!

View file

@ -1,52 +0,0 @@
{
"name": "Grafana",
"id": "grafana",
"packaging_format": 1,
"description": {
"en": "Metric & analytic dashboards for monitoring",
"fr": "Tableaux de bord de supervision"
},
"version": "9.4.7~ynh1",
"url": "https://grafana.com/oss/grafana/",
"upstream": {
"license": "AGPL-3.0-only",
"website": "https://grafana.com/",
"demo": "https://play.grafana.org",
"code": "https://github.com/grafana/grafana"
},
"license": "AGPL-3.0-only",
"maintainer": {
"name": "JimboJoe",
"email": "jimmy@monin.net"
},
"requirements": {
"yunohost": ">= 4.3.0"
},
"multi_instance": false,
"services": [
"nginx"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/grafana",
"default": "/grafana"
},
{
"name": "is_public",
"type": "boolean",
"default": false
},
{
"name": "admin",
"type": "user"
}
]
}
}

65
manifest.toml Normal file
View file

@ -0,0 +1,65 @@
packaging_format = 2
id = "grafana"
name = "Grafana"
description.en = "Metric & analytic dashboards for monitoring"
description.fr = "Tableaux de bord de supervision"
version = "10.1.5~ynh2"
maintainers = ["JimboJoe"]
[upstream]
license = "AGPL-3.0-only"
website = "https://grafana.com/"
demo = "https://play.grafana.org"
code = "https://github.com/grafana/grafana"
[integration]
yunohost = ">= 11.2"
architectures = "all"
multi_instance = false
ldap = true
sso = true
disk = "50M"
ram.build = "50M"
ram.runtime = "50M"
[install]
[install.domain]
type = "domain"
[install.path]
type = "path"
default = "/grafana"
[install.init_main_permission]
type = "group"
default = "visitors"
[install.admin]
type = "user"
[resources]
[resources.system_user]
allow_email = true
[resources.install_dir]
[resources.ports]
[resources.permissions]
main.url = "/"
[resources.apt]
packages = "mariadb-server, influxdb"
extras.grafana.repo = "deb https://packages.grafana.com/oss/deb stable main"
extras.grafana.key = "https://packages.grafana.com/gpg.key"
extras.grafana.packages = "grafana"
[resources.database]
type = "mysql"

View file

@ -5,10 +5,7 @@
#=================================================
# Debian package version for Grafana
GRAFANA_VERSION="9.4.7"
# dependencies used by the app
pkg_dependencies="influxdb"
GRAFANA_VERSION="10.2.1"
#=================================================
# PERSONAL HELPERS

View file

@ -10,26 +10,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
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
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================

View file

@ -9,59 +9,6 @@
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
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=4
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# 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
#=================================================
@ -76,29 +23,7 @@ ynh_systemd_action --service_name=grafana-server --action="stop" --log_path="/va
#=================================================
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
ynh_change_url_nginx_config
#=================================================
# SPECIFIC MODIFICATIONS
@ -129,13 +54,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=2
systemctl daemon-reload
ynh_systemd_action --service_name=grafana-server --action="start" --log_path="/var/log/grafana/grafana.log" --line_match="HTTP Server Listen" --timeout=600
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -9,73 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
admin=$YNH_APP_ARG_ADMIN
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=2
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=1
# Find an available port
port=$(ynh_find_port --port=3000)
ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=44
ynh_install_app_dependencies $pkg_dependencies
ynh_install_extra_app_dependencies --repo="deb https://packages.grafana.com/oss/deb stable main" --package="grafana" --key="https://packages.grafana.com/gpg.key"
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
ynh_script_progression --message="Creating a MySQL database..." --weight=2
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -128,47 +61,15 @@ sed -i '/^\[\[opentsdb\]\]$/,/^\[/ s/^.* enabled = false/enabled = true/' /etc/i
ynh_systemd_action --service_name=influxdb --action="restart"
# Configure Grafana
cp ../conf/ldap.toml /etc/grafana
ynh_add_config --template="ldap.toml" --destination="/etc/grafana/ldap.toml"
grafana_conf="/etc/grafana/grafana.ini"
# Set final port
sed -i "/^\[server\]$/,/^\[/ s@;http_port = .*@http_port = $port@" $grafana_conf
# Set domain
sed -i "/^\[server\]$/,/^\[/ s@;domain = .*@domain = $domain@" $grafana_conf
# Set final URL
sed -i "/^\[server\]$/,/^\[/ s@;root_url = .*@root_url = https://$domain$path_url@" $grafana_conf
# Specify if using sub_path
if [ "$path_url" != "/" ]; then
sed -i "/^\[server\]$/,/^\[/ s@;serve_from_sub_path = .*@serve_from_sub_path = true@" $grafana_conf
else
sed -i "/^\[server\]$/,/^\[/ s@;serve_from_sub_path = .*@serve_from_sub_path = false@" $grafana_conf
fi
# Disable check for updates
sed -i '/^\[analytics\]$/,/^\[/ s/;check_for_updates = .*/check_for_updates = false/' $grafana_conf
# Disable analytics reporting
sed -i '/^\[analytics\]$/,/^\[/ s/;reporting_enabled = .*/reporting_enabled = false/' $grafana_conf
# Disable organization creation
sed -i '/^\[users\]$/,/^\[/ s/;allow_org_create = .*/allow_org_create = false/' $grafana_conf
# Enable HTTP and LDAP authentication
sed -i '/^\[auth.basic\]$/,/^\[/ s/;enabled = .*/enabled = false/' $grafana_conf
sed -i '/^\[auth.proxy\]$/,/^\[/ s/;enabled = .*/enabled = true/' $grafana_conf
sed -i '/^\[auth.ldap\]$/,/^\[/ {
s/;enabled = .*/enabled = true/
s/;allow_sign_up = .*/allow_sign_up = true/
}' $grafana_conf
# Set log level to debug
sed -i '/^\[log\]$/,/^\[/ s/;level = .*/level = debug/' $grafana_conf
ynh_add_config --template="grafana.ini" --destination="/etc/grafana/grafana.ini"
# Change URL and database credentials
sed -i "/^\[database\]$/,/^\[/ {
s/;type = .*/type = mysql/
s/;name = .*/name = $db_name/
s/;user = .*/user = $db_user/
s/;\?password =.*/password = $db_pwd/
}" $grafana_conf
chmod 650 "/etc/grafana/grafana.ini"
chown $app:$app "/etc/grafana/grafana.ini"
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$grafana_conf"
ynh_store_file_checksum --file="/etc/grafana/grafana.ini"
# Start Grafana and wait for it to be fully started
systemctl daemon-reload
@ -217,26 +118,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=2
systemctl daemon-reload
ynh_systemd_action --service_name=grafana-server --action="restart" --log_path="/var/log/grafana/grafana.log" --line_match="HTTP Server Listen" --timeout=600
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -9,18 +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
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
#=================================================
# STANDARD REMOVE
#=================================================
@ -35,14 +23,6 @@ then
yunohost service remove influxdb
fi
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Removing the MySQL database..." --weight=3
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
@ -51,14 +31,6 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=26
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# SPECIFIC REMOVE
#=================================================

View file

@ -10,35 +10,14 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# 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
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d "/etc/influxdb" \
|| ynh_die --message="InfluxDB / Grafana are already installed"
#ynh_script_progression --message="Validating restoration parameters..." --weight=1
#
# This old test doesn't seem to make sense in packaging v2 anymore, because at this stage the apt dependencies are already installed, so yes /etc/influxdb exists ...
# it's not clear what was really the intent
#test ! -d "/etc/influxdb" || ynh_die --message="InfluxDB/Grafana are already installed"
#=================================================
# STANDARD RESTORATION STEPS
@ -49,24 +28,11 @@ ynh_script_progression --message="Restoring the NGINX web server configuration..
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=24
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
ynh_install_extra_app_dependencies --repo="deb https://packages.grafana.com/oss/deb stable main" --package="grafana" --key="https://packages.grafana.com/gpg.key"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=2
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#=================================================
@ -81,14 +47,14 @@ ynh_restore_file --origin_path="/var/lib/grafana/plugins" --not_mandatory
# Set permission with the new grafana user (id could have been changed)
chown -R root:grafana "/etc/grafana"
if [ -d "/var/lib/grafana/plugins" ]; then
chown -R grafana:grafana "/var/lib/grafana/plugins"
chown -R $app:$app "/var/lib/grafana/plugins"
fi
#=================================================
# RESTORE THE INFLUXDB DATABASE
#=================================================
ynh_script_progression --message="Restoring the InfluxDB database..." --weight=10
# Restore InfluxDB data (only if backup not empty)
# That happens when passing automated tests (NetData not present)
ynh_systemd_action --service_name=influxdb --action="stop"

View file

@ -9,25 +9,9 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
@ -40,41 +24,6 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
mkdir -p "/var/lib/grafana/plugins"
chown -R $app:$app "/var/lib/grafana/plugins"
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# 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
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
# Migration: remove old repository if defined
if [ -f "/etc/apt/sources.list.d/grafana_stable.list" ] ; then
ynh_secure_remove --file="/etc/apt/sources.list.d/grafana_stable.list"
fi
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -83,14 +32,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=12
ynh_install_app_dependencies $pkg_dependencies
ynh_install_extra_app_dependencies --repo="deb https://packages.grafana.com/oss/deb stable main" --package="grafana" --key="https://packages.grafana.com/gpg.key"
#=================================================
# SPECIFIC UPGRADE
#=================================================
@ -146,6 +87,12 @@ EOF
ynh_systemd_action --service_name=netdata --action="restart"
fi
# Fix configuration for Grafana instances existing prior to version 10
sed -i "/^\[server\]$/,/^\[/ s@serve_from_sub_path = .*@serve_from_sub_path = false@" "/etc/grafana/grafana.ini"
# Update Grafana LDAP authentication configuration
ynh_add_config --template="ldap.toml" --destination="/etc/grafana/ldap.toml"
# Update default dashboard for NetData (source: https://grafana.com/grafana/dashboards/2701)
# Remove new lines
tr -d '\n' < ../conf/netdata_dashboard.json > dashboard.json
@ -177,13 +124,6 @@ ynh_script_progression --message="Restarting a systemd service..." --weight=2
systemctl daemon-reload
ynh_systemd_action --service_name=grafana-server --action="restart" --log_path="/var/log/grafana/grafana.log" --line_match="HTTP Server Listen" --timeout=600
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================

9
tests.toml Normal file
View file

@ -0,0 +1,9 @@
test_format = 1.0
[default]
# -------------------------------
# Commits to test upgrade from
# -------------------------------
test_upgrade_from.993c3b904f558057de4278c1833448fc124e8626.name = "Upgrade from 8.3.3"