mirror of
https://github.com/YunoHost-Apps/monitorix_ynh.git
synced 2024-09-03 19:46:06 +02:00
commit
5184b128d0
17 changed files with 67 additions and 91 deletions
|
@ -21,7 +21,7 @@ Monitorix is a free, open source, lightweight system monitoring tool designed to
|
|||
It has been created to be used under production Linux/UNIX servers, but due to its simplicity and small size can be used on embedded devices as well.
|
||||
|
||||
|
||||
**Shipped version:** 3.15.0~ynh5
|
||||
**Shipped version:** 3.15.0~ynh6
|
||||
|
||||
**Demo:** <https://www.fibranet.cat/monitorix/>
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ Monitorix is a free, open source, lightweight system monitoring tool designed to
|
|||
It has been created to be used under production Linux/UNIX servers, but due to its simplicity and small size can be used on embedded devices as well.
|
||||
|
||||
|
||||
**Paketatutako bertsioa:** 3.15.0~ynh5
|
||||
**Paketatutako bertsioa:** 3.15.0~ynh6
|
||||
|
||||
**Demoa:** <https://www.fibranet.cat/monitorix/>
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ Monitorix is a free, open source, lightweight system monitoring tool designed to
|
|||
It has been created to be used under production Linux/UNIX servers, but due to its simplicity and small size can be used on embedded devices as well.
|
||||
|
||||
|
||||
**Version incluse :** 3.15.0~ynh5
|
||||
**Version incluse :** 3.15.0~ynh6
|
||||
|
||||
**Démo :** <https://www.fibranet.cat/monitorix/>
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ Monitorix is a free, open source, lightweight system monitoring tool designed to
|
|||
It has been created to be used under production Linux/UNIX servers, but due to its simplicity and small size can be used on embedded devices as well.
|
||||
|
||||
|
||||
**Versión proporcionada:** 3.15.0~ynh5
|
||||
**Versión proporcionada:** 3.15.0~ynh6
|
||||
|
||||
**Demo:** <https://www.fibranet.cat/monitorix/>
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ Monitorix is a free, open source, lightweight system monitoring tool designed to
|
|||
It has been created to be used under production Linux/UNIX servers, but due to its simplicity and small size can be used on embedded devices as well.
|
||||
|
||||
|
||||
**分发版本:** 3.15.0~ynh5
|
||||
**分发版本:** 3.15.0~ynh6
|
||||
|
||||
**演示:** <https://www.fibranet.cat/monitorix/>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
#
|
||||
# Example script used to execute an alert action.
|
||||
#
|
||||
|
|
|
@ -27,7 +27,7 @@ ProtectKernelModules=yes
|
|||
ProtectKernelTunables=yes
|
||||
LockPersonality=yes
|
||||
SystemCallArchitectures=native
|
||||
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @cpu-emulation @swap
|
||||
SystemCallFilter=~@clock @debug @module @obsolete @reboot @cpu-emulation @swap
|
||||
|
||||
# # Denying access to capabilities that should not be relevant for webapps
|
||||
# # Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
|
||||
|
|
|
@ -7,7 +7,7 @@ name = "Monitorix"
|
|||
description.en = "A system monitoring tool"
|
||||
description.fr = "Un outil de monitoring système"
|
||||
|
||||
version = "3.15.0~ynh5"
|
||||
version = "3.15.0~ynh6"
|
||||
|
||||
maintainers = ["Josué Tille"]
|
||||
|
||||
|
@ -20,7 +20,7 @@ code = "https://github.com/mikaku/Monitorix"
|
|||
cpe = "cpe:2.3:a:fibranet:monitorix"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.0.11"
|
||||
yunohost = ">= 11.2.11"
|
||||
architectures = "all"
|
||||
multi_instance = false
|
||||
ldap = "not_relevant"
|
||||
|
|
|
@ -79,7 +79,7 @@ load_vars() {
|
|||
readonly home_user_dirs="$(echo /home/* | home_dir_filter)"
|
||||
readonly net_gateway="$(ip --json route show default | jq -r '.[0].dev')"
|
||||
readonly net_interface_list="$(ip --json link show | jq -r '.[].ifname | select(. != "lo")' | interface_speed_map)"
|
||||
readonly net_max_speed="$(cat /sys/class/net/*/speed 2>/dev/null | sort | tail -n1)"
|
||||
readonly net_max_speed="$(cat /sys/class/net/*/speed 2>/dev/null | sort | tail -n1 | sed 's|-1|1000|g')"
|
||||
readonly ssh_port="$((grep ssh_port /etc/yunohost/settings.yml || echo 22) | cut -d: -f2 | xargs)"
|
||||
readonly port_infos="$(python3 <<EOF
|
||||
import yaml, socket
|
||||
|
@ -96,6 +96,8 @@ with open("/etc/yunohost/firewall.yml", "r") as f:
|
|||
if str(port) not in hard_coded_ports]
|
||||
with open("/etc/yunohost/services.yml", "r") as f:
|
||||
services = yaml.safe_load(f)
|
||||
if services is None:
|
||||
services = dict()
|
||||
port_map = dict()
|
||||
for key, value in services.items():
|
||||
if 'needs_exposed_ports' in value:
|
||||
|
@ -125,6 +127,8 @@ import yaml, socket
|
|||
hard_coded_ports = ["25", "53", "80", "443", "587", "993"]
|
||||
with open("/etc/yunohost/services.yml", "r") as f:
|
||||
services = yaml.safe_load(f)
|
||||
if services is None:
|
||||
services = dict()
|
||||
results = ["%s|%s" % (k, v["description"] if "description" in v else k) for k, v in services.items()]
|
||||
print('\n'.join(results))
|
||||
EOF
|
||||
|
@ -145,7 +149,7 @@ EOF
|
|||
# Used by update_config_if_needed.sh hook
|
||||
save_vars_current_value() {
|
||||
for var in $var_list_to_manage; do
|
||||
ynh_app_setting_set --app "$app" --key previous_$var --value "${!var}"
|
||||
ynh_app_setting_set --app="$app" --key="previous_$var" --value="${!var}"
|
||||
done
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ load_vars
|
|||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
if systemctl is-active $app.service --quiet; then
|
||||
if systemctl is-active "$app".service --quiet; then
|
||||
ynh_print_warn --message="It's highly recommended to make your backup when the service is stopped. Please stop $app service with this command before to run the backup 'systemctl stop $app.service'"
|
||||
fi
|
||||
|
||||
|
@ -29,11 +29,11 @@ ynh_print_info --message="Declaring files to be backed up..."
|
|||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/$app/"
|
||||
ynh_backup --src_path "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup --src_path "$nginx_status_conf"
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup --src_path="$nginx_status_conf"
|
||||
|
||||
ynh_print_info --message="Backing up code..."
|
||||
ynh_backup --src_path $install_dir
|
||||
ynh_backup --src_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
|
@ -41,7 +41,7 @@ ynh_backup --src_path $install_dir
|
|||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path "/etc/systemd/system/$app.service"
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# BACKUP VARIOUS FILES
|
||||
|
|
|
@ -18,7 +18,7 @@ load_vars
|
|||
#=================================================
|
||||
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"
|
||||
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
|
@ -39,7 +39,7 @@ ynh_add_jinja_config --template=monitorix.conf --destination=/etc/monitorix/moni
|
|||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
ynh_systemd_action --service_name="$app" --action=start --log_path 'systemd' --line_match ' - Ok, ready.'
|
||||
ynh_systemd_action --service_name="$app" --action=start --log_path='systemd' --line_match=' - Ok, ready.'
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -133,30 +133,3 @@ ynh_add_jinja_config() {
|
|||
)
|
||||
ynh_store_file_checksum --file="$destination"
|
||||
}
|
||||
|
||||
# Check either a package is installed or not
|
||||
#
|
||||
# example: ynh_package_is_installed --package=yunohost && echo "installed"
|
||||
#
|
||||
# usage: ynh_package_is_installed --package=name [--wait_dpkg_free]
|
||||
# | arg: -p, --package= - the package name to check
|
||||
# | arg: -l, --wait_dpkg_free= - wait for dpkg to be free.
|
||||
# | Note that waiting on dpkg free could take about 0.2s on quick platform
|
||||
# | and about 2 seconds on slow platform so in case of multiple call it could be slow
|
||||
# | ret: 0 if the package is installed, 1 else.
|
||||
ynh_package_is_installed() {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=pl
|
||||
local -A args_array=([p]=package= [l]=wait_dpkg_free=)
|
||||
local package
|
||||
local wait_dpkg_free
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
wait_dpkg_free="${wait_dpkg_free:-0}"
|
||||
|
||||
if [ "$wait_dpkg_free" -eq 1 ]; then
|
||||
ynh_wait_dpkg_free
|
||||
fi
|
||||
dpkg-query --show --showformat='${Status}' "$package" 2>/dev/null \
|
||||
| grep --count "ok installed" &>/dev/null
|
||||
}
|
||||
|
|
|
@ -17,34 +17,25 @@ ensure_vars_set
|
|||
# Check datadir empty
|
||||
#=================================================
|
||||
|
||||
if [ -n "$(ls -A $data_dir)" ]; then
|
||||
if [ -n "$(ls -A "$data_dir")" ]; then
|
||||
old_data_dir_path="${data_dir}_$(date '+%Y%m%d.%H%M%S')"
|
||||
ynh_print_warn --message="Data directory was not empty. Data was moved to $old_data_dir_path"
|
||||
mkdir -p $old_data_dir_path
|
||||
mkdir -p "$old_data_dir_path"
|
||||
mv -t "$old_data_dir_path" "$data_dir"/*
|
||||
app_data_dirs="$(echo /home/yunohost.app/*)"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing packages..." --weight=1
|
||||
|
||||
# Download package and install it
|
||||
install_monitorix_package
|
||||
mkdir -p /var/log/"$app"
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action=stop --log_path=systemd --timeout=15
|
||||
mkdir -p /var/log/new_"${app}"
|
||||
mv -t /var/log/new_"${app}" /var/log/monitorix*
|
||||
mv /var/log/new_"${app}" /var/log/"${app}"
|
||||
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================ç
|
||||
ynh_script_progression --message="Adding configurations related to $app..." --weight=1
|
||||
|
||||
mkdir -p /etc/monitorix
|
||||
ynh_add_jinja_config --template=monitorix.conf --destination="/etc/monitorix/monitorix.conf"
|
||||
ynh_add_jinja_config --template=nginx_status.conf --destination "$nginx_status_conf"
|
||||
ynh_add_jinja_config --template=nginx_status.conf --destination="$nginx_status_conf"
|
||||
|
||||
ynh_add_nginx_config
|
||||
ynh_add_systemd_config
|
||||
|
@ -62,6 +53,14 @@ fi
|
|||
configure_hooks
|
||||
configure_alerts_email
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing packages..." --weight=1
|
||||
|
||||
# Download package and install it
|
||||
install_monitorix_package
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
@ -69,14 +68,14 @@ ynh_script_progression --message="Protecting directory..."
|
|||
|
||||
set_permission
|
||||
|
||||
ynh_use_logrotate --logfile "/var/log/$app"
|
||||
ynh_use_logrotate --logfile="/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path 'systemd' --line_match ' - Ok, ready.'
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path='systemd' --line_match=' - Ok, ready.'
|
||||
# when we change the value of 'listen [::1]:xxx;' nginx don't reload correctly the config, so force to restart to ensure that the new config are loaded
|
||||
ynh_systemd_action --service_name=nginx.service --action=restart
|
||||
save_vars_current_value
|
||||
|
|
|
@ -18,7 +18,7 @@ load_vars
|
|||
#=================================================
|
||||
|
||||
# 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
|
||||
if ynh_exec_warn_less yunohost service status "$app" >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app service integration..." --weight=3
|
||||
yunohost service remove "$app"
|
||||
|
@ -48,15 +48,18 @@ for pool_dir_by_version in /etc/php/*; do
|
|||
fi
|
||||
done
|
||||
|
||||
if ynh_psql_user_exists --user=$db_user; then
|
||||
ynh_psql_drop_user $db_user
|
||||
if ynh_psql_user_exists --user="$db_user"; then
|
||||
ynh_psql_drop_user "$db_user"
|
||||
fi
|
||||
if ynh_mysql_user_exists --user=$db_user; then
|
||||
ynh_mysql_drop_user $db_user
|
||||
if ynh_mysql_user_exists --user="$db_user"; then
|
||||
ynh_mysql_drop_user "$db_user"
|
||||
fi
|
||||
|
||||
ynh_package_autopurge monitorix
|
||||
ynh_secure_remove --file=/var/log/"$app"
|
||||
ynh_secure_remove --file="$install_dir"
|
||||
|
||||
if [ "$YNH_APP_PURGE" -eq 1 ]; then
|
||||
ynh_secure_remove --file=/var/log/"$app"
|
||||
fi
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
|
|
|
@ -12,17 +12,6 @@ source ../settings/scripts/experimental_helper.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
load_vars
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the dependencies..." --weight=1
|
||||
|
||||
install_monitorix_package
|
||||
ynh_systemd_action --service_name="$app" --action=stop --log_path=systemd --timeout=15
|
||||
mkdir -p /var/log/new_"${app}"
|
||||
mv -t /var/log/new_"${app}" /var/log/monitorix*
|
||||
mv /var/log/new_"${app}" /var/log/"${app}"
|
||||
|
||||
ynh_script_progression --message="Configuring databases access..."
|
||||
configure_db
|
||||
|
||||
|
@ -32,15 +21,23 @@ configure_db
|
|||
ynh_script_progression --message="Restoring files" --weight=1
|
||||
|
||||
ynh_restore
|
||||
mkdir -p /var/log/$app
|
||||
systemctl enable $app.service --quiet
|
||||
mkdir -p /var/log/"$app"
|
||||
systemctl enable "$app".service --quiet
|
||||
|
||||
ynh_script_progression --message="Configuring php fpm access if needed..."
|
||||
if "$phpfpm_installed"; then
|
||||
config_php_fpm
|
||||
fi
|
||||
|
||||
yunohost service add $app --description="Monitorix" --log="systemd"
|
||||
yunohost service add "$app" --description="Monitorix" --log="systemd"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the dependencies..." --weight=1
|
||||
|
||||
install_monitorix_package
|
||||
ynh_systemd_action --service_name="$app" --action=stop --log_path=systemd --timeout=15
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -49,7 +46,7 @@ ynh_script_progression --message="Protecting directory..."
|
|||
|
||||
set_permission
|
||||
|
||||
ynh_use_logrotate --logfile "/var/log/$app"
|
||||
ynh_use_logrotate --logfile="/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -58,7 +55,7 @@ ynh_use_logrotate --logfile "/var/log/$app"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action=start --log_path 'systemd' --line_match ' - Ok, ready.'
|
||||
ynh_systemd_action --service_name="$app" --action=start --log_path='systemd' --line_match=' - Ok, ready.'
|
||||
# when we change the value of 'listen [::1]:xxx;' nginx don't reload correctly the config, so force to restart to ensure that the new config are loaded
|
||||
ynh_systemd_action --service_name=nginx.service --action=restart
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
|
|
@ -11,7 +11,7 @@ source experimental_helper.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
load_vars
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
upgrade_type="$(ynh_check_app_version_changed)"
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
|
@ -30,14 +30,14 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|||
test -e /etc/monitorix/conf.d/00-debian.conf || touch /etc/monitorix/conf.d/00-debian.conf
|
||||
|
||||
# Remove old hook if exist
|
||||
ynh_secure_remove --file=/usr/share/yunohost/hooks/post_iptable_rules/50-$app
|
||||
ynh_secure_remove --file=/usr/share/yunohost/hooks/post_iptable_rules/50-"$app"
|
||||
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
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"
|
||||
ynh_systemd_action --service_name="$app" --action=stop --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
|
||||
|
@ -77,7 +77,7 @@ fi
|
|||
ynh_script_progression --message="Upgrading configurations related to $app..." --weight=1
|
||||
|
||||
ynh_add_jinja_config --template=monitorix.conf --destination=/etc/monitorix/monitorix.conf
|
||||
ynh_add_jinja_config --template=nginx_status.conf --destination "$nginx_status_conf"
|
||||
ynh_add_jinja_config --template=nginx_status.conf --destination="$nginx_status_conf"
|
||||
if "$phpfpm_installed"; then
|
||||
config_php_fpm
|
||||
fi
|
||||
|
@ -104,14 +104,14 @@ ynh_script_progression --message="Protecting directory..."
|
|||
|
||||
set_permission
|
||||
|
||||
ynh_use_logrotate --logfile "/var/log/$app"
|
||||
ynh_use_logrotate --logfile="/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name="$app" --action=restart --log_path=systemd --line_match ' - Ok, ready.'
|
||||
ynh_systemd_action --service_name="$app" --action=restart --log_path=systemd --line_match=' - Ok, ready.'
|
||||
# when we change the value of 'listen [::1]:xxx;' nginx don't reload correctly the config, so force to restart to ensure that the new config are loaded
|
||||
ynh_systemd_action --service_name=nginx.service --action=restart
|
||||
save_vars_current_value
|
||||
|
|
|
@ -76,13 +76,13 @@ if "$status_dirty"; then
|
|||
emailreports_yearly_to="$(ynh_app_setting_get --app="$app" --key=emailreports_yearly_to)"
|
||||
|
||||
ynh_add_jinja_config --template=monitorix.conf --destination="/etc/monitorix/monitorix.conf"
|
||||
ynh_add_jinja_config --template=nginx_status.conf --destination "$nginx_status_conf"
|
||||
ynh_add_jinja_config --template=nginx_status.conf --destination="$nginx_status_conf"
|
||||
configure_db
|
||||
|
||||
if "$phpfpm_installed"; then
|
||||
config_php_fpm
|
||||
fi
|
||||
ynh_systemd_action --service_name="$app" --action=restart --log_path 'systemd' --line_match ' - Ok, ready.'
|
||||
ynh_systemd_action --service_name="$app" --action=restart --log_path='systemd' --line_match=' - Ok, ready.'
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
save_vars_current_value
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue