fix start script

This commit is contained in:
larssand
2026-09-03 20:48:01 +02:00
parent 1e33e1fffc
commit c60b9e0057
2 changed files with 15 additions and 2 deletions

View File

@@ -28,7 +28,7 @@ chmod +x /etc/init.d/racecore-nginx
/etc/init.d/racecore-nginx start /etc/init.d/racecore-nginx start
``` ```
The custom init script is useful when Teltonika's bundled `nginx-util` is missing. The custom init script is useful when Teltonika.s bundled `nginx-util` is missing. It discovers Nginx in the firmware PATH, including `/usr/local/usr/sbin/nginx`, before checking standard paths.
It recreates all RAM-backed Nginx temporary directories under `/tmp` on every boot, It recreates all RAM-backed Nginx temporary directories under `/tmp` on every boot,
validates the config, and starts Nginx under `procd`. validates the config, and starts Nginx under `procd`.

View File

@@ -4,14 +4,26 @@ START=95
STOP=10 STOP=10
USE_PROCD=1 USE_PROCD=1
NGINX_BIN="/usr/sbin/nginx" NGINX_BIN=""
NGINX_CONF="/etc/nginx/nginx.conf" NGINX_CONF="/etc/nginx/nginx.conf"
resolve_nginx() {
for candidate in "$(command -v nginx 2>/dev/null)" /usr/local/usr/sbin/nginx /usr/sbin/nginx /usr/bin/nginx; do
if [ -n "$candidate" ] && [ -x "$candidate" ]; then
NGINX_BIN="$candidate"
return 0
fi
done
logger -t racecore-nginx "nginx executable not found"
return 1
}
prepare_runtime() { prepare_runtime() {
mkdir -p /tmp/nginx/client_body /tmp/nginx/proxy /tmp/nginx/fastcgi /tmp/nginx/uwsgi /tmp/nginx/scgi mkdir -p /tmp/nginx/client_body /tmp/nginx/proxy /tmp/nginx/fastcgi /tmp/nginx/uwsgi /tmp/nginx/scgi
} }
start_service() { start_service() {
resolve_nginx || return 1
prepare_runtime prepare_runtime
"$NGINX_BIN" -t -c "$NGINX_CONF" || return 1 "$NGINX_BIN" -t -c "$NGINX_CONF" || return 1
procd_open_instance procd_open_instance
@@ -24,6 +36,7 @@ start_service() {
} }
reload_service() { reload_service() {
resolve_nginx || return 1
prepare_runtime prepare_runtime
"$NGINX_BIN" -t -c "$NGINX_CONF" || return 1 "$NGINX_BIN" -t -c "$NGINX_CONF" || return 1
"$NGINX_BIN" -s reload -c "$NGINX_CONF" "$NGINX_BIN" -s reload -c "$NGINX_CONF"