Skip to content

Commit

Permalink
prometheus-node-exporter-lua: This commit adds TLS capabilities for t…
Browse files Browse the repository at this point in the history
…he custom port selected to provide prometheus node exporter. The changes have been performed by enhancing the already existing modes of operation for the uhttpd server.

By merging this commit, the /etc/config/prometheus-node-exporter-lua file receives another two options, which allow the configuration of independent keys and certificate for the uhttpd server.

Signed-off-by: Thomas Rahimi <[email protected]>
  • Loading branch information
thomasrahimi committed Dec 15, 2024
1 parent 0d478f6 commit 2271022
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
config prometheus-node-exporter-lua 'main'
option listen_interface 'loopback'
option listen_port '9100'
option cert_path 'none'
option key_path 'none'
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,55 @@ start_service() {
[ $keepalive -gt 0 ] && procd_append_param command -k $keepalive

if [ "$interface" = "*" ]; then
procd_append_param command -p $port
if [ "$cert_path" = "none" ] && [ "$key_path" = "none" ]; then
procd_append_param command -p $port
elif [ "$cert_path" = "none" ] && [ "$key_path" != "none" ]; then
procd_append_param command -p $port
elif [ "$cert_path" != "none" ] && [ "$key_path" = "none" ]; then
procd_append_param command -p $port
elif [ "$cert_path" != "none" ] && [ "$key_path" != "none" ]; then
if [ -f "$cert_path" ] && [ -f "$key_path" ]; then
procd_append_param command -C $cert_path -K $key_path -s $port
elif [ ! -f "$cert_path" ]; then
_log "No cert file found under path: $cert_path"
return 0
elif [ ! -f "$key_path" ]; then
_log "No key file found under path: $key_path"
return 0
else
_log "Error setting up TLS"
return 0
fi
else
procd_append_param command -p $port
fi
else
[ -n "$bind4" ] && procd_append_param command -p $bind4:$port
[ -n "$bind6" ] && procd_append_param command -p [$bind6]:$port
if [ "$cert_path" = "none" ] && [ "$key_path" = "none" ]; then
procd_append_param command -p $bind4:$port
procd_append_param command -p [$bind6]:$port
elif [ "$cert_path" = "none" ] && [ "$key_path" != "none" ]; then
procd_append_param command -p $bind4:$port
procd_append_param command -p [$bind6]:$port
elif [ "$cert_path" != "none" ] && [ "$key_path" = "none" ]; then
procd_append_param command -p $bind4:$port
procd_append_param command -p [$bind6]:$port
elif [ "$cert_path" != "none" ] && [ "$key_path" != "none" ]; then
if [ -f "$cert_path" ] && [ -f "$key_path" ]; then
procd_append_param command -C $cert_path -K $key_path -s $bind4:$port
procd_append_param command -C $cert_path -K $key_path -s [$bind6]:$port
elif [ ! -f "$cert_path" ]; then
_log "No cert file found under path: $cert_path"
return 0
elif [ ! -f "$key_path" ]; then
_log "No key file found under path: $key_path"
return 0
else
_log "Error setting up TLS"
return 0
fi
else
procd_append_param command -p $port
fi
fi

procd_set_param stdout 1
Expand Down

0 comments on commit 2271022

Please sign in to comment.