diff options
author | Karel Kočí <cynerd@email.cz> | 2020-09-23 11:42:19 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2020-09-23 11:43:02 +0200 |
commit | 5fee4bd515d55cb1ded1bed0c34fb89c22e01a87 (patch) | |
tree | 0718445739237630d35330ac3ac5c3cc11979daa /sentinel-proxy/files | |
parent | bf24e13ee81a77aa39e2af11f4a778c7bef39f0b (diff) | |
download | openwrt-personal-pkgs-5fee4bd515d55cb1ded1bed0c34fb89c22e01a87.tar.gz openwrt-personal-pkgs-5fee4bd515d55cb1ded1bed0c34fb89c22e01a87.tar.bz2 openwrt-personal-pkgs-5fee4bd515d55cb1ded1bed0c34fb89c22e01a87.zip |
sentinel-proxy: try newer version
Diffstat (limited to 'sentinel-proxy/files')
-rw-r--r-- | sentinel-proxy/files/ca.pem | 38 | ||||
-rwxr-xr-x | sentinel-proxy/files/init | 30 | ||||
-rw-r--r-- | sentinel-proxy/files/renew.cron | 5 | ||||
-rwxr-xr-x | sentinel-proxy/files/restart-proxy-hook.sh | 3 | ||||
-rwxr-xr-x | sentinel-proxy/files/sentinel-reload.sh | 15 | ||||
-rwxr-xr-x | sentinel-proxy/files/sentinel.sh | 47 | ||||
-rw-r--r-- | sentinel-proxy/files/uci | 2 | ||||
-rwxr-xr-x | sentinel-proxy/files/uci-defaults | 9 |
8 files changed, 149 insertions, 0 deletions
diff --git a/sentinel-proxy/files/ca.pem b/sentinel-proxy/files/ca.pem new file mode 100644 index 0000000..91094e1 --- /dev/null +++ b/sentinel-proxy/files/ca.pem @@ -0,0 +1,38 @@ +-----BEGIN CERTIFICATE----- +MIIGsDCCBJigAwIBAgIJAM3oziL/qM4GMA0GCSqGSIb3DQEBCwUAMIGWMQswCQYD +VQQGEwJDWjELMAkGA1UECBMCQ1oxDzANBgNVBAcTBlByYWd1ZTEPMA0GA1UEChMG +Q1ouTklDMQ8wDQYDVQQLEwZUdXJyaXMxFDASBgNVBAMTC1NlbnRpbmVsIENBMREw +DwYDVQ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/sentinel-proxy/files/init b/sentinel-proxy/files/init new file mode 100755 index 0000000..d8df253 --- /dev/null +++ b/sentinel-proxy/files/init @@ -0,0 +1,30 @@ +#!/bin/sh /etc/rc.common + +USE_PROCD=1 +START=95 +STOP=10 + +start_service() { + source /lib/functions/sentinel.sh + agreed_with_eula || return 1 + + config_load sentinel + local device_token + config_get device_token main device_token "" + if ! sentinel-device-token --validate "${device_token}" --quite; then + device_token="$(sentinel-device-token --create --quite)"; + uci -q set sentinel.main.device_token="${device_token}"; + uci -q commit sentinel.main; + echo "New device token created" >&2; + fi + + cat > "/tmp/etc/sentinel-proxy.cfg" <<-EOF + device_token = "${device_token}" +EOF + + procd_open_instance + procd_set_param command /bin/sh -c 'sentinel-certgen certs --skip-renew && exec sentinel-proxy' + procd_set_param respawn 600 5 5 + procd_set_param file /etc/config/sentinel + procd_close_instance +} diff --git a/sentinel-proxy/files/renew.cron b/sentinel-proxy/files/renew.cron new file mode 100644 index 0000000..839208f --- /dev/null +++ b/sentinel-proxy/files/renew.cron @@ -0,0 +1,5 @@ +## crontab +# + +# Periodically check and renew Sentinel:Proxy certificate +42 */12 * * * root sentinel-certgen certs --hooks-dir /usr/libexec/sentinel/renew_hooks.d diff --git a/sentinel-proxy/files/restart-proxy-hook.sh b/sentinel-proxy/files/restart-proxy-hook.sh new file mode 100755 index 0000000..faec14d --- /dev/null +++ b/sentinel-proxy/files/restart-proxy-hook.sh @@ -0,0 +1,3 @@ +#!/bin/sh +# restart Sentinel:Proxy service +/etc/init.d/sentinel-proxy restart diff --git a/sentinel-proxy/files/sentinel-reload.sh b/sentinel-proxy/files/sentinel-reload.sh new file mode 100755 index 0000000..f21eceb --- /dev/null +++ b/sentinel-proxy/files/sentinel-reload.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# Reload all sentinel components to apply the newest configuration. +# The reload is done by running scripts located in HOOKS_DIR + +HOOKS_DIR="/usr/libexec/sentinel/reload_hooks.d/" + +if ! [ -d "${HOOKS_DIR}" ]; then + echo "Failed to reload Sentinel: hooks dir does not exist" >&2 + return 1 +fi + +for reload_script in "${HOOKS_DIR}"/*; do + [ -x "${reload_script}" ] || continue + "${reload_script}" +done diff --git a/sentinel-proxy/files/sentinel.sh b/sentinel-proxy/files/sentinel.sh new file mode 100755 index 0000000..044832a --- /dev/null +++ b/sentinel-proxy/files/sentinel.sh @@ -0,0 +1,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 +) diff --git a/sentinel-proxy/files/uci b/sentinel-proxy/files/uci new file mode 100644 index 0000000..139597f --- /dev/null +++ b/sentinel-proxy/files/uci @@ -0,0 +1,2 @@ + + diff --git a/sentinel-proxy/files/uci-defaults b/sentinel-proxy/files/uci-defaults new file mode 100755 index 0000000..d144db5 --- /dev/null +++ b/sentinel-proxy/files/uci-defaults @@ -0,0 +1,9 @@ +#!/bin/sh + +if [ "$(uci -q get sentinel.main)" != "main" ]; then + uci -q batch <<EOT + delete sentinel.main + set sentinel.main='main' + commit sentinel.main +EOT +fi |