From aa588461eb5272efb0e4cbed987eb96380263107 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Wed, 13 May 2020 16:00:07 +0200 Subject: [PATCH 1/8] Refactor to latest package guidelines --- conf/nginx.conf | 14 +++--- scripts/_common.sh | 29 +++++------ scripts/backup | 42 ++++++++++++++-- scripts/change_url | 96 +++++++++++++++++++++--------------- scripts/install | 86 ++++++++++++++++++++++---------- scripts/remove | 40 ++++++++++++--- scripts/restore | 71 ++++++++++++++++++++------- scripts/upgrade | 119 +++++++++++++++++++++++++++++---------------- 8 files changed, 339 insertions(+), 158 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index fde6590..9241df9 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,8 +1,10 @@ -#for-subdir location __PATH__ { -#for-subdir return 301 __PATH__/; -#for-subdir } +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location ~ __PATH__/(?.*) { + # Force usage of https + if ($scheme = http) { + rewrite ^ https://$server_name$request_uri? permanent; + } proxy_redirect off; proxy_set_header Host $host; @@ -19,7 +21,7 @@ location ~ __PATH__/(?.*) { gzip on; gzip_proxied any; gzip_types *; - - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; } diff --git a/scripts/_common.sh b/scripts/_common.sh index 2edd312..5cda5f3 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,9 +1,16 @@ #!/bin/bash -# -# Common variables -# +#================================================= +# COMMON VARIABLES +#================================================= + +# 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 python-mysqldb libipmimonitoring-dev acl python-psycopg2 python-pymongo libuv1-dev liblz4-dev libjudy-dev libssl-dev cmake" + +#================================================= +# PERSONAL HELPERS +#================================================= + # Configure NetData configure_netdata() { @@ -13,9 +20,9 @@ configure_netdata() { s@# registry to announce = https://registry.my-netdata.io@registry to announce = https://$domain$path_url@ }" /opt/netdata/etc/netdata/netdata.conf -# Opt-out from sending anonymous statistics -# (see https://docs.netdata.cloud/docs/anonymous-statistics/#opt-out) -touch /opt/netdata/etc/netdata/.opt-out-from-anonymous-statistics + # Opt-out from sending anonymous statistics + # (see https://docs.netdata.cloud/docs/anonymous-statistics/#opt-out) + touch /opt/netdata/etc/netdata/.opt-out-from-anonymous-statistics # Add a web_log entry for every YunoHost domain netdata_add_yunohost_web_logs @@ -24,9 +31,9 @@ touch /opt/netdata/etc/netdata/.opt-out-from-anonymous-statistics netdata_add_yunohost_postgres_configuration # Create netdata user to monitor MySQL (if needed) - is_mysql_user_existing=$(ynh_mysql_execute_as_root "select user from mysql.user where user = 'netdata';") + is_mysql_user_existing=$(ynh_mysql_execute_as_root --sql="select user from mysql.user where user = 'netdata';") if [ -z "$is_mysql_user_existing" ] ; then - ynh_mysql_execute_as_root "create user 'netdata'@'localhost'; + ynh_mysql_execute_as_root --sql="create user 'netdata'@'localhost'; grant usage on *.* to 'netdata'@'localhost' with grant option; flush privileges;" fi @@ -46,12 +53,6 @@ touch /opt/netdata/etc/netdata/.opt-out-from-anonymous-statistics # Add netdata to the adm group to access web logs usermod -a -G adm netdata - - # Declare service for YunoHost monitoring - yunohost service add netdata --log "/opt/netdata/var/log/netdata/error.log" "/opt/netdata/var/log/netdata/access.log" "/opt/netdata/var/log/netdata/debug.log" - - # Restart NetData - systemctl restart netdata } # Add a web_log entry for every YunoHost domain diff --git a/scripts/backup b/scripts/backup index 4674860..7ae019c 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -13,28 +14,59 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} # 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" domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= # STANDARD BACKUP STEPS #================================================= -# BACKUP THE APP CONFIGURATION +# STOP SYSTEMD SERVICE #================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 -# Backup configuration files -ynh_backup "/opt/netdata/etc/netdata" +ynh_systemd_action --service_name=$app --action="stop" --log_path="/opt/$app/var/log/$app/error.log" + +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Backing up Netdata configuration directory..." --weight=1 + +ynh_backup --src_path="/opt/netdata/etc/netdata" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Backing up nginx web server configuration..." --weight=1 -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# SPECIFIC BACKUP +#================================================= + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="/opt/$app/var/log/$app/error.log" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last diff --git a/scripts/change_url b/scripts/change_url index 8efef37..63672c3 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,15 +24,27 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 + +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= -# CHECK PATHS SYNTAX +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --time --weight=1 -test -n "$old_path" || old_path="/" -test -n "$new_path" || new_path="/" -new_path=$(ynh_normalize_url_path $new_path) -old_path=$(ynh_normalize_url_path $old_path) +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # 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 @@ -53,60 +65,66 @@ fi #================================================= # STANDARD MODIFICATIONS #================================================= -# MODIFY URL IN NGINX CONF FILE +# 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" + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +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 "$nginx_conf_path" - ynh_replace_string "location $old_path {" "location $new_path {" "$nginx_conf_path" - if [ "$new_path" = "/" ] && [ "$old_path" != "/" ] ; then - ynh_replace_string "location ~ $old_path" "location ~ " "$nginx_conf_path" - ynh_replace_string "return 301 $old_path/" "return 301 /" "$nginx_conf_path" - - # Move #for-subdir comment at the beginning of the line (line not needed for "/" path) - ynh_replace_string "\(.*\) #for-subdir" "#for-subdir \1" "$nginx_conf_path" - elif [ "$new_path" != "/" ] && [ "$old_path" = "/" ] ; then - # Move #for-subdir comment at the end of the line (line needed for "/path" path) - ynh_replace_string "#for-subdir\(.*\)" "\1 #for-subdir" "$nginx_conf_path" - - # Replace path in several location occurrences based on different recognition patterns - ynh_replace_string "location ~ " "location ~ $new_path" "$nginx_conf_path" - ynh_replace_string "return 301 /" "return 301 $new_path/" "$nginx_conf_path" - else - ynh_replace_string "location ~ $old_path" "location ~ $new_path" "$nginx_conf_path" - ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path" - fi - # Calculate and store the nginx config file checksum - ynh_store_file_checksum "$nginx_conf_path" - - # Change registry link - ynh_replace_string "registry to announce = https://$old_domain$old_path" "registry to announce = https://$new_domain$new_path" /opt/netdata/etc/netdata/netdata.conf - systemctl restart netdata + # 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 "$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 "/etc/nginx/conf.d/$new_domain.d/$app.conf" + # 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 #================================================= # SPECIFIC MODIFICATIONS #================================================= +# Change registry link +ynh_replace_string --match_string="registry to announce = https://$old_domain$old_path" --replace_string="registry to announce = https://$new_domain$new_path" --target_file="/opt/netdata/etc/netdata/netdata.conf" + #================================================= -# GENERIC FINALIZATION +# GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="restart" --log_path="/opt/$app/var/log/$app/error.log" + #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading nginx web server..." --weight=1 -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index 9003a7e..ee59d46 100644 --- a/scripts/install +++ b/scripts/install @@ -13,6 +13,10 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -30,55 +34,63 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +### About --weight and --time +### ynh_script_progression will show to your final users the progression of each scripts. +### In order to do that, --weight will represent the relative time of execution compared to the other steps in the script. +### --time is a packager option, it will show you the execution time since the previous call. +### This option should be removed before releasing your app. +### Use the execution time, given by --time, to estimate the weight of a step. +### A common way to do it is to set a weight equal to the execution time in second +1. +### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call. +ynh_script_progression --message="Validating installation parameters..." --weight=1 -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) +final_path=/opt/$app +test ! -e "$final_path" || ynh_die --message="This path already contains a folder" -# Check web path availability -ynh_webpath_available $domain $path_url # Register (book) web path -ynh_webpath_register $app $domain $path_url +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_script_progression --message="Storing installation settings..." --weight=1 -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path_url -ynh_app_setting_set $app admin $admin -ynh_app_setting_set $app is_public $is_public +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 +#================================================= + #================================================= # INSTALL DEPENDENCIES #================================================= +ynh_script_progression --message="Installing dependencies..." --weight=32 ynh_install_app_dependencies $pkg_dependencies #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Setting up source files..." --weight=11 +### `ynh_setup_source` is used to install an app from a zip or tar.gz file, +### downloaded from an upstream source, like a git repository. +### `ynh_setup_source` use the file conf/app.src + +ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src NETDATA_TMPDIR=$(mktemp -d) -ynh_setup_source "$NETDATA_TMPDIR" +ynh_setup_source --dest_dir="$NETDATA_TMPDIR" #================================================= # NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Configuring nginx web server..." --weight=2 -nginx_conf="../conf/nginx.conf" -if [ "$path_url" = "/" ] -then - # Handle root path, avoid double slash. - # Temporary fix, in waiting for an upgrade of the helper. (#361) - path_url_slash_less=${path_url%/} - ynh_replace_string "__PATH__/" "$path_url_slash_less/" $nginx_conf -else - # Move prefix comment #for-subdir at end of lines - ynh_replace_string "#for-subdir\(.*\)" "\1 #for-subdir" $nginx_conf -fi +### `ynh_add_nginx_config` will use the file conf/nginx.conf # Create a dedicated nginx config ynh_add_nginx_config @@ -87,10 +99,7 @@ ynh_add_nginx_config # SPECIFIC SETUP #================================================= -#================================================= -# INSTALL AND CONFIGURE NETDATA -#================================================= - +ynh_script_progression --message="Executing Netdata installer..." --time --weight=180 # Launch netdata installation in /opt directory pushd $NETDATA_TMPDIR ./netdata-installer.sh --install /opt --dont-wait @@ -101,13 +110,30 @@ configure_netdata popd cp ../conf/app.src /opt/netdata/etc/netdata + #================================================= # GENERIC FINALIZATION #================================================= +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= + +yunohost service add $app --description "Real-time performance and health monitoring for systems and applications" --log "/opt/netdata/var/log/netdata/error.log" "/opt/netdata/var/log/netdata/access.log" "/opt/netdata/var/log/netdata/debug.log" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=2 + +# Start a systemd service +ynh_systemd_action --service_name=$app --action="restart" --log_path="/opt/$app/var/log/$app/error.log" + + #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Configuring SSOwat..." --weight=1 # Make app public if necessary if [ $is_public -eq 1 ]; then @@ -119,8 +145,16 @@ fi # Add direct access in the portal to admin only ynh_permission_update --permission "main" --add "$admin" + #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading nginx web server..." --weight=1 -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 48648e9..f24a216 100644 --- a/scripts/remove +++ b/scripts/remove @@ -6,30 +6,44 @@ # IMPORT GENERIC HELPERS #================================================= -# Source app helpers 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" domain) +domain=$(ynh_app_setting_get --app=$app --key=domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE +#================================================= +# REMOVE SERVICE INTEGRATION IN YUNOHOST +#================================================= + +# 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 +then + ynh_script_progression --message="Removing $app service..." --weight=2 + yunohost service remove $app +fi + #================================================= # REMOVE DEPENDENCIES #================================================= +ynh_script_progression --message="Removing dependencies..." --weight=8 # Remove metapackage and its dependencies ynh_remove_app_dependencies #================================================= -# REMOVE APP +# REMOVE APP MAIN DIR #================================================= +ynh_script_progression --message="Uninstalling Netdata..." --weight=6 # Prepare to execute uninstaller(generated by NetData install script) UNINSTALL_SCRIPT="netdata-uninstaller.sh" @@ -44,14 +58,26 @@ cd /tmp ./${UNINSTALL_SCRIPT} --yes --force --env /opt/netdata/etc/netdata/.environment # Remove MySQL netdata user - ynh_mysql_execute_as_root "drop user 'netdata'@'localhost'; flush privileges;" - -# Remove services from YunoHost monitoring - yunohost service remove netdata +ynh_mysql_execute_as_root "drop user 'netdata'@'localhost'; flush privileges;" #================================================= # REMOVE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Removing nginx web server configuration..." --weight=1 # Remove the dedicated nginx config ynh_remove_nginx_config + +#================================================= +# SPECIFIC REMOVE +#================================================= + +#================================================= +# GENERIC FINALIZATION +#================================================= + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 4b6ec37..45c202a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -13,24 +14,33 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + #### Remove this function if there's nothing to clean before calling the remove script. + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) +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) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= +ynh_script_progression --message="Validating restoration parameters..." --weight=1 -ynh_webpath_available $domain $path_url \ - || ynh_die "Path not available: ${domain}${path_url}" +ynh_webpath_available --domain=$domain --path_url=$path_url \ + || ynh_die --message="Path not available: ${domain}${path_url}" +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS @@ -38,21 +48,30 @@ ynh_webpath_available $domain $path_url \ # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# INSTALL DEPENDENCIES +# RESTORE THE APP MAIN DIR #================================================= +ynh_script_progression --message="Restoring Netdata configuration directory..." --weight=1 +ynh_restore_file --origin_path="/opt/netdata/etc/netdata" + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=7 + +# Define and install dependencies ynh_install_app_dependencies $pkg_dependencies #================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE +# INSTALL AND RESTORE THE APP CONFIGURATION #================================================= -# Restore configuration files -ynh_restore_file "/opt/netdata/etc/netdata" - +ynh_script_progression --message="Reinstalling Netdata..." --weight=180 # Restore permissions to app files chown -R root: "/opt/netdata/etc/netdata" @@ -64,10 +83,6 @@ cp /opt/netdata/etc/netdata/app.src ../conf NETDATA_TMPDIR=$(mktemp -d) ynh_setup_source "$NETDATA_TMPDIR" -#================================================= -# INSTALL AND RESTORE THE APP CONFIGURATION -#================================================= - # Launch netdata installation in /opt directory cd $NETDATA_TMPDIR ./netdata-installer.sh --install /opt --dont-wait @@ -75,9 +90,29 @@ cd $NETDATA_TMPDIR configure_netdata #================================================= -# GENERIC FINALISATION -#================================================= -# RELOAD NGINX AND PHP-FPM +# INTEGRATE SERVICE IN YUNOHOST #================================================= -systemctl reload nginx +yunohost service add $app --description "A short description of the app" --log "/opt/netdata/var/log/netdata/error.log" "/opt/netdata/var/log/netdata/access.log" "/opt/netdata/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="/opt/$app/var/log/$app/error.log" + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index bfcd2e2..2a5356a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,63 +12,68 @@ 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 domain) -path_url=$(ynh_app_setting_get $app path) -is_public=$(ynh_app_setting_get $app is_public) +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) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#================================================= +# CHECK VERSION +#================================================= + +upgrade_type=$(ynh_check_app_version_changed) + +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +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 final_path doesn't exist, create it +if [ -z "$final_path" ]; then + final_path=/var/www/$app + ynh_app_setting_set --app=$app --key=final_path --value=$final_path +fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3 -ynh_backup_before_upgrade # Backup the current version of the app +# Backup the current version of the app +ynh_backup_before_upgrade ynh_clean_setup () { - ynh_restore_upgradebackup # restore it if the upgrade fails + # restore it if the upgrade fails + ynh_restore_upgradebackup } -ynh_abort_if_errors # Active trap to stop script execution if an error occurs - -#================================================= -# CHECK THE PATH -#================================================= - -# Normalize the URL path syntax -path_url=$(ynh_normalize_url_path $path_url) +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS #================================================= + #================================================= -# NGINX CONFIGURATION +# DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -nginx_conf="../conf/nginx.conf" -if [ "$path_url" = "/" ] +if [ "$upgrade_type" == "UPGRADE_APP" ] then - # Handle root path, avoid double slash. - # Temporary fix, in waiting for an upgrade of the helper. (#361) - path_url_slash_less=${path_url%/} - ynh_replace_string "__PATH__/" "$path_url_slash_less/" $nginx_conf -else - # Move prefix comment #for-subdir at end of lines - ynh_replace_string "#for-subdir\(.*\)" "\1 #for-subdir" $nginx_conf -fi + ynh_script_progression --message="Upgrading source files..." --weight=180 -# Create a dedicated nginx config -ynh_add_nginx_config - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= - -ynh_install_app_dependencies $pkg_dependencies - -installed_version=$(cat /opt/netdata/etc/netdata/app.src | grep SOURCE_URL | sed "s|.*/v\(.*\)/.*|\1|g") -version_to_install=$(cat ../conf/app.src | grep SOURCE_URL | sed "s|.*/v\(.*\)/.*|\1|g") - -if [ "$installed_version" != "$version_to_install" ] ; then #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -93,12 +98,8 @@ if [ "$installed_version" != "$version_to_install" ] ; then # Launch netdata installation in /opt directory pushd $NETDATA_TMPDIR - # Remove previous service definition (specific 1.8.0 upgrade) - rm -f /etc/systemd/system/netdata.service - ./netdata-installer.sh --install /opt --dont-wait >&3 2>&3 || ynh_die "FAILED TO COMPILE/INSTALL NETDATA" - - popd + popd # close fd 3 exec 3<&- @@ -110,11 +111,29 @@ configure_netdata # Store the app.src file cp ../conf/app.src /opt/netdata/etc/netdata +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=1 + +# Create a dedicated nginx config +ynh_add_nginx_config + +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=7 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # GENERIC FINALIZATION +#================================================= + #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1 # Make app public if necessary if [[ $is_public -eq 1 ]]; then @@ -123,8 +142,22 @@ if [[ $is_public -eq 1 ]]; then ynh_permission_update --permission "main" --add "visitors" fi +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="restart" --log_path="/opt/$app/var/log/$app/error.log" + #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading nginx web server..." --weight=1 -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --last From 4076fa25cfdae328056ec6cac9dc58319f810ddd Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Wed, 13 May 2020 16:00:07 +0200 Subject: [PATCH 2/8] Refactor to latest package guidelines --- conf/nginx.conf | 14 +++--- scripts/_common.sh | 29 +++++------ scripts/backup | 42 ++++++++++++++-- scripts/change_url | 96 +++++++++++++++++++++--------------- scripts/install | 79 ++++++++++++++++++++---------- scripts/remove | 40 ++++++++++++--- scripts/restore | 71 ++++++++++++++++++++------- scripts/upgrade | 119 +++++++++++++++++++++++++++++---------------- 8 files changed, 332 insertions(+), 158 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index fde6590..9241df9 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,8 +1,10 @@ -#for-subdir location __PATH__ { -#for-subdir return 301 __PATH__/; -#for-subdir } +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location ~ __PATH__/(?.*) { + # Force usage of https + if ($scheme = http) { + rewrite ^ https://$server_name$request_uri? permanent; + } proxy_redirect off; proxy_set_header Host $host; @@ -19,7 +21,7 @@ location ~ __PATH__/(?.*) { gzip on; gzip_proxied any; gzip_types *; - - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; } diff --git a/scripts/_common.sh b/scripts/_common.sh index 2edd312..5cda5f3 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,9 +1,16 @@ #!/bin/bash -# -# Common variables -# +#================================================= +# COMMON VARIABLES +#================================================= + +# 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 python-mysqldb libipmimonitoring-dev acl python-psycopg2 python-pymongo libuv1-dev liblz4-dev libjudy-dev libssl-dev cmake" + +#================================================= +# PERSONAL HELPERS +#================================================= + # Configure NetData configure_netdata() { @@ -13,9 +20,9 @@ configure_netdata() { s@# registry to announce = https://registry.my-netdata.io@registry to announce = https://$domain$path_url@ }" /opt/netdata/etc/netdata/netdata.conf -# Opt-out from sending anonymous statistics -# (see https://docs.netdata.cloud/docs/anonymous-statistics/#opt-out) -touch /opt/netdata/etc/netdata/.opt-out-from-anonymous-statistics + # Opt-out from sending anonymous statistics + # (see https://docs.netdata.cloud/docs/anonymous-statistics/#opt-out) + touch /opt/netdata/etc/netdata/.opt-out-from-anonymous-statistics # Add a web_log entry for every YunoHost domain netdata_add_yunohost_web_logs @@ -24,9 +31,9 @@ touch /opt/netdata/etc/netdata/.opt-out-from-anonymous-statistics netdata_add_yunohost_postgres_configuration # Create netdata user to monitor MySQL (if needed) - is_mysql_user_existing=$(ynh_mysql_execute_as_root "select user from mysql.user where user = 'netdata';") + is_mysql_user_existing=$(ynh_mysql_execute_as_root --sql="select user from mysql.user where user = 'netdata';") if [ -z "$is_mysql_user_existing" ] ; then - ynh_mysql_execute_as_root "create user 'netdata'@'localhost'; + ynh_mysql_execute_as_root --sql="create user 'netdata'@'localhost'; grant usage on *.* to 'netdata'@'localhost' with grant option; flush privileges;" fi @@ -46,12 +53,6 @@ touch /opt/netdata/etc/netdata/.opt-out-from-anonymous-statistics # Add netdata to the adm group to access web logs usermod -a -G adm netdata - - # Declare service for YunoHost monitoring - yunohost service add netdata --log "/opt/netdata/var/log/netdata/error.log" "/opt/netdata/var/log/netdata/access.log" "/opt/netdata/var/log/netdata/debug.log" - - # Restart NetData - systemctl restart netdata } # Add a web_log entry for every YunoHost domain diff --git a/scripts/backup b/scripts/backup index 4674860..366d169 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -13,28 +14,59 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} # 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" domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= # STANDARD BACKUP STEPS #================================================= -# BACKUP THE APP CONFIGURATION +# STOP SYSTEMD SERVICE #================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 -# Backup configuration files -ynh_backup "/opt/netdata/etc/netdata" +ynh_systemd_action --service_name=$app --action="stop" --log_path="/opt/$app/var/log/$app/error.log" + +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Backing up Netdata configuration directory..." --weight=1 + +ynh_backup --src_path="/opt/netdata/etc/netdata" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Backing up nginx web server configuration..." --weight=1 -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# SPECIFIC BACKUP +#================================================= + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="/opt/$app/var/log/$app/error.log" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last diff --git a/scripts/change_url b/scripts/change_url index 8efef37..1ff246a 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,15 +24,27 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 + +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= -# CHECK PATHS SYNTAX +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --time --weight=1 -test -n "$old_path" || old_path="/" -test -n "$new_path" || new_path="/" -new_path=$(ynh_normalize_url_path $new_path) -old_path=$(ynh_normalize_url_path $old_path) +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # 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 @@ -53,60 +65,66 @@ fi #================================================= # STANDARD MODIFICATIONS #================================================= -# MODIFY URL IN NGINX CONF FILE +# 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" + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +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 "$nginx_conf_path" - ynh_replace_string "location $old_path {" "location $new_path {" "$nginx_conf_path" - if [ "$new_path" = "/" ] && [ "$old_path" != "/" ] ; then - ynh_replace_string "location ~ $old_path" "location ~ " "$nginx_conf_path" - ynh_replace_string "return 301 $old_path/" "return 301 /" "$nginx_conf_path" - - # Move #for-subdir comment at the beginning of the line (line not needed for "/" path) - ynh_replace_string "\(.*\) #for-subdir" "#for-subdir \1" "$nginx_conf_path" - elif [ "$new_path" != "/" ] && [ "$old_path" = "/" ] ; then - # Move #for-subdir comment at the end of the line (line needed for "/path" path) - ynh_replace_string "#for-subdir\(.*\)" "\1 #for-subdir" "$nginx_conf_path" - - # Replace path in several location occurrences based on different recognition patterns - ynh_replace_string "location ~ " "location ~ $new_path" "$nginx_conf_path" - ynh_replace_string "return 301 /" "return 301 $new_path/" "$nginx_conf_path" - else - ynh_replace_string "location ~ $old_path" "location ~ $new_path" "$nginx_conf_path" - ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path" - fi - # Calculate and store the nginx config file checksum - ynh_store_file_checksum "$nginx_conf_path" - - # Change registry link - ynh_replace_string "registry to announce = https://$old_domain$old_path" "registry to announce = https://$new_domain$new_path" /opt/netdata/etc/netdata/netdata.conf - systemctl restart netdata + # 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 "$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 "/etc/nginx/conf.d/$new_domain.d/$app.conf" + # 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 #================================================= # SPECIFIC MODIFICATIONS #================================================= +# Change registry link +ynh_replace_string --match_string="registry to announce = https://$old_domain$old_path" --replace_string="registry to announce = https://$new_domain$new_path" --target_file="/opt/netdata/etc/netdata/netdata.conf" + #================================================= -# GENERIC FINALIZATION +# GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="restart" --log_path="/opt/$app/var/log/$app/error.log" + #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading nginx web server..." --weight=1 -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index 9003a7e..5f0524e 100644 --- a/scripts/install +++ b/scripts/install @@ -13,6 +13,10 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -31,54 +35,55 @@ app=$YNH_APP_INSTANCE_NAME # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) +ynh_script_progression --message="Validating installation parameters..." --weight=1 + +final_path=/opt/$app +test ! -e "$final_path" || ynh_die --message="This path already contains a folder" -# Check web path availability -ynh_webpath_available $domain $path_url # Register (book) web path -ynh_webpath_register $app $domain $path_url +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_script_progression --message="Storing installation settings..." --weight=1 -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path_url -ynh_app_setting_set $app admin $admin -ynh_app_setting_set $app is_public $is_public +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 +#================================================= + #================================================= # INSTALL DEPENDENCIES #================================================= +ynh_script_progression --message="Installing dependencies..." --weight=32 ynh_install_app_dependencies $pkg_dependencies #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Setting up source files..." --weight=11 +### `ynh_setup_source` is used to install an app from a zip or tar.gz file, +### downloaded from an upstream source, like a git repository. +### `ynh_setup_source` use the file conf/app.src + +ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src NETDATA_TMPDIR=$(mktemp -d) -ynh_setup_source "$NETDATA_TMPDIR" +ynh_setup_source --dest_dir="$NETDATA_TMPDIR" #================================================= # NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Configuring nginx web server..." --weight=2 -nginx_conf="../conf/nginx.conf" -if [ "$path_url" = "/" ] -then - # Handle root path, avoid double slash. - # Temporary fix, in waiting for an upgrade of the helper. (#361) - path_url_slash_less=${path_url%/} - ynh_replace_string "__PATH__/" "$path_url_slash_less/" $nginx_conf -else - # Move prefix comment #for-subdir at end of lines - ynh_replace_string "#for-subdir\(.*\)" "\1 #for-subdir" $nginx_conf -fi +### `ynh_add_nginx_config` will use the file conf/nginx.conf # Create a dedicated nginx config ynh_add_nginx_config @@ -87,10 +92,7 @@ ynh_add_nginx_config # SPECIFIC SETUP #================================================= -#================================================= -# INSTALL AND CONFIGURE NETDATA -#================================================= - +ynh_script_progression --message="Executing Netdata installer..." --weight=180 # Launch netdata installation in /opt directory pushd $NETDATA_TMPDIR ./netdata-installer.sh --install /opt --dont-wait @@ -101,13 +103,30 @@ configure_netdata popd cp ../conf/app.src /opt/netdata/etc/netdata + #================================================= # GENERIC FINALIZATION #================================================= +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= + +yunohost service add $app --description "Real-time performance and health monitoring for systems and applications" --log "/opt/netdata/var/log/netdata/error.log" "/opt/netdata/var/log/netdata/access.log" "/opt/netdata/var/log/netdata/debug.log" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=2 + +# Start a systemd service +ynh_systemd_action --service_name=$app --action="restart" --log_path="/opt/$app/var/log/$app/error.log" + + #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Configuring SSOwat..." --weight=1 # Make app public if necessary if [ $is_public -eq 1 ]; then @@ -119,8 +138,16 @@ fi # Add direct access in the portal to admin only ynh_permission_update --permission "main" --add "$admin" + #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading nginx web server..." --weight=1 -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 48648e9..f24a216 100644 --- a/scripts/remove +++ b/scripts/remove @@ -6,30 +6,44 @@ # IMPORT GENERIC HELPERS #================================================= -# Source app helpers 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" domain) +domain=$(ynh_app_setting_get --app=$app --key=domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE +#================================================= +# REMOVE SERVICE INTEGRATION IN YUNOHOST +#================================================= + +# 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 +then + ynh_script_progression --message="Removing $app service..." --weight=2 + yunohost service remove $app +fi + #================================================= # REMOVE DEPENDENCIES #================================================= +ynh_script_progression --message="Removing dependencies..." --weight=8 # Remove metapackage and its dependencies ynh_remove_app_dependencies #================================================= -# REMOVE APP +# REMOVE APP MAIN DIR #================================================= +ynh_script_progression --message="Uninstalling Netdata..." --weight=6 # Prepare to execute uninstaller(generated by NetData install script) UNINSTALL_SCRIPT="netdata-uninstaller.sh" @@ -44,14 +58,26 @@ cd /tmp ./${UNINSTALL_SCRIPT} --yes --force --env /opt/netdata/etc/netdata/.environment # Remove MySQL netdata user - ynh_mysql_execute_as_root "drop user 'netdata'@'localhost'; flush privileges;" - -# Remove services from YunoHost monitoring - yunohost service remove netdata +ynh_mysql_execute_as_root "drop user 'netdata'@'localhost'; flush privileges;" #================================================= # REMOVE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Removing nginx web server configuration..." --weight=1 # Remove the dedicated nginx config ynh_remove_nginx_config + +#================================================= +# SPECIFIC REMOVE +#================================================= + +#================================================= +# GENERIC FINALIZATION +#================================================= + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 4b6ec37..45c202a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -13,24 +14,33 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + #### Remove this function if there's nothing to clean before calling the remove script. + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) +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) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= +ynh_script_progression --message="Validating restoration parameters..." --weight=1 -ynh_webpath_available $domain $path_url \ - || ynh_die "Path not available: ${domain}${path_url}" +ynh_webpath_available --domain=$domain --path_url=$path_url \ + || ynh_die --message="Path not available: ${domain}${path_url}" +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS @@ -38,21 +48,30 @@ ynh_webpath_available $domain $path_url \ # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# INSTALL DEPENDENCIES +# RESTORE THE APP MAIN DIR #================================================= +ynh_script_progression --message="Restoring Netdata configuration directory..." --weight=1 +ynh_restore_file --origin_path="/opt/netdata/etc/netdata" + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=7 + +# Define and install dependencies ynh_install_app_dependencies $pkg_dependencies #================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE +# INSTALL AND RESTORE THE APP CONFIGURATION #================================================= -# Restore configuration files -ynh_restore_file "/opt/netdata/etc/netdata" - +ynh_script_progression --message="Reinstalling Netdata..." --weight=180 # Restore permissions to app files chown -R root: "/opt/netdata/etc/netdata" @@ -64,10 +83,6 @@ cp /opt/netdata/etc/netdata/app.src ../conf NETDATA_TMPDIR=$(mktemp -d) ynh_setup_source "$NETDATA_TMPDIR" -#================================================= -# INSTALL AND RESTORE THE APP CONFIGURATION -#================================================= - # Launch netdata installation in /opt directory cd $NETDATA_TMPDIR ./netdata-installer.sh --install /opt --dont-wait @@ -75,9 +90,29 @@ cd $NETDATA_TMPDIR configure_netdata #================================================= -# GENERIC FINALISATION -#================================================= -# RELOAD NGINX AND PHP-FPM +# INTEGRATE SERVICE IN YUNOHOST #================================================= -systemctl reload nginx +yunohost service add $app --description "A short description of the app" --log "/opt/netdata/var/log/netdata/error.log" "/opt/netdata/var/log/netdata/access.log" "/opt/netdata/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="/opt/$app/var/log/$app/error.log" + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index bfcd2e2..2a5356a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,63 +12,68 @@ 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 domain) -path_url=$(ynh_app_setting_get $app path) -is_public=$(ynh_app_setting_get $app is_public) +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) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#================================================= +# CHECK VERSION +#================================================= + +upgrade_type=$(ynh_check_app_version_changed) + +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +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 final_path doesn't exist, create it +if [ -z "$final_path" ]; then + final_path=/var/www/$app + ynh_app_setting_set --app=$app --key=final_path --value=$final_path +fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3 -ynh_backup_before_upgrade # Backup the current version of the app +# Backup the current version of the app +ynh_backup_before_upgrade ynh_clean_setup () { - ynh_restore_upgradebackup # restore it if the upgrade fails + # restore it if the upgrade fails + ynh_restore_upgradebackup } -ynh_abort_if_errors # Active trap to stop script execution if an error occurs - -#================================================= -# CHECK THE PATH -#================================================= - -# Normalize the URL path syntax -path_url=$(ynh_normalize_url_path $path_url) +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS #================================================= + #================================================= -# NGINX CONFIGURATION +# DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -nginx_conf="../conf/nginx.conf" -if [ "$path_url" = "/" ] +if [ "$upgrade_type" == "UPGRADE_APP" ] then - # Handle root path, avoid double slash. - # Temporary fix, in waiting for an upgrade of the helper. (#361) - path_url_slash_less=${path_url%/} - ynh_replace_string "__PATH__/" "$path_url_slash_less/" $nginx_conf -else - # Move prefix comment #for-subdir at end of lines - ynh_replace_string "#for-subdir\(.*\)" "\1 #for-subdir" $nginx_conf -fi + ynh_script_progression --message="Upgrading source files..." --weight=180 -# Create a dedicated nginx config -ynh_add_nginx_config - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= - -ynh_install_app_dependencies $pkg_dependencies - -installed_version=$(cat /opt/netdata/etc/netdata/app.src | grep SOURCE_URL | sed "s|.*/v\(.*\)/.*|\1|g") -version_to_install=$(cat ../conf/app.src | grep SOURCE_URL | sed "s|.*/v\(.*\)/.*|\1|g") - -if [ "$installed_version" != "$version_to_install" ] ; then #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -93,12 +98,8 @@ if [ "$installed_version" != "$version_to_install" ] ; then # Launch netdata installation in /opt directory pushd $NETDATA_TMPDIR - # Remove previous service definition (specific 1.8.0 upgrade) - rm -f /etc/systemd/system/netdata.service - ./netdata-installer.sh --install /opt --dont-wait >&3 2>&3 || ynh_die "FAILED TO COMPILE/INSTALL NETDATA" - - popd + popd # close fd 3 exec 3<&- @@ -110,11 +111,29 @@ configure_netdata # Store the app.src file cp ../conf/app.src /opt/netdata/etc/netdata +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=1 + +# Create a dedicated nginx config +ynh_add_nginx_config + +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=7 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # GENERIC FINALIZATION +#================================================= + #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1 # Make app public if necessary if [[ $is_public -eq 1 ]]; then @@ -123,8 +142,22 @@ if [[ $is_public -eq 1 ]]; then ynh_permission_update --permission "main" --add "visitors" fi +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="restart" --log_path="/opt/$app/var/log/$app/error.log" + #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading nginx web server..." --weight=1 -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --last From 1821e7b138ac662ca5e3956de0fd87bcc8defe66 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Sat, 16 May 2020 14:20:04 +0200 Subject: [PATCH 3/8] Misc fixes --- scripts/_common.sh | 12 ++++++------ scripts/backup | 10 +++++----- scripts/change_url | 3 +-- scripts/install | 31 ++++++++++++++----------------- scripts/remove | 10 +++++++++- scripts/restore | 12 +++--------- scripts/upgrade | 14 +++++++++----- 7 files changed, 47 insertions(+), 45 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 5cda5f3..56fa45b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -18,11 +18,11 @@ configure_netdata() { sed -i "/^\[registry\]$/,/^\[/ { s/# enabled = no/enabled = yes/ s@# registry to announce = https://registry.my-netdata.io@registry to announce = https://$domain$path_url@ - }" /opt/netdata/etc/netdata/netdata.conf + }" $final_path/etc/netdata/netdata.conf # Opt-out from sending anonymous statistics # (see https://docs.netdata.cloud/docs/anonymous-statistics/#opt-out) - touch /opt/netdata/etc/netdata/.opt-out-from-anonymous-statistics + touch $final_path/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="/opt/netdata/etc/netdata/python.d/web_log.conf" + local web_log_file="$final_path/etc/netdata/python.d/web_log.conf" if [ ! -f $web_log_file ] ; then - cp /opt/netdata/etc/netdata/orig/python.d/web_log.conf $web_log_file + cp $final_path/etc/netdata/orig/python.d/web_log.conf $web_log_file fi if [ -z "$(grep "YUNOHOST" $web_log_file)" ] ; then echo "# ------------YUNOHOST DOMAINS---------------" >> $web_log_file @@ -78,9 +78,9 @@ EOF # If PostgreSQL is installed, add a PostgreSQL entry using instance password netdata_add_yunohost_postgres_configuration () { - local postgres_file="/opt/netdata/etc/netdata/python.d/postgres.conf" + local postgres_file="$final_path/etc/netdata/python.d/postgres.conf" if [ ! -f $postgres_file ] ; then - cp /opt/netdata/etc/netdata/orig/python.d/postgres.conf $postgres_file + cp $final_path/etc/netdata/orig/python.d/postgres.conf $postgres_file fi if [ -f /etc/yunohost/psql ] && [ -z "$(grep "yunohost:" $postgres_file)" ] ; then cat >> $postgres_file <${tmp} + # Launch netdata installation in /opt directory pushd $NETDATA_TMPDIR -./netdata-installer.sh --install /opt --dont-wait - -configure_netdata - -# Store the app.src file +./netdata-installer.sh --install /opt --dont-wait >&3 2>&3 || ynh_die "FAILED TO COMPILE/INSTALL NETDATA" popd -cp ../conf/app.src /opt/netdata/etc/netdata +# close fd 3 +exec 3<&- + +# Specific configuration +configure_netdata #================================================= # GENERIC FINALIZATION @@ -121,7 +118,7 @@ cp ../conf/app.src /opt/netdata/etc/netdata # INTEGRATE SERVICE IN YUNOHOST #================================================= -yunohost service add $app --description "Real-time performance and health monitoring for systems and applications" --log "/opt/netdata/var/log/netdata/error.log" "/opt/netdata/var/log/netdata/access.log" "/opt/netdata/var/log/netdata/debug.log" +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" #================================================= # START SYSTEMD SERVICE @@ -129,7 +126,7 @@ yunohost service add $app --description "Real-time performance and health monito ynh_script_progression --message="Starting a systemd service..." --weight=2 # Start a systemd service -ynh_systemd_action --service_name=$app --action="restart" --log_path="/opt/$app/var/log/$app/error.log" +ynh_systemd_action --service_name=$app --action="restart" --log_path="$final_path/var/log/$app/error.log" #================================================= diff --git a/scripts/remove b/scripts/remove index f24a216..23af483 100644 --- a/scripts/remove +++ b/scripts/remove @@ -54,8 +54,16 @@ chmod +x /tmp/$UNINSTALL_SCRIPT # Move outside the directory (which will be removed) cd /tmp +# create a temporary file for the log +tmp=$(mktemp /tmp/netdata-uninstaller-log-XXXXXX.log) +# open fd 3 and send it to tmp +exec 3>${tmp} + # Execute the uninstall script -./${UNINSTALL_SCRIPT} --yes --force --env /opt/netdata/etc/netdata/.environment +./${UNINSTALL_SCRIPT} --yes --force --env $final_path/etc/netdata/.environment >&3 2>&3 + +# close fd 3 +exec 3<&- # Remove MySQL netdata user ynh_mysql_execute_as_root "drop user 'netdata'@'localhost'; flush privileges;" diff --git a/scripts/restore b/scripts/restore index 45c202a..a851615 100644 --- a/scripts/restore +++ b/scripts/restore @@ -55,7 +55,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_script_progression --message="Restoring Netdata configuration directory..." --weight=1 -ynh_restore_file --origin_path="/opt/netdata/etc/netdata" +ynh_restore_file --origin_path="$final_path/etc/netdata" #================================================= # SPECIFIC RESTORATION @@ -72,12 +72,6 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= ynh_script_progression --message="Reinstalling Netdata..." --weight=180 -# Restore permissions to app files -chown -R root: "/opt/netdata/etc/netdata" - -# Retrieve app.src from archive for ynh_setup_source helper -mkdir ../conf -cp /opt/netdata/etc/netdata/app.src ../conf # Download, check integrity, uncompress and patch the source from app.src NETDATA_TMPDIR=$(mktemp -d) @@ -93,14 +87,14 @@ configure_netdata # INTEGRATE SERVICE IN YUNOHOST #================================================= -yunohost service add $app --description "A short description of the app" --log "/opt/netdata/var/log/netdata/error.log" "/opt/netdata/var/log/netdata/access.log" "/opt/netdata/var/log/netdata/debug.log" +yunohost service add $app --description "A short description of the app" --log "$final_path/var/log/netdata/error.log" "$final_path/var/log/netdata/access.log" "$final_path/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="/opt/$app/var/log/$app/error.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/var/log/$app/error.log" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 2a5356a..37d9275 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -44,7 +44,7 @@ fi # If final_path doesn't exist, create it if [ -z "$final_path" ]; then - final_path=/var/www/$app + final_path=/opt/$app ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi @@ -62,6 +62,13 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# CHECK THE PATH +#================================================= + +# Normalize the URL path syntax +path_url=$(ynh_normalize_url_path --path_url=$path_url) + #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -108,9 +115,6 @@ fi # Specific configuration configure_netdata -# Store the app.src file -cp ../conf/app.src /opt/netdata/etc/netdata - #================================================= # NGINX CONFIGURATION #================================================= @@ -147,7 +151,7 @@ fi #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="restart" --log_path="/opt/$app/var/log/$app/error.log" +ynh_systemd_action --service_name=$app --action="restart" --log_path="$final_path/var/log/$app/error.log" #================================================= # RELOAD NGINX From 367693c98d09c300c00227138d08fc4df94f5948 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Sat, 16 May 2020 14:20:57 +0200 Subject: [PATCH 4/8] Bump package version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index c84e5d5..2d38cc3 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "real-time performance and health monitoring", "fr": "Monitoring serveur en temps reel" }, - "version": "1.22.1~ynh1", + "version": "1.22.1~ynh2", "url": "http://my-netdata.io/", "license": "GPL-3.0", "maintainer": { From 736009bb828e1cdc07d5440b1dc6b1fbacd6f126 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Tue, 4 Aug 2020 20:20:29 +0200 Subject: [PATCH 5/8] Fix upgrade edge case --- scripts/upgrade | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 37d9275..d4e7372 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -48,6 +48,13 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi +# If final_path 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 +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= From b30eafd9e8cd8221a713be52075bb53608ad5550 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Tue, 4 Aug 2020 20:20:41 +0200 Subject: [PATCH 6/8] Minor backup/restore changes --- scripts/backup | 19 ++++++++++++++----- scripts/restore | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/scripts/backup b/scripts/backup index f0af6cd..9440f6f 100644 --- a/scripts/backup +++ b/scripts/backup @@ -33,24 +33,33 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= # STANDARD BACKUP STEPS +#================================================= + +ynh_print_info --message="Declaring files to be backed up..." + +# N.B.: the following 'ynh_backup' calls are only a *declaration* of what needs +# to be backuped and not an actual copy of any file. The actual backup that +# creates and fill the archive with the files happens in the core after this +# script is called. Hence ynh_backups calls takes basically 0 seconds to run + #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=2 +ynh_print_info --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="$final_path/var/log/$app/error.log" #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_script_progression --message="Backing up Netdata configuration directory..." --weight=1 +ynh_print_info --message="Backing up Netdata configuration directory..." ynh_backup --src_path="$final_path/etc/netdata" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Backing up nginx web server configuration..." --weight=1 +ynh_print_info --message="Backing up nginx web server configuration..." ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -61,7 +70,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=2 +ynh_print_info --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/var/log/$app/error.log" @@ -69,4 +78,4 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/ # END OF SCRIPT #================================================= -ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/restore b/scripts/restore index a851615..3e55786 100644 --- a/scripts/restore +++ b/scripts/restore @@ -24,7 +24,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME From a2aa891c2e8e2f847cfd672f56030f8c74dfca0d Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Tue, 4 Aug 2020 20:21:06 +0200 Subject: [PATCH 7/8] Upgrade to upstream version 1.23.2 --- README.md | 2 +- conf/app.src | 4 ++-- manifest.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 897f0bf..0e21c94 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ _netdata is **fast** and **efficient**, designed to permanently run on all syste (**physical** & **virtual** servers, **containers**, **IoT** devices), without disrupting their core function._ -**Shipped version:** 1.22.1 +**Shipped version:** 1.23.2 **Customization brought by the package:** diff --git a/conf/app.src b/conf/app.src index 86963b8..147e919 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,3 +1,3 @@ -SOURCE_URL=https://github.com/netdata/netdata/releases/download/v1.22.1/netdata-v1.22.1.tar.gz -SOURCE_SUM=f169c8615a6823448c2f1923c87c286d798132ea29d26f366e96d26e0aec3697 +SOURCE_URL=https://github.com/netdata/netdata/releases/download/v1.23.2/netdata-v1.23.2.tar.gz +SOURCE_SUM=761aec15901e09f963361752c6e5b5cb723e342a3c5bf6b0624067fceb2ccdfd SOURCE_FORMAT=tar.gz diff --git a/manifest.json b/manifest.json index 2d38cc3..903d76a 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "real-time performance and health monitoring", "fr": "Monitoring serveur en temps reel" }, - "version": "1.22.1~ynh2", + "version": "1.23.2~ynh1", "url": "http://my-netdata.io/", "license": "GPL-3.0", "maintainer": { From d75af1f5ecfbde05fdfd72f761e545bca8a30bdf Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Sun, 15 Nov 2020 15:10:09 +0100 Subject: [PATCH 8/8] Upgrade to upstream version 1.26.0 & disable NetData Cloud --- CHANGELOG.md | 5 +++++ README.md | 3 ++- conf/app.src | 4 ++-- manifest.json | 2 +- scripts/install | 2 +- scripts/upgrade | 2 +- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6950104..f1169bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ Changelog ## Unreleased - Nothing for now... +## [1.26.0~ynh1](https://github.com/YunoHost-Apps/netdata_ynh/pull/50) - 2020-11-15 + +#### Changed +* [Update to 1.26.0](https://github.com/YunoHost-Apps/netdata_ynh/pull/50) + ## [1.22.1~ynh1](https://github.com/YunoHost-Apps/netdata_ynh/pull/48) - 2020-05-13 #### Changed diff --git a/README.md b/README.md index 0e21c94..273261f 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,11 @@ _netdata is **fast** and **efficient**, designed to permanently run on all syste (**physical** & **virtual** servers, **containers**, **IoT** devices), without disrupting their core function._ -**Shipped version:** 1.23.2 +**Shipped version:** 1.26.0 **Customization brought by the package:** +* Netdata Cloud functionality disabled * grant MySQL statistics access via a `netdata` user * nginx root log statistics via putting `netdata` user in the `adm` group * Dovecot statistics via giving access to Dovecot stats stocket to `netdata` user (works only with Dovecot 2.2.16+) diff --git a/conf/app.src b/conf/app.src index 147e919..b7a7af3 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,3 +1,3 @@ -SOURCE_URL=https://github.com/netdata/netdata/releases/download/v1.23.2/netdata-v1.23.2.tar.gz -SOURCE_SUM=761aec15901e09f963361752c6e5b5cb723e342a3c5bf6b0624067fceb2ccdfd +SOURCE_URL=https://github.com/netdata/netdata/releases/download/v1.26.0/netdata-v1.26.0.tar.gz +SOURCE_SUM=33af27eb57f954e50059a32bec624815aa742fe03182845b1d9b577f1e20e30a SOURCE_FORMAT=tar.gz diff --git a/manifest.json b/manifest.json index 903d76a..5953763 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "real-time performance and health monitoring", "fr": "Monitoring serveur en temps reel" }, - "version": "1.23.2~ynh1", + "version": "1.26.0~ynh1", "url": "http://my-netdata.io/", "license": "GPL-3.0", "maintainer": { diff --git a/scripts/install b/scripts/install index 8e2ed64..0f7d350 100644 --- a/scripts/install +++ b/scripts/install @@ -101,7 +101,7 @@ exec 3>${tmp} # Launch netdata installation in /opt directory pushd $NETDATA_TMPDIR -./netdata-installer.sh --install /opt --dont-wait >&3 2>&3 || ynh_die "FAILED TO COMPILE/INSTALL NETDATA" +./netdata-installer.sh --install /opt --dont-wait --disable-cloud >&3 2>&3 || ynh_die "FAILED TO COMPILE/INSTALL NETDATA" popd # close fd 3 diff --git a/scripts/upgrade b/scripts/upgrade index d4e7372..b6ad8ee 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -112,7 +112,7 @@ then # Launch netdata installation in /opt directory pushd $NETDATA_TMPDIR - ./netdata-installer.sh --install /opt --dont-wait >&3 2>&3 || ynh_die "FAILED TO COMPILE/INSTALL NETDATA" + ./netdata-installer.sh --install /opt --dont-wait --disable-cloud >&3 2>&3 || ynh_die "FAILED TO COMPILE/INSTALL NETDATA" popd # close fd 3