2021-05-18 18:17:45 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=3
|
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2024-01-03 22:02:22 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2021-05-18 18:17:45 +02:00
|
|
|
|
2024-01-03 22:02:22 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:$app "$install_dir"
|
2021-05-18 18:17:45 +02:00
|
|
|
|
|
|
|
log_path="/var/log/$app"
|
|
|
|
mkdir -p "$log_path"
|
|
|
|
touch "$log_path/$app.log"
|
|
|
|
chmod 750 "$log_path"
|
|
|
|
chmod -R o-rwx "$log_path"
|
|
|
|
chown -R $app:$app "$log_path"
|
|
|
|
|
|
|
|
#=================================================
|
2024-01-03 22:02:22 +01:00
|
|
|
# ADD A CONFIGURATION
|
2021-05-18 18:17:45 +02:00
|
|
|
#=================================================
|
2024-01-03 22:02:22 +01:00
|
|
|
ynh_script_progression --message="Configuring the app..." --weight=2
|
2021-05-18 18:17:45 +02:00
|
|
|
|
2024-01-03 22:02:22 +01:00
|
|
|
ynh_replace_string --match_string="localhost:9090" --replace_string="localhost:$port" --target_file="$install_dir/prometheus.yml"
|
|
|
|
echo " metrics_path: $path/metrics" >> "$install_dir/prometheus.yml"
|
2021-05-18 18:17:45 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-01-03 22:02:22 +01:00
|
|
|
# SYSTEM CONFIGURATION
|
2021-05-18 18:17:45 +02:00
|
|
|
#=================================================
|
2024-01-03 22:02:22 +01:00
|
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2021-05-18 18:17:45 +02:00
|
|
|
|
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_add_systemd_config
|
2024-01-03 22:02:22 +01:00
|
|
|
yunohost service add "$app" --description="Prometheus daemon" --log="systemd"
|
2021-05-18 18:17:45 +02:00
|
|
|
|
|
|
|
# Use logrotate to manage application logfile(s)
|
|
|
|
ynh_use_logrotate
|
|
|
|
|
|
|
|
#=================================================
|
2024-01-03 22:02:22 +01:00
|
|
|
# GENERIC FINALIZATION
|
2021-05-18 18:17:45 +02:00
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2024-01-03 22:02:22 +01:00
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
2021-05-18 18:17:45 +02:00
|
|
|
|
|
|
|
# Start a systemd service
|
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started Prometheus daemon" --timeout=30
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|