1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/scrutiny_ynh.git synced 2024-09-03 20:16:24 +02:00
This commit is contained in:
ewilly 2023-03-07 22:33:13 +01:00
parent 4e8f401e7e
commit f560272439
14 changed files with 80 additions and 101 deletions

View file

@ -23,7 +23,6 @@ version: 1
host: host:
id: "yunohost" id: "yunohost"
# This block allows you to override/customize the settings for devices detected by # This block allows you to override/customize the settings for devices detected by
# Scrutiny via `smartctl --scan` # Scrutiny via `smartctl --scan`
# See the "--device=TYPE" section of https://linux.die.net/man/8/smartctl # See the "--device=TYPE" section of https://linux.die.net/man/8/smartctl
@ -62,16 +61,13 @@ devices:
# metrics_info_args: '--info --json -T permissive' # used to determine device unique ID & register device with Scrutiny # metrics_info_args: '--info --json -T permissive' # used to determine device unique ID & register device with Scrutiny
# metrics_smart_args: '--xall --json -T permissive' # used to retrieve smart data for each device. # metrics_smart_args: '--xall --json -T permissive' # used to retrieve smart data for each device.
log: log:
file: /var/log/__APP__/__APP__-collector.log file: /var/log/__APP__/collector.log
level: INFO level: INFO
#
api: api:
# endpoint: 'https://__DOMAIN____PATH__/' # endpoint: 'https://__DOMAIN____PATH__/'
endpoint: 'http://localhost:8080__PATH__/' endpoint: 'http://127.0.0.1:__PORT____PATH__/'
# endpoint: 'http://localhost:8080'
# endpoint: 'http://localhost:8080/custombasepath'
# if you need to use a custom base path (for a reverse proxy), you can add a suffix to the endpoint. # if you need to use a custom base path (for a reverse proxy), you can add a suffix to the endpoint.
# See docs/TROUBLESHOOTING_REVERSE_PROXY.md for more info, # See docs/TROUBLESHOOTING_REVERSE_PROXY.md for more info,
@ -97,4 +93,3 @@ api:
# short: # short:
# enable: false # enable: false
# command: '' # command: ''

View file

@ -28,7 +28,7 @@ web:
# see docs/TROUBLESHOOTING_REVERSE_PROXY.md # see docs/TROUBLESHOOTING_REVERSE_PROXY.md
# basepath: `/scrutiny` # basepath: `/scrutiny`
# leave empty unless behind a path prefixed proxy # leave empty unless behind a path prefixed proxy
basepath: '__PATH__' basepath: '__BASE_PATH__'
database: database:
# can also set absolute path here # can also set absolute path here
location: __INSTALL_DIR__/config/scrutiny.db location: __INSTALL_DIR__/config/scrutiny.db
@ -56,7 +56,7 @@ web:
# insecure_skip_verify: false # insecure_skip_verify: false
log: log:
file: /var/log/__APP__/__APP__-web-server.log file: /var/log/__APP__/web-server.log
level: INFO level: INFO
# Notification "urls" look like the following. For more information about service specific configuration see # Notification "urls" look like the following. For more information about service specific configuration see

View file

@ -4,6 +4,7 @@ After=network-online.target scrutiny-web-server.service
[Service] [Service]
Type=oneshot Type=oneshot
# Only root can fully execute smartcl features
User=root User=root
Group=root Group=root
WorkingDirectory=__INSTALL_DIR__ WorkingDirectory=__INSTALL_DIR__
@ -11,7 +12,7 @@ LogsDirectory=__APP__
StateDirectory=__APP__ StateDirectory=__APP__
ExecStart=__INSTALL_DIR__/bin/scrutiny-collector-metrics-linux-amd64 run --config __INSTALL_DIR__/config/collector.yaml ExecStart=__INSTALL_DIR__/bin/scrutiny-collector-metrics-linux-amd64 run --config __INSTALL_DIR__/config/collector.yaml
Restart=no Restart=no
StandardOutput=append:/var/log/__APP__/__APP__-collector.log StandardOutput=append:/var/log/__APP__/collector.log
StandardError=inherit StandardError=inherit
# Sandboxing options to harden security # Sandboxing options to harden security

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Scrutiny Collector timer Description=Scrutiny Collector Timer
[Timer] [Timer]
OnCalendar=daily OnCalendar=daily

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Scrutiny web server Description=Scrutiny Web Server
After=network-online.target After=network-online.target
[Service] [Service]
@ -12,7 +12,7 @@ StateDirectory=__APP__
ExecStart=__INSTALL_DIR__/bin/scrutiny-web-linux-amd64 start --config __INSTALL_DIR__/config/scrutiny.yaml ExecStart=__INSTALL_DIR__/bin/scrutiny-web-linux-amd64 start --config __INSTALL_DIR__/config/scrutiny.yaml
Restart=always Restart=always
RestartSec=10s RestartSec=10s
StandardOutput=append:/var/log/__APP__/__APP__-web-server.log StandardOutput=append:/var/log/__APP__/web-server.log
StandardError=inherit StandardError=inherit
# Sandboxing options to harden security # Sandboxing options to harden security

