From 3633e2d0efc537164661343f9cdd3019dd328d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 28 Dec 2023 09:31:32 +0100 Subject: [PATCH] v2 --- conf/app.src | 6 ---- conf/uninstaller.src | 7 ----- manifest.toml | 67 ++++++++++++++++++++++++++++++++++++++++++++ scripts/_common.sh | 24 ++++++++-------- scripts/backup | 14 ++++----- scripts/change_url | 62 ++++++++++++++++++++-------------------- scripts/install | 50 ++++++++++++++++----------------- scripts/remove | 14 ++++----- scripts/restore | 26 ++++++++--------- scripts/upgrade | 54 +++++++++++++++++------------------ 10 files changed, 190 insertions(+), 134 deletions(-) delete mode 100644 conf/app.src delete mode 100644 conf/uninstaller.src create mode 100644 manifest.toml diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index 33c1264..0000000 --- a/conf/app.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://github.com/netdata/netdata/releases/download/v1.44.1/netdata-v1.44.1.tar.gz -SOURCE_SUM=77e94acf7085c23ab20b2d0d2d4d2bc5a289f121fc7aac5d0daffb960041fd95 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= diff --git a/conf/uninstaller.src b/conf/uninstaller.src deleted file mode 100644 index 5617ba0..0000000 --- a/conf/uninstaller.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://raw.githubusercontent.com/netdata/netdata/v1.15.0/packaging/installer/netdata-uninstaller.sh -SOURCE_SUM=a4727069b47138cea5c466bc902934545841c88dc5f641728ef0feb921efd218 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=sh -SOURCE_IN_SUBDIR=false -SOURCE_FILENAME=netdata-uninstaller.sh -SOURCE_EXTRACT=false diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..fd9e733 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,67 @@ +packaging_format = 2 + +id = "netdata" +name = "NetData" +description.en = "Real-time performance and health monitoring" +description.fr = "Monitoring serveur en temps reel" + +version = "1.44.1~ynh1" + +maintainers = ["JimboJoe"] + +[upstream] +license = "GPL-3.0" +website = "http://my-netdata.io" +demo = "https://learn.netdata.cloud/docs/agent/demo-sites/" +admindoc = "https://learn.netdata.cloud/docs" +code = "https://github.com/netdata/netdata" +cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) +fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. + +[integration] +yunohost = ">= 11.2" +architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +multi_instance = false +ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. +sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. +disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... +ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +[install] + [install.domain] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "domain" + + [install.path] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "path" + default = "/netdata" + + [install.init_main_permission] + type = "group" + default = false + + [install.admin] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "user" + +[resources] + [resources.sources] + [resources.sources.main] + url = "https://github.com/netdata/netdata/releases/download/v1.44.1/netdata-v1.44.1.tar.gz" + sha256 = "77e94acf7085c23ab20b2d0d2d4d2bc5a289f121fc7aac5d0daffb960041fd95" + + [resources.sources.uninstaller] + url = "https://raw.githubusercontent.com/netdata/netdata/v1.15.0/packaging/installer/netdata-uninstaller.sh" + sha256 = "a4727069b47138cea5c466bc902934545841c88dc5f641728ef0feb921efd218" + format = "sh" + rename = "netdata-uninstaller.sh" + + + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" diff --git a/scripts/_common.sh b/scripts/_common.sh index d5fee85..6b373b7 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="zlib1g-dev uuid-dev libmnl-dev gcc make git autoconf autoconf-archive autogen automake pkg-config curl jq nodejs python3-mysqldb libipmimonitoring-dev acl python3-pymongo libuv1-dev liblz4-dev libjudy-dev libssl-dev cmake" +#REMOVEME? pkg_dependencies="zlib1g-dev uuid-dev libmnl-dev gcc make git autoconf autoconf-archive autogen automake pkg-config curl jq nodejs python3-mysqldb libipmimonitoring-dev acl python3-pymongo libuv1-dev liblz4-dev libjudy-dev libssl-dev cmake" #================================================= # PERSONAL HELPERS @@ -17,12 +17,12 @@ configure_netdata() { # Set server as registry serveur sed -i "/^\[registry\]$/,/^\[/ { s/# enabled = no/enabled = yes/ - s@# registry to announce = https://registry.my-netdata.io@registry to announce = https://$domain$path_url@ - }" $final_path/etc/netdata/netdata.conf + s@# registry to announce = https://registry.my-netdata.io@registry to announce = https://$domain$path@ + }" $install_dir/etc/netdata/netdata.conf # Opt-out from sending anonymous statistics # (see https://docs.netdata.cloud/docs/anonymous-statistics/#opt-out) - touch $final_path/etc/netdata/.opt-out-from-anonymous-statistics + touch $install_dir/etc/netdata/.opt-out-from-anonymous-statistics # Add a web_log entry for every YunoHost domain netdata_add_yunohost_web_logs @@ -57,9 +57,9 @@ configure_netdata() { # Add a web_log entry for every YunoHost domain netdata_add_yunohost_web_logs () { - local web_log_file="$final_path/etc/netdata/go.d/web_log.conf" + local web_log_file="$install_dir/etc/netdata/go.d/web_log.conf" if [ ! -f $web_log_file ] ; then - cp $final_path/etc/netdata/orig/go.d/web_log.conf $web_log_file + cp $install_dir/etc/netdata/orig/go.d/web_log.conf $web_log_file fi if [ -z "$(grep "YUNOHOST" $web_log_file)" ] ; then echo "# ------------YUNOHOST DOMAINS---------------" >> $web_log_file @@ -77,16 +77,16 @@ EOF fi chgrp netdata $web_log_file # Manage upgrade case from python to go plugin - if [ -f "$final_path/etc/netdata/python.d/web_log.conf" ] ; then - ynh_secure_remove --file="$final_path/etc/netdata/python.d/web_log.conf" + if [ -f "$install_dir/etc/netdata/python.d/web_log.conf" ] ; then +#REMOVEME? ynh_secure_remove --file="$install_dir/etc/netdata/python.d/web_log.conf" fi } # If PostgreSQL is installed, add a PostgreSQL entry using instance password netdata_add_yunohost_postgres_configuration () { - local postgres_file="$final_path/etc/netdata/go.d/postgres.conf" + local postgres_file="$install_dir/etc/netdata/go.d/postgres.conf" if [ ! -f $postgres_file ] ; then - cp $final_path/etc/netdata/orig/go.d/postgres.conf $postgres_file + cp $install_dir/etc/netdata/orig/go.d/postgres.conf $postgres_file fi if [ -f /etc/yunohost/psql ] && [ -z "$(grep "YUNOHOST" $postgres_file)" ] ; then cat >> $postgres_file <${tmp} # Execute the uninstall script - ./${UNINSTALL_SCRIPT} --yes --force --env $final_path/etc/netdata/.environment >&3 2>&3 + ./${UNINSTALL_SCRIPT} --yes --force --env $install_dir/etc/netdata/.environment >&3 2>&3 # close fd 3 exec 3<&- diff --git a/scripts/restore b/scripts/restore index 5b4de05..219b217 100644 --- a/scripts/restore +++ b/scripts/restore @@ -14,27 +14,27 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { true } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 +#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1 #================================================= # STANDARD RESTORATION STEPS @@ -43,17 +43,17 @@ ynh_script_progression --message="Validating restoration parameters..." --weight #================================================= ynh_script_progression --message="Restoring Netdata configuration directory..." --weight=1 -ynh_restore_file --origin_path="$final_path/etc/netdata" +ynh_restore_file --origin_path="$install_dir/etc/netdata" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=7 +#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=7 # Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE NGINX CONFIGURATION @@ -91,14 +91,14 @@ configure_netdata #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "Real-time performance and health monitoring for systems and applications" --log "$final_path/var/log/netdata/error.log" "$final_path/var/log/netdata/access.log" "$final_path/var/log/netdata/debug.log" +yunohost service add $app --description "Real-time performance and health monitoring for systems and applications" --log "$install_dir/var/log/netdata/error.log" "$install_dir/var/log/netdata/access.log" "$install_dir/var/log/netdata/debug.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/var/log/$app/error.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="$install_dir/var/log/$app/error.log" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 9af2636..bfe3c02 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,14 +12,14 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? 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) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) #================================================= # CHECK VERSION @@ -30,16 +30,16 @@ 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=3 +#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3 # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS @@ -48,22 +48,22 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# If final_path doesn't exist, create it -if [ -z "$final_path" ]; then - final_path=/opt/$app - ynh_app_setting_set --app=$app --key=final_path --value=$final_path +# If install_dir doesn't exist, create it +if [ -z "$install_dir" ]; then +#REMOVEME? install_dir=/opt/$app +#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir fi -# If final_path wrongly refers to /var/www +# If install_dir wrongly refers to /var/www # see http://tldp.org/LDP/abs/html/comparison-ops.html for syntax reference -if [[ $final_path == /var/www* ]]; then - final_path=/opt/$app - ynh_app_setting_set --app=$app --key=final_path --value=$final_path +if [[ $install_dir == /var/www* ]]; then +#REMOVEME? install_dir=/opt/$app +#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir fi # Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all +#REMOVEME? if ynh_legacy_permissions_exists; then +#REMOVEME? ynh_legacy_permissions_delete_all ynh_app_setting_delete --app=$app --key=is_public fi @@ -121,9 +121,9 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=7 +#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=7 -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies #================================================= # GENERIC FINALIZATION @@ -132,21 +132,21 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "Real-time performance and health monitoring for systems and applications" --log "$final_path/var/log/netdata/error.log" "$final_path/var/log/netdata/access.log" "$final_path/var/log/netdata/debug.log" +yunohost service add $app --description "Real-time performance and health monitoring for systems and applications" --log "$install_dir/var/log/netdata/error.log" "$install_dir/var/log/netdata/access.log" "$install_dir/var/log/netdata/debug.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="restart" --log_path="$final_path/var/log/$app/error.log" +ynh_systemd_action --service_name=$app --action="restart" --log_path="$install_dir/var/log/$app/error.log" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT