#!/bin/sh
# Run product specific init scripts and set bootstrap conditions.
#
# Product-specific files (udev rules, factory config, etc.) are already
# copied to / by the pre-udev run task before udevd starts.  This
# script handles the remaining product init: running custom scripts
# from /etc/product/init.d/ and setting finit conditions.
#
# Use /etc/product/init.d/S01-myscript for scripts, may be a symlink, it
# will be called with `start` as its only argument.
ident=$(basename "$0")

PRODUCT_INIT=/etc/product/init.d

note()
{
    logger -I $$ -k -p user.notice -t "$ident" "$1"
}

# Conditions for bootstrap services, this enables product specific
# init scripts to prevent select services from starting.
initctl -nbq cond set led

if [ -d "$PRODUCT_INIT" ]; then
    note "Calling runparts $PRODUCT_INIT/S[0-9]+.* start"
    /usr/libexec/finit/runparts -bsp "$PRODUCT_INIT"
fi

# Product specific init done.
initctl -nbq cond set product

exit 0
