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

Misc fixes

This commit is contained in:
Jimmy Monin 2020-05-16 14:20:04 +02:00
parent 89e3cb3d7d
commit 1821e7b138
7 changed files with 47 additions and 45 deletions

View file

@ -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 <<EOF

View file

@ -36,16 +36,16 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_script_progression --message="Stopping a systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action="stop" --log_path="/opt/$app/var/log/$app/error.log"
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_backup --src_path="/opt/netdata/etc/netdata"
ynh_backup --src_path="$final_path/etc/netdata"
#=================================================
# BACKUP THE NGINX CONFIGURATION
@ -61,9 +61,9 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression --message="Starting a systemd service..." --weight=2
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"
#=================================================
# END OF SCRIPT

View file

@ -26,7 +26,6 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
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)
#=================================================
@ -114,7 +113,7 @@ ynh_replace_string --match_string="registry to announce = https://$old_domain$ol
#=================================================
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

View file

@ -34,15 +34,6 @@ 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
ynh_script_progression --message="Validating installation parameters..." --weight=1
@ -102,16 +93,22 @@ ynh_add_nginx_config
#=================================================
ynh_script_progression --message="Executing Netdata installer..." --weight=180
# create a temporary file for the log
tmp=$(mktemp /tmp/netdata-updater-log-XXXXXX.log)
# open fd 3 and send it to tmp
exec 3>${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"
#=================================================

View file

@ -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;"

View file

@ -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

View file

@ -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