#!/bin/sh

INIT_DIR=/etc/init.d
LOGTOOL=/usr/bin/logger
NETWORK_SCRIPT=/etc/init.d/95inet

for script in $(ls ${INIT_DIR}/[0-9][0-9]*); do
        if [ ! -x ${script} ]; then
                echo "Skip non-executable file ${script}.";
                continue;
        fi
        echo -ne "Start $(echo ${script} | sed -e 's|${INIT_DIR}/[0-9][0-9]||') ... ";
        if [ "X$(ps | grep -v grep | grep -c syslogd)" != "X0" ]; then # we remove grep -c syslogd ...
                ${script} start 2>&1 | ${LOGTOOL};
                ERR=$?;
        else
                ${script} start;
                ERR=$?;
        fi
        if [ "X${ERR}" != "X0" ]; then
                echo "failed";
                ${LOGTOOL} "${script} failed with error ${ERR}";
        else
                echo "done";
        fi

        if [ ${script} = ${NETWORK_SCRIPT} ] ; then
                /sbin/ifconfig
        fi
done

exit 0;
