validate-init-services: anchor scheme extraction off comments; fall back to cmd-path binary check
This commit is contained in:
@@ -74,7 +74,7 @@ if [ -d "$MOUNT_DIR/usr/lib/init.d" ] || [ -d "$MOUNT_DIR/etc/init.d" ]; then
|
||||
for svc_file in "$MOUNT_DIR"/usr/lib/init.d/*.service "$MOUNT_DIR"/etc/init.d/*.service; do
|
||||
[ -f "$svc_file" ] || continue
|
||||
|
||||
scheme_name=$(grep -oP 'type\s*=\s*\{\s*scheme\s*=\s*"([^"]+)"' "$svc_file" 2>/dev/null | grep -oP '"[^"]+"' | tr -d '"' || true)
|
||||
scheme_name=$(grep -oP '^\s*type\s*=\s*\{\s*scheme\s*=\s*"([^"]+)"' "$svc_file" 2>/dev/null | grep -oP '"[^"]+"' | tr -d '"' || true)
|
||||
if [ -n "$scheme_name" ]; then
|
||||
# Scheme daemon binaries use <name>d convention (e.g., scheme "evdev" -> binary "evdevd")
|
||||
found_binary=false
|
||||
@@ -85,6 +85,15 @@ if [ -d "$MOUNT_DIR/usr/lib/init.d" ] || [ -d "$MOUNT_DIR/etc/init.d" ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ "$found_binary" = "false" ]; then
|
||||
# Fall back to the service's actual cmd path (scheme daemons may
|
||||
# live outside /usr/bin, e.g. /usr/lib/drivers/intel-lpss-i2cd).
|
||||
cmd_path=$(grep -oP '^\s*cmd\s*=\s*"([^"]+)"' "$svc_file" 2>/dev/null | grep -oP '"[^"]+"' | tr -d '"' | head -1 || true)
|
||||
if [ -n "$cmd_path" ] && [ -x "$MOUNT_DIR$cmd_path" ]; then
|
||||
echo " OK: scheme '$scheme_name' has binary at cmd path $cmd_path"
|
||||
found_binary=true
|
||||
fi
|
||||
fi
|
||||
if [ "$found_binary" = "false" ]; then
|
||||
echo " FAIL: scheme '$scheme_name' has NO binary at /usr/bin/$scheme_name, /usr/bin/${scheme_name}d, or /usr/bin/redbear-$scheme_name"
|
||||
failures=$((failures + 1))
|
||||
|
||||
Reference in New Issue
Block a user