1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/grafana_ynh.git synced 2024-09-03 20:36:29 +02:00
This commit is contained in:
ericgaspar 2021-08-03 08:02:26 +02:00
parent 30b6005e1e
commit 867c276323
8 changed files with 27 additions and 60 deletions

View file

@ -1,11 +1,11 @@
;; Complete test
auto_remove=1
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
admin="john" (USER)
is_public=1 (PUBLIC|public=1|private=0)
port="3000" (PORT)
domain="domain.tld"
path="/path"
admin="john"
is_public=1
port="3000"
; Checks
pkg_linter=1
setup_sub_dir=1

View file

@ -3,7 +3,7 @@
"id": "grafana",
"packaging_format": 1,
"description": {
"en": "Beautiful metric & analytic dashboards for monitoring",
"en": "Metric & analytic dashboards for monitoring",
"fr": "Tableaux de bords de supervision"
},
"version": "7.5.5~ynh1",
@ -15,50 +15,33 @@
"url": ""
},
"requirements": {
"yunohost": ">= 3.8.1"
"yunohost": ">= 4.2.0"
},
"multi_instance": false,
"services": [
"nginx",
"php7.0-fpm"
"nginx"
],
"arguments": {
"install" : [
{
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain for Grafana",
"fr": "Choisissez un nom de domaine pour Grafana"
},
"example": "domain.org"
},
{
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for Grafana",
"fr": "Choisissez un chemin pour Grafana"
},
"example": "/grafana",
"default": "/grafana"
},
{
"name": "admin",
"type": "user",
"ask": {
"en": "Choose an admin user",
"fr": "Choisissez l'administrateur"
},
"example": "homer"
},
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public application?",
"fr": "Est-ce une application publique ?"
},
"default": false
}
]

View file

@ -63,6 +63,7 @@ ynh_mysql_dump_db --database="$db_name" > db.sql
# SPECIFIC BACKUP
#=================================================
ynh_print_info --message="Backing up the InfluxDB database..."
# Backup InfluxDB data
# Source: http://stackoverflow.com/questions/39501416/how-to-restore-data-base-using-influxd
mkdir influxdb_data

View file

@ -31,7 +31,7 @@ port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --weight=4
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
@ -73,7 +73,7 @@ ynh_systemd_action --service_name=grafana-server --action="stop" --log_path="/va
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating nginx web server configuration..." --weight=1
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
@ -128,7 +128,7 @@ ynh_systemd_action --service_name=grafana-server --action="start" --log_path="/v
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -48,7 +48,6 @@ 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
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
#=================================================
# STANDARD MODIFICATIONS
@ -88,7 +87,7 @@ ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring nginx web server..." --weight=1
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
### `ynh_add_nginx_config` will use the file conf/nginx.conf
@ -227,19 +226,18 @@ ynh_systemd_action --service_name=grafana-server --action="restart" --log_path="
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring SSOwat..." --weight=1
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
ynh_permission_update --permission="main" --add="visitors"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -54,7 +54,7 @@ ynh_remove_app_dependencies
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing nginx web server configuration..." --weight=1
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated nginx config
ynh_remove_nginx_config

View file

@ -113,7 +113,7 @@ ynh_systemd_action --service_name=grafana-server --action="start" --log_path="/v
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -19,7 +19,6 @@ 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)
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
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)
@ -36,21 +35,19 @@ upgrade_type=$(ynh_check_app_version_changed)
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=1
is_public=1
elif [ "$is_public" = "No" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=0
is_public=0
fi
# 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
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
@ -70,7 +67,7 @@ ynh_abort_if_errors
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=1
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated nginx config
ynh_add_nginx_config
@ -163,18 +160,6 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name <<<
yunohost service add influxdb --description="open source time series database" --log="/var/log/grafana/grafana.log"
yunohost service add grafana-server --description="open source analytics and monitoring solution" --log="/var/log/grafana/grafana.log"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
fi
#=================================================
# START SYSTEMD SERVICE
#=================================================
@ -185,7 +170,7 @@ ynh_systemd_action --service_name=grafana-server --action="restart" --log_path="
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload