mirror of
https://github.com/openwrt/packages.git
synced 2025-12-22 01:44:32 +04:00
prometheus-node-exporter-lua: add HTTPS support
With valid 'cert'/'key' config, prometheus-node-exporter-lua will respond to https instead of http on 'listen_port'. Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
This commit is contained in:
@@ -11,12 +11,14 @@ _log() {
|
||||
start_service() {
|
||||
. /lib/functions/network.sh
|
||||
|
||||
local interface port bind4 bind6
|
||||
local interface port listenflag cert key bind4 bind6
|
||||
|
||||
config_load prometheus-node-exporter-lua.main
|
||||
config_get keepalive "main" http_keepalive 70
|
||||
config_get interface "main" listen_interface "loopback"
|
||||
config_get port "main" listen_port 9100
|
||||
config_get cert "main" cert
|
||||
config_get key "main" key
|
||||
|
||||
[ "$interface" = "*" ] || {
|
||||
network_get_ipaddr bind4 "$interface"
|
||||
@@ -25,18 +27,25 @@ start_service() {
|
||||
_log "defering start until listen interface $interface becomes ready"
|
||||
return 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
procd_open_instance
|
||||
|
||||
procd_set_param command /usr/sbin/uhttpd -f -c /dev/null -l / -L /usr/bin/prometheus-node-exporter-lua
|
||||
[ $keepalive -gt 0 ] && procd_append_param command -k $keepalive
|
||||
|
||||
if [ "$interface" = "*" ]; then
|
||||
procd_append_param command -p $port
|
||||
if [ -f "$cert" -a -f "$key" ]; then
|
||||
listenflag=-s
|
||||
procd_append_param command -C $cert -K $key
|
||||
else
|
||||
[ -n "$bind4" ] && procd_append_param command -p $bind4:$port
|
||||
[ -n "$bind6" ] && procd_append_param command -p [$bind6]:$port
|
||||
listenflag=-p
|
||||
fi
|
||||
|
||||
if [ "$interface" = "*" ]; then
|
||||
procd_append_param command $listenflag $port
|
||||
else
|
||||
[ -n "$bind4" ] && procd_append_param command $listenflag $bind4:$port
|
||||
[ -n "$bind6" ] && procd_append_param command $listenflag [$bind6]:$port
|
||||
fi
|
||||
|
||||
procd_set_param stdout 1
|
||||
|
||||
Reference in New Issue
Block a user