2023-03-03 10:07:36 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2024-08-31 02:59:01 +02:00
|
|
|
ynh_script_progression "Setting up source files..."
|
2023-03-03 10:07:36 +01:00
|
|
|
|
2023-03-06 21:25:34 +01:00
|
|
|
mkdir -p "$install_dir/bin"
|
2024-09-02 17:37:26 +02:00
|
|
|
ynh_setup_source --source_id="scrutiny-web-linux" --dest_dir="$install_dir/bin"
|
2024-02-26 09:09:27 +01:00
|
|
|
ynh_setup_source --source_id="scrutiny-collector-metrics-linux" --dest_dir="$install_dir/bin"
|
2024-02-25 13:50:54 +01:00
|
|
|
|
2023-03-06 21:25:34 +01:00
|
|
|
mkdir -p "$install_dir/web"
|
2024-02-25 17:47:04 +01:00
|
|
|
ynh_setup_source --source_id="scrutiny-web-frontend" --dest_dir="$install_dir/web"
|
2023-03-03 10:07:36 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SYSTEM CONFIGURATION
|
|
|
|
#=================================================
|
2024-08-31 02:59:01 +02:00
|
|
|
ynh_script_progression "Adding system configurations related to $app ..."
|
2023-03-03 10:07:36 +01:00
|
|
|
|
|
|
|
# Create a dedicated NGINX config using the conf/nginx.conf template
|
2024-08-31 02:59:01 +02:00
|
|
|
ynh_config_add_nginx
|
2023-03-03 10:07:36 +01:00
|
|
|
|
|
|
|
# Create a dedicated systemd config
|
2024-08-31 02:59:01 +02:00
|
|
|
ynh_config_add_systemd --service="scrutiny-web-server" --template="systemd-scrutiny-web-server.service"
|
2023-04-03 11:59:03 +02:00
|
|
|
yunohost service add "scrutiny-web-server" --description="WebUI for smartd S.M.A.R.T monitoring" --log="/var/log/$app/web-server.log" --test_status="systemctl show scrutiny-web-server.service -p ActiveState --value | grep -v failed"
|
2023-03-03 10:07:36 +01:00
|
|
|
|
2024-08-31 02:59:01 +02:00
|
|
|
ynh_config_add --template="systemd-scrutiny-collector.service" --destination="/etc/systemd/system/scrutiny-collector.service"
|
2023-03-07 22:33:13 +01:00
|
|
|
if [ $collector -eq 1 ]
|
|
|
|
then
|
2023-03-08 22:24:16 +01:00
|
|
|
yunohost service add "scrutiny-collector" --description="Collector running on timer (daily) for smartd S.M.A.R.T monitoring" --log="/var/log/$app/collector.log" --test_status="systemctl show scrutiny-collector.service -p ActiveState --value | grep -v failed"
|
2023-03-06 21:25:34 +01:00
|
|
|
fi
|
2023-03-03 10:07:36 +01:00
|
|
|
|
2023-03-06 21:25:34 +01:00
|
|
|
# Use logrotate to manage application logfile(s)
|
2024-08-31 02:59:01 +02:00
|
|
|
ynh_config_add_logrotate
|
2023-03-03 10:07:36 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# APP INITIAL CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
# ADD A CONFIGURATION
|
|
|
|
#=================================================
|
2024-08-31 02:59:01 +02:00
|
|
|
ynh_script_progression "Adding $app's configuration..."
|
2023-03-03 10:07:36 +01:00
|
|
|
|
2023-03-06 21:25:34 +01:00
|
|
|
mkdir -p "$install_dir/config"
|
2023-03-07 22:33:13 +01:00
|
|
|
if [ "${path}" == "/" ]
|
|
|
|
then
|
|
|
|
base_path=""
|
|
|
|
else
|
|
|
|
base_path="${path}"
|
|
|
|
fi
|
2024-08-31 02:59:01 +02:00
|
|
|
ynh_config_add --template="config/scrutiny.yaml" --destination="$install_dir/config/scrutiny.yaml"
|
2023-03-03 10:07:36 +01:00
|
|
|
|
2024-08-31 02:59:01 +02:00
|
|
|
ynh_config_add --template="systemd-scrutiny-collector.timer" --destination="/etc/systemd/system/scrutiny-collector.timer"
|
|
|
|
ynh_config_add --template="config/collector.yaml" --destination="$install_dir/config/collector.yaml"
|
2023-03-03 10:07:36 +01:00
|
|
|
|
2024-09-02 18:11:59 +02:00
|
|
|
#=================================================
|
|
|
|
# SET FILE OWNERSHIP / PERMISSIONS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
myynh_set_permissions
|
|
|
|
|
2023-03-03 10:07:36 +01:00
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2024-08-31 02:59:01 +02:00
|
|
|
ynh_script_progression "Starting $app's systemd service..."
|
|
|
|
ynh_systemctl --service="influxdb" --action="enable"
|
|
|
|
ynh_systemctl --service="influxdb" --action="start"
|
2023-04-03 09:08:54 +02:00
|
|
|
|
2024-08-31 02:59:01 +02:00
|
|
|
ynh_systemctl --service="scrutiny-web-server.service" --action="enable"
|
|
|
|
ynh_systemctl --service="scrutiny-web-server.service" --action="start" --log_path="/var/log/$app/web-server.log"
|
2023-04-03 09:08:54 +02:00
|
|
|
|
2023-03-07 22:33:13 +01:00
|
|
|
if [ $collector -eq 1 ]
|
|
|
|
then
|
2023-03-06 21:25:34 +01:00
|
|
|
systemctl daemon-reload
|
2024-08-31 02:59:01 +02:00
|
|
|
ynh_systemctl --service="scrutiny-collector.timer" --action="enable"
|
|
|
|
ynh_systemctl --service="scrutiny-collector.timer" --action="start" --log_path="/var/log/$app/collector.log"
|
2023-03-06 21:25:34 +01:00
|
|
|
fi
|
2023-03-03 10:07:36 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2024-08-31 02:59:01 +02:00
|
|
|
ynh_script_progression "Installation of $app completed"
|