1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/monitorix_ynh.git synced 2024-09-03 19:46:06 +02:00

Add title for each part of code and use helper upstream_version

This commit is contained in:
Josué Tille 2018-01-31 16:07:43 +01:00
parent 5a4b48b995
commit 4f54fe164c
9 changed files with 119 additions and 24 deletions

View file

@ -6,7 +6,7 @@
"en": "A monitoring tools",
"fr": "Un outils de monitoring"
},
"version": "3.10.0",
"version": "3.10.0~ynh1",
"url": "http://monitorix.org",
"license": "GPL-2.0",
"maintainer": {

View file

@ -1,18 +1,16 @@
#!/bin/bash
app=$YNH_APP_INSTANCE_NAME
#=================================================
# SET ALL CONSTANTS
#=================================================
## Adapt md5sum while you update app
sha256sum="3fb8b4a4f7aeeeafccc6dc5b232f82d5761be80fe8e82008bc768f805fe5a744"
ynh_app_version() {
manifest_path="../manifest.json"
if [ ! -e "$manifest_path" ]; then
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
fi
echo $(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file.
}
APP_VERSION=$(ynh_app_version)
app=$YNH_APP_INSTANCE_NAME
APP_VERSION=$(ynh_app_upstream_version)
#=================================================
# DEFINE ALL COMMON FONCTIONS
#=================================================
install_dependances() {
ynh_install_app_dependencies rrdtool perl libwww-perl libmailtools-perl libmime-lite-perl librrds-perl libdbi-perl libxml-simple-perl libhttp-server-simple-perl libconfig-general-perl pflogsumm

View file

@ -1,5 +1,9 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# Source YunoHost helpers
source /usr/share/yunohost/helpers
@ -7,11 +11,15 @@ source /usr/share/yunohost/helpers
ynh_abort_if_errors
# Import common cmd
source ../settings/scripts/experimental_helper.sh
source ../settings/scripts/_common.sh
# Retrieve arguments
domain=$(ynh_app_setting_get $app domain)
#=================================================
# STANDARD BACKUP STEPS
#=================================================
# Copy NGINX configuration
domain=$(ynh_app_setting_get "$app" domain)

View file

@ -1,5 +1,9 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# Source YunoHost helpers
source /usr/share/yunohost/helpers
@ -7,6 +11,7 @@ source /usr/share/yunohost/helpers
ynh_abort_if_errors
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Retrive arguments
@ -37,7 +42,10 @@ then
change_path=1
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# MODIFY URL IN NGINX CONF
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf

View file

@ -0,0 +1,42 @@
# Read the value of a key in a ynh manifest file
#
# usage: ynh_read_manifest manifest key
# | arg: manifest - Path of the manifest to read
# | arg: key - Name of the key to find
ynh_read_manifest () {
manifest="$1"
key="$2"
python3 -c "import sys, json;print(json.load(open('$manifest'))['$key'])"
}
# Read the upstream version from the manifest
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
# For example : 4.3-2~ynh3
# This include the number before ~ynh
# In the last example it return 4.3-2
#
# usage: ynh_app_upstream_version
ynh_app_upstream_version () {
manifest_path="../manifest.json"
if [ ! -e "$manifest_path" ]; then
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
fi
version_key=$(ynh_read_manifest "$manifest_path" "version")
echo "${version_key/~ynh*/}"
}
# Read package version from the manifest
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
# For example : 4.3-2~ynh3
# This include the number after ~ynh
# In the last example it return 3
#
# usage: ynh_app_package_version
ynh_app_package_version () {
manifest_path="../manifest.json"
if [ ! -e "$manifest_path" ]; then
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
fi
version_key=$(ynh_read_manifest "$manifest_path" "version")
echo "${version_key/*~ynh/}"
}

View file

@ -1,5 +1,9 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# Source YunoHost helpers
source /usr/share/yunohost/helpers
@ -7,6 +11,7 @@ source /usr/share/yunohost/helpers
ynh_abort_if_errors
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Retrieve arguments
@ -17,6 +22,17 @@ path=$(ynh_normalize_url_path $YNH_APP_ARG_PATH)
test $(ynh_webpath_available $domain $path) == 'True' || ynh_die "$domain$path is not available, please use an other domain or path."
ynh_webpath_register $app $domain $path
# Find a port for built-in monitorix HTTP server
http_port=$(ynh_find_port 8080)
nginx_status_port=$(ynh_find_port $(($http_port +1)))
ynh_app_setting_set $app http_port $http_port
ynh_app_setting_set $app nginx_status_port $nginx_status_port
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# Install package
install_dependances
@ -29,13 +45,6 @@ dbpass=$(ynh_string_random 12)
ynh_app_setting_set "$app" mysqlpwd "$dbpass"
ynh_mysql_create_user $dbuser $dbpass
# Find a port for built-in monitorix HTTP server
http_port=$(ynh_find_port 8080)
nginx_status_port=$(ynh_find_port $(($http_port +1)))
ynh_app_setting_set $app http_port $http_port
ynh_app_setting_set $app nginx_status_port $nginx_status_port
# Config nginx
config_nginx

View file

@ -1,17 +1,23 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Stop script if errors
set -u
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain)
#=================================================
# STANDARD REMOVE
#=================================================
# Stop service
systemctl stop monitorix.service

View file

@ -1,5 +1,9 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# Source YunoHost helpers
source /usr/share/yunohost/helpers
@ -7,6 +11,7 @@ source /usr/share/yunohost/helpers
ynh_abort_if_errors
# Import common cmd
source ../settings/scripts/experimental_helper.sh
source ../settings/scripts/_common.sh
# Retrieve old app settings
@ -16,6 +21,10 @@ path=$(ynh_normalize_url_path $(ynh_app_setting_get "$app" path))
# Check domain/path availability
ynh_webpath_available $domain $path || ynh_die "$domain/$path is not available, please use an other domain or path."
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# Install package
install_dependances
@ -32,6 +41,10 @@ ynh_secure_remove /etc/monitorix # we remove the directory because if it is not
ynh_secure_remove /var/lib/monitorix
ynh_restore
#=================================================
# GENERIC FINALIZATION
#=================================================
# Set access
set_permission

View file

@ -1,5 +1,9 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# Source YunoHost helpers
source /usr/share/yunohost/helpers
@ -7,6 +11,7 @@ source /usr/share/yunohost/helpers
ynh_abort_if_errors
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Retrieve app settings
@ -21,8 +26,6 @@ dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
# Stop services
systemctl stop monitorix.service
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
@ -32,6 +35,10 @@ ynh_clean_setup () {
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# Download package and install it
get_install_source
@ -41,6 +48,10 @@ config_nginx
# Update monitorix configuration
config_monitorix
#=================================================
# GENERIC FINALIZATION
#=================================================
# Set access
set_permission