2017-01-05 23:37:07 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-01-31 16:07:43 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
2023-12-09 00:35:51 +01:00
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2018-01-31 16:07:43 +01:00
|
|
|
|
2023-12-09 00:35:51 +01:00
|
|
|
source _common.sh
|
2024-04-04 00:28:32 +02:00
|
|
|
source experimental_helper.sh
|
2017-07-21 22:11:45 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2024-04-04 00:28:32 +02:00
|
|
|
load_vars
|
|
|
|
|
|
|
|
ensure_vars_set
|
2017-07-21 22:11:45 +02:00
|
|
|
|
2023-12-09 00:35:51 +01:00
|
|
|
#=================================================
|
2024-04-04 00:28:32 +02:00
|
|
|
# Check datadir empty
|
2023-12-09 00:35:51 +01:00
|
|
|
#=================================================
|
2017-01-05 23:37:07 +01:00
|
|
|
|
2024-04-04 00:28:32 +02:00
|
|
|
if [ -n "$(ls -A $data_dir)" ]; then
|
|
|
|
old_data_dir_path="${data_dir}_$(date '+%Y%m%d.%H%M%S')"
|
|
|
|
ynh_print_warn --message="Data directory was not empty. Data was moved to $old_data_dir_path"
|
|
|
|
mkdir -p $old_data_dir_path
|
|
|
|
mv -t "$old_data_dir_path" "$data_dir"/*
|
|
|
|
app_data_dirs="$(echo /home/yunohost.app/*)"
|
2022-11-02 23:07:44 +01:00
|
|
|
fi
|
|
|
|
|
2018-01-31 16:07:43 +01:00
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
#=================================================
|
2023-12-09 00:35:51 +01:00
|
|
|
ynh_script_progression --message="Installing packages..." --weight=1
|
2018-01-31 16:07:43 +01:00
|
|
|
|
2017-10-31 23:08:23 +01:00
|
|
|
# Download package and install it
|
2023-12-09 00:35:51 +01:00
|
|
|
install_monitorix_package
|
|
|
|
|
2024-04-04 00:28:32 +02:00
|
|
|
ynh_systemd_action --service_name="$app" --action=stop --log_path=systemd --timeout=15
|
|
|
|
mkdir -p /var/log/new_"${app}"
|
|
|
|
mv -t /var/log/new_"${app}" /var/log/monitorix*
|
|
|
|
mv /var/log/new_"${app}" /var/log/"${app}"
|
2023-12-09 00:35:51 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SYSTEM CONFIGURATION
|
|
|
|
#=================================================ç
|
2024-04-04 00:28:32 +02:00
|
|
|
ynh_script_progression --message="Adding configurations related to $app..." --weight=1
|
2017-10-31 23:08:23 +01:00
|
|
|
|
2024-04-04 00:28:32 +02:00
|
|
|
ynh_add_jinja_config --template=monitorix.conf --destination="/etc/monitorix/monitorix.conf"
|
|
|
|
ynh_add_jinja_config --template=nginx_status.conf --destination "$nginx_status_conf"
|
2023-01-22 03:09:34 +01:00
|
|
|
|
2023-12-09 00:35:51 +01:00
|
|
|
ynh_add_nginx_config
|
2024-04-04 00:28:32 +02:00
|
|
|
ynh_add_systemd_config
|
2017-01-05 23:37:07 +01:00
|
|
|
|
2024-04-04 00:28:32 +02:00
|
|
|
yunohost service add "$app" --description=Monitorix --log=systemd
|
|
|
|
|
|
|
|
ynh_script_progression --message="Configuring databases access..."
|
|
|
|
configure_db
|
2017-01-05 23:37:07 +01:00
|
|
|
|
2024-04-04 00:28:32 +02:00
|
|
|
ynh_script_progression --message="Configuring php fpm access if needed..."
|
|
|
|
if "$phpfpm_installed"; then
|
|
|
|
config_php_fpm
|
|
|
|
fi
|
|
|
|
|
|
|
|
configure_hooks
|
|
|
|
configure_alerts_email
|
2017-01-05 23:37:07 +01:00
|
|
|
|
2018-04-30 21:41:07 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Protecting directory..."
|
2023-12-09 00:35:51 +01:00
|
|
|
|
2018-01-29 18:57:10 +01:00
|
|
|
set_permission
|
|
|
|
|
2024-04-04 00:28:32 +02:00
|
|
|
ynh_use_logrotate --logfile "/var/log/$app"
|
|
|
|
|
2023-12-09 00:35:51 +01:00
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
|
2024-04-04 00:28:32 +02:00
|
|
|
ynh_systemd_action --service_name="$app" --action="start" --log_path 'systemd' --line_match ' - Ok, ready.'
|
|
|
|
save_vars_current_value
|
2023-12-09 00:35:51 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2019-06-07 23:09:30 +02:00
|
|
|
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|