#!/bin/sh

### BEGIN INIT INFO
# Provides:          sc_hardware_prepare
# Required-Start:    $local_fs
# Should-Start:      $null
# Required-Stop:     $null
# Should-Stop:       $null
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: checks for pc_type specific configuration and makes them default
# Description:       checks for pc_type specific configuration
#   and makes them default by creating links.
#   Additional, it executes pc_type specific commands,
#   that are defined in /etc/smartclient/sc_hardware
### END INIT INFO


source /etc/rc.status
rc_reset

source /usr/lib/smartclient/sc_hardware.sh
sc_hardware_init

FOO="SmartClient hardware preparation "

case "$1" in
    start)
        echo "Starting $FOO "
    
        # execute hardware specific commands
        pcTypeSpecificCommands=`get_pcType_specific_action`
        if [ "$pcTypeSpecificCommands" ]; then
            echo -n "  executing PC-type specific command ($pcTypeSpecificCommands) "
            do_pcType_specific_action
            rc_status -v
            result=1
        fi
    
        CONFIG_FILES=$SC_HARDWARE_SPECIFIC_CONFIGS
    
        for config in $CONFIG_FILES; do
            echo -n "  $config: "
            do_pcType_specific_config $config
            #rc_status -v
            echo
            result=1
        done

        if [ -z "$result" ]; then
            rc_status -v1
        fi
        ;;
    stop)
        ;;
    restart)
        ## Stop the service and regardless of whether it was
        ## running or not, start it again.
        $0 stop
        $0 start
    
        # Remember status and be quiet
        rc_status
        ;;
    status)
        ;;
    *)
        echo "Usage: $0 {start|stop|status|restart}"
        exit 1
        ;;
esac
rc_exit
