summaryrefslogtreecommitdiff
path: root/sentinel-proxy/files/sentinel.sh
blob: 044832ae47f17562cc0b560ddb91ad4e19f7038f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh
## sentinel.sh
#
# set of common functions intended to be sourced and reused in
# sentinel-related scripts

# source OpenWrt functions if not sourced yet
command -v config_load > /dev/null || . /lib/functions.sh


allowed_to_run() {
	local component_name="$1";
	agreed_with_eula "${component_name}" && component_enabled "${component_name}"
}

component_enabled() (
	local component_name="$1";
	config_load sentinel

	local enabled
	config_get_bool enabled "${component_name}" enabled "1"
	[ "$enabled" = "1" ] || {
		echo "Sentinel ${component_name} not enabled" >&2
		return 1
	}
)

agreed_with_eula() (
	local component_name="$1";
	config_load sentinel

	local agreed_eula_version
	config_get agreed_eula_version main agreed_with_eula_version "0"
	[ "$agreed_eula_version" -le "0" ] || return 0

	cat >&2 <<EOF
Not agreed with EULA.

EULA could be found at /usr/share/sentinel-eula/ and you can
agree with it either in ReForis data collect tab or using
uci config:
uci set sentinel.main.agreed_with_eula_version=1 && uci commit

EULA version may increase in time. See documentation for more details.
EOF
	return 1
)