#!/bin/sh
########################################################################
# Begin local
#
# Description : Perform local setup on startup
#
# Author      : Tomek Wójcik <tomek@bthlabs.pl>
#
# Version     : ZiomekOS 26.9.26
#
########################################################################

### BEGIN INIT INFO
# Provides:            local
# Required-Start:      $network
# Should-Start:        networkmanager wicd
# Required-Stop:       $network
# Should-Stop:         networkmanager wicd
# Default-Start:       2 3 4 5
# Default-Stop:        
# Short-Description:   Local Setup
# Description:         Local Setup
# X-LFS-Provided-By:   ZiomekOS
### END INIT INFO

. /lib/lsb/init-functions

PARTS_DIR="/etc/rc.local.d"

run_parts() {
    local DIR=$1
    local SCRIPT RC
    local RESULT=0

    [ -d "$DIR" ] || return 0

    for SCRIPT in "$DIR"/*; do
        [ -f "$SCRIPT" ] && [ -x "$SCRIPT" ] || continue

        "$SCRIPT"
        RC=$?

        if [ "$RC" -ne 0 ]; then
            log_warning_msg "${SCRIPT} exited with status ${RC}"
            [ "$RESULT" -eq 0 ] && RESULT=$RC
        fi
    done

    return "0"
}

case "$1" in
   start)
      log_info_msg "Running rc.local scripts..."
      evaluate_retval
      run_parts $PARTS_DIR
      ;;

   *)
      echo "Usage: $0 {start}"
      exit 1
      ;;
esac

# End local
