ucentral-client: fix init script file handling

Add file existence checks before reading gateway.json and initialise
variables to prevent boot log spam when configuration file doesn't
exist.

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2025-10-19 00:00:00 +02:00
parent e5b3a6506b
commit 27e9f05908

View File

@@ -42,8 +42,10 @@ start_service() {
[ "${selfsigned}" == "true" ] && insecure=1 [ "${selfsigned}" == "true" ] && insecure=1
fi fi
server=$(cat /etc/ucentral/gateway.json | jsonfilter -e '@["server"]') server=
port=$(cat /etc/ucentral/gateway.json | jsonfilter -e '@["port"]') [ -f /etc/ucentral/gateway.json ] && server=$(cat /etc/ucentral/gateway.json | jsonfilter -e '@["server"]')
port=
[ -f /etc/ucentral/gateway.json ] && port=$(cat /etc/ucentral/gateway.json | jsonfilter -e '@["port"]')
[ -n "$server" -a -n "$port" ] || return 0 [ -n "$server" -a -n "$port" ] || return 0
boot_cause=$(cat /tmp/pstore | jsonfilter -e '@["pstore"][-1]'.boot_cause) boot_cause=$(cat /tmp/pstore | jsonfilter -e '@["pstore"][-1]'.boot_cause)