View file

@ -1,4 +1,8 @@
For any collector not on that host, you should change the `--api-endpoint`. For any collector not on that host...
...refer to the documentation at [https://github.com/AnalogJ/scrutiny/blob/master/docs/INSTALL_MANUAL.md#collector](https://github.com/AnalogJ/scrutiny/blob/master/docs/INSTALL_MANUAL.md#collector)
...change the `--api-endpoint`
For example : For example :

View file

@ -1,4 +1,8 @@
For any collector not on that host, you should change the `--api-endpoint`. For any collector not on that host...
...refer to the documentation at [https://github.com/AnalogJ/scrutiny/blob/master/docs/INSTALL_MANUAL.md#collector](https://github.com/AnalogJ/scrutiny/blob/master/docs/INSTALL_MANUAL.md#collector)
...change the `--api-endpoint`
For example : For example :

View file

@ -1,6 +1,9 @@
For any collector not on that host, you should change the `--api-endpoint`. For any collector not on that host...
...refer to the documentation at [https://github.com/AnalogJ/scrutiny/blob/master/docs/INSTALL_MANUAL.md#collector](https://github.com/AnalogJ/scrutiny/blob/master/docs/INSTALL_MANUAL.md#collector)
...change the `--api-endpoint`
For example : For example :
> `/opt/scrutiny/bin/scrutiny-collector-metrics-linux-amd64 run --api-endpoint https://__DOMAIN____PATH__` > `/opt/scrutiny/bin/scrutiny-collector-metrics-linux-amd64 run --api-endpoint https://__DOMAIN____PATH__`

View file

@ -17,7 +17,7 @@ fund = "https://paypal.me/analogj/usd10"
[integration] [integration]
yunohost = ">= 11.1.6" yunohost = ">= 11.1.6"
architectures = ["amd64", "arm64"] architectures = ["amd64", "arm64"]
multi_instance = true multi_instance = false
ldap = "not_relevant" ldap = "not_relevant"
sso = "not_relevant" sso = "not_relevant"
disk = "50M" disk = "50M"
@ -34,7 +34,7 @@ ram.runtime = "50M"
[install.collector] [install.collector]
ask.en = "Should the collector be activated on this host?" ask.en = "Should the collector be activated on this host?"
ask.fr = "Le collector doit-il est activé sur cet host ?" help.en = "Let it to true if yunohost is running on bare metal (i.e. not in a VM or in a LXC)"
type = "boolean" type = "boolean"
default = true default = true

View file

@ -1,47 +0,0 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# 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
ynh_change_url_nginx_config
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# ...
#=================================================
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -17,10 +17,12 @@ source /usr/share/yunohost/helpers
ynh_script_progression --message="Setting up source files..." --weight=1 ynh_script_progression --message="Setting up source files..." --weight=1
mkdir -p "$install_dir/bin" mkdir -p "$install_dir/bin"
if [ $YNH_ARCH == "amd64" ]; then if [ $YNH_ARCH == "amd64" ]
then
ynh_setup_source --source_id="src/scrutiny-web-linux-amd64" --dest_dir="$install_dir/bin" ynh_setup_source --source_id="src/scrutiny-web-linux-amd64" --dest_dir="$install_dir/bin"
ynh_setup_source --source_id="src/scrutiny-collector-metrics-linux-amd64" --dest_dir="$install_dir/bin" ynh_setup_source --source_id="src/scrutiny-collector-metrics-linux-amd64" --dest_dir="$install_dir/bin"
elif [ $YNH_ARCH == "arm64" ]; then elif [ $YNH_ARCH == "arm64" ]
then
ynh_setup_source --source_id="src/scrutiny-web-linux-arm64" --dest_dir="$install_dir/bin" ynh_setup_source --source_id="src/scrutiny-web-linux-arm64" --dest_dir="$install_dir/bin"
ynh_setup_source --source_id="src/scrutiny-collector-metrics-linux-arm64" --dest_dir="$install_dir/bin" ynh_setup_source --source_id="src/scrutiny-collector-metrics-linux-arm64" --dest_dir="$install_dir/bin"
fi fi
@ -37,11 +39,12 @@ ynh_add_nginx_config
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config --service="scrutiny-web-server" --template="systemd-scrutiny-web-server.service" ynh_add_systemd_config --service="scrutiny-web-server" --template="systemd-scrutiny-web-server.service"
yunohost service add "scrutiny-web-server" --description="WebUI for smartd S.M.A.R.T monitoring" --log="/var/log/$app/$app-web-server.log" yunohost service add "scrutiny-web-server" --description="WebUI for smartd S.M.A.R.T monitoring" --log="/var/log/$app/web-server.log"
ynh_add_config --template="systemd-scrutiny-collector.service" --destination="/etc/systemd/system/scrutiny-collector.service" ynh_add_config --template="systemd-scrutiny-collector.service" --destination="/etc/systemd/system/scrutiny-collector.service"
if [ $collector ]; then if [ $collector -eq 1 ]
yunohost service add "scrutiny-collector.timer" --description="Collector timer for smartd S.M.A.R.T monitoring" --log="/var/log/$app/$app-web-server.log" then
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"
fi fi
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
@ -55,6 +58,12 @@ ynh_use_logrotate --specific_user="$app"
ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_script_progression --message="Adding a configuration file..." --weight=1
mkdir -p "$install_dir/config" mkdir -p "$install_dir/config"
if [ "${path}" == "/" ]
then
base_path=""
else
base_path="${path}"
fi
ynh_add_config --template="config/scrutiny.yaml" --destination="$install_dir/config/scrutiny.yaml" ynh_add_config --template="config/scrutiny.yaml" --destination="$install_dir/config/scrutiny.yaml"
ynh_add_config --template="systemd-scrutiny-collector.timer" --destination="/etc/systemd/system/scrutiny-collector.timer" ynh_add_config --template="systemd-scrutiny-collector.timer" --destination="/etc/systemd/system/scrutiny-collector.timer"
@ -74,13 +83,14 @@ myynh_set_permissions
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name="influxdb" --action="enable" ynh_systemd_action --service_name="influxdb" --action="enable"
ynh_systemd_action --service_name="influxdb" --action="start" ynh_systemd_action --service_name="influxdb" --action="start"
ynh_systemd_action --service_name="scrutiny-web-server.service" --action="start" --log_path="/var/log/$app/scrutiny-web-server.log" ynh_systemd_action --service_name="scrutiny-web-server.service" --action="start" --log_path="/var/log/$app/web-server.log"
if [ $collector ]; then if [ $collector -eq 1 ]
then
systemctl daemon-reload systemctl daemon-reload
ynh_systemd_action --service_name="scrutiny-collector.service" --action="enable" ynh_systemd_action --service_name="scrutiny-collector.service" --action="enable"
ynh_systemd_action --service_name="scrutiny-collector.service" --action="start" --log_path="/var/log/$app/scrutiny-collector.log" ynh_systemd_action --service_name="scrutiny-collector.service" --action="start" --log_path="/var/log/$app/collector.log"
ynh_systemd_action --service_name="scrutiny-collector.timer" --action="enable" ynh_systemd_action --service_name="scrutiny-collector.timer" --action="enable"
ynh_systemd_action --service_name="scrutiny-collector.timer" --action="start" ynh_systemd_action --service_name="scrutiny-collector.timer" --action="start" --log_path="/var/log/$app/collector.log"
fi fi
#================================================= #=================================================

View file

@ -25,21 +25,18 @@ fi
if ynh_exec_warn_less yunohost service status "scrutiny-collector" >/dev/null if ynh_exec_warn_less yunohost service status "scrutiny-collector" >/dev/null
then then
ynh_script_progression --message="Removing scrutiny-collector timer integration..." --weight=1 ynh_script_progression --message="Removing scrutiny-collector service integration..." --weight=1
yunohost service remove "scrutiny-collector" yunohost service remove "scrutiny-collector"
fi fi
ynh_remove_systemd_config --service="scrutiny-web-server" ynh_remove_systemd_config --service="scrutiny-web-server"
ynh_remove_systemd_config --service="scrutiny-collector" ynh_remove_systemd_config --service="scrutiny-collector"
ynh_secure_remove --file="/etc/systemd/system/scrutiny-collector.timer"
ynh_remove_nginx_config ynh_remove_nginx_config
ynh_remove_logrotate ynh_remove_logrotate
if [ $collector ]; then
ynh_secure_remove --file="/etc/systemd/system/scrutiny-collector.timer"
fi
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"
#================================================= #=================================================

View file

@ -30,9 +30,10 @@ systemctl enable "/etc/systemd/system/scrutiny-web-server.service" --quiet
ynh_restore_file --origin_path="/etc/systemd/system/scrutiny-collector.service" ynh_restore_file --origin_path="/etc/systemd/system/scrutiny-collector.service"
ynh_restore_file --origin_path="/etc/systemd/system/scrutiny-collector.timer" ynh_restore_file --origin_path="/etc/systemd/system/scrutiny-collector.timer"
yunohost service add "scrutiny-web-server" --description="WebUI for smartd S.M.A.R.T monitoring" --log="/var/log/$app/$app-web-server.log" yunohost service add "scrutiny-web-server" --description="WebUI for smartd S.M.A.R.T monitoring" --log="/var/log/$app/web-server.log"
if [ $collector ]; then if [ $collector -eq 1 ]
yunohost service add "scrutiny-collector.timer" --description="Collector timer for smartd S.M.A.R.T monitoring" --log="/var/log/$app/$app-web-server.log" then
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"
fi fi
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
@ -47,13 +48,14 @@ ynh_script_progression --message="Reloading NGINX web server and $app's service.
# Typically you only have either $app or php-fpm but not both at the same time... # Typically you only have either $app or php-fpm but not both at the same time...
ynh_systemd_action --service_name="influxdb" --action="start" ynh_systemd_action --service_name="influxdb" --action="start"
ynh_systemd_action --service_name="scrutiny-web-server.service" --action="start" --log_path="/var/log/$app/scrutiny-web-server.log" ynh_systemd_action --service_name="scrutiny-web-server.service" --action="start" --log_path="/var/log/$app/web-server.log"
if [ $collector ]; then if [ $collector -eq 1 ]
then
systemctl daemon-reload systemctl daemon-reload
ynh_systemd_action --service_name="scrutiny-collector.service" --action="enable" ynh_systemd_action --service_name="scrutiny-collector.service" --action="enable"
ynh_systemd_action --service_name="scrutiny-collector.service" --action="start" --log_path="/var/log/$app/scrutiny-collector.log" ynh_systemd_action --service_name="scrutiny-collector.service" --action="start" --log_path="/var/log/$app/collector.log"
ynh_systemd_action --service_name="scrutiny-collector.timer" --action="enable" ynh_systemd_action --service_name="scrutiny-collector.timer" --action="enable"
ynh_systemd_action --service_name="scrutiny-collector.timer" --action="start" ynh_systemd_action --service_name="scrutiny-collector.timer" --action="start" --log_path="/var/log/$app/collector.log"
fi fi
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload

View file

@ -24,11 +24,11 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1 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"
ynh_systemd_action --service_name="influxdb" --action="stop" ynh_systemd_action --service_name="influxdb" --action="stop"
ynh_systemd_action --service_name="scrutiny-web-server.service" --action="stop" --log_path="/var/log/$app/scrutiny-web-server.log" ynh_systemd_action --service_name="scrutiny-web-server.service" --action="stop" --log_path="/var/log/$app/web-server.log"
if [ $collector ]; then if [ $collector -eq 1 ]
ynh_systemd_action --service_name="scrutiny-collector.timer" --action="stop" then
ynh_systemd_action --service_name="scrutiny-collector.timer" --action="stop" --log_path="/var/log/$app/collector.log"
fi fi
#================================================= #=================================================
@ -42,10 +42,12 @@ then
ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
if [ $YNH_ARCH == "amd64" ]; then if [ $YNH_ARCH == "amd64" ]
then
ynh_setup_source --source_id="src/scrutiny-web-linux-amd64" --dest_dir="$install_dir/bin" ynh_setup_source --source_id="src/scrutiny-web-linux-amd64" --dest_dir="$install_dir/bin"
ynh_setup_source --source_id="src/scrutiny-collector-metrics-linux-amd64" --dest_dir="$install_dir/bin" ynh_setup_source --source_id="src/scrutiny-collector-metrics-linux-amd64" --dest_dir="$install_dir/bin"
elif [ $YNH_ARCH == "arm64" ]; then elif [ $YNH_ARCH == "arm64" ]
then
ynh_setup_source --source_id="src/scrutiny-web-linux-arm64" --dest_dir="$install_dir/bin" ynh_setup_source --source_id="src/scrutiny-web-linux-arm64" --dest_dir="$install_dir/bin"
ynh_setup_source --source_id="src/scrutiny-collector-metrics-linux-arm64" --dest_dir="$install_dir/bin" ynh_setup_source --source_id="src/scrutiny-collector-metrics-linux-arm64" --dest_dir="$install_dir/bin"
fi fi
@ -60,11 +62,12 @@ ynh_script_progression --message="Upgrading system configurations related to $ap
ynh_add_nginx_config ynh_add_nginx_config
ynh_add_systemd_config --service="scrutiny-web-server" --template="systemd-scrutiny-web-server.service" ynh_add_systemd_config --service="scrutiny-web-server" --template="systemd-scrutiny-web-server.service"
yunohost service add "scrutiny-web-server" --description="WebUI for smartd S.M.A.R.T monitoring" --log="/var/log/$app/$app-web-server.log" yunohost service add "scrutiny-web-server" --description="WebUI for smartd S.M.A.R.T monitoring" --log="/var/log/$app/web-server.log"
ynh_add_config --template="systemd-scrutiny-collector.service" --destination="/etc/systemd/system/scrutiny-collector.service" ynh_add_config --template="systemd-scrutiny-collector.service" --destination="/etc/systemd/system/scrutiny-collector.service"
if [ $collector ]; then if [ $collector -eq 1 ]
yunohost service add "scrutiny-collector.timer" --description="Collector timer for smartd S.M.A.R.T monitoring" --log="/var/log/$app/$app-web-server.log" then
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"
fi fi
ynh_use_logrotate --specific_user="$app" --non-append ynh_use_logrotate --specific_user="$app" --non-append
@ -76,6 +79,12 @@ ynh_use_logrotate --specific_user="$app" --non-append
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_script_progression --message="Updating a configuration file..." --weight=1
if [ "${path}" == "/" ]
then
base_path=""
else
base_path="${path}"
fi
ynh_add_config --template="config/scrutiny.yaml" --destination="$install_dir/config/scrutiny.yaml" ynh_add_config --template="config/scrutiny.yaml" --destination="$install_dir/config/scrutiny.yaml"
ynh_add_config --template="systemd-scrutiny-collector.timer" --destination="/etc/systemd/system/scrutiny-collector.timer" ynh_add_config --template="systemd-scrutiny-collector.timer" --destination="/etc/systemd/system/scrutiny-collector.timer"
@ -93,13 +102,14 @@ myynh_set_permissions
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name="influxdb" --action="enable" ynh_systemd_action --service_name="influxdb" --action="enable"
ynh_systemd_action --service_name="influxdb" --action="start" ynh_systemd_action --service_name="influxdb" --action="start"
ynh_systemd_action --service_name="scrutiny-web-server.service" --action="start" --log_path="/var/log/$app/scrutiny-web-server.log" ynh_systemd_action --service_name="scrutiny-web-server.service" --action="start" --log_path="/var/log/$app/web-server.log"
if [ $collector ]; then if [ $collector -eq 1 ]
then
systemctl daemon-reload systemctl daemon-reload
ynh_systemd_action --service_name="scrutiny-collector.service" --action="enable" ynh_systemd_action --service_name="scrutiny-collector.service" --action="enable"
ynh_systemd_action --service_name="scrutiny-collector.service" --action="start" --log_path="/var/log/$app/scrutiny-collector.log" ynh_systemd_action --service_name="scrutiny-collector.service" --action="start" --log_path="/var/log/$app/collector.log"
ynh_systemd_action --service_name="scrutiny-collector.timer" --action="enable" ynh_systemd_action --service_name="scrutiny-collector.timer" --action="enable"
ynh_systemd_action --service_name="scrutiny-collector.timer" --action="start" ynh_systemd_action --service_name="scrutiny-collector.timer" --action="start" --log_path="/var/log/$app/collector.log"
fi fi
#================================================= #=================================================