Changeset 8223

Show
Ignore:
Timestamp:
07/18/07 07:26:37 (1 year ago)
Author:
dnicholson
Message:

Simplify modules input loop

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/bootscripts/ChangeLog

    r8222 r8223  
    55        * lfs/init.d/modules: Remove the log level handling since this is 
    66          done in the consolelog script now. 
     7        * lfs/init.d/modules: Clean up the script by removing the file 
     8          descriptor duplication and instead just redirecting 
     9          /etc/sysconfig/modules to the input of the while loop. 
    710 
    8112007-06-16      Dan Nicholson   <dnicholson@linuxfromscratch.org> 
  • trunk/bootscripts/lfs/init.d/modules

    r8222 r8223  
    2222        start) 
    2323 
     24                # Exit if there's no modules file or there are no 
     25                # valid entries 
     26                [ -r /etc/sysconfig/modules ] && 
     27                        egrep -qv '^($|#)' /etc/sysconfig/modules || 
     28                        exit 0 
     29 
     30                boot_mesg -n "Loading modules:" ${INFO} 
     31 
    2432                # Only try to load modules if the user has actually given us 
    2533                # some modules to load. 
    26                 if egrep -qv '^(#|$)' /etc/sysconfig/modules 2>/dev/null 
    27                 then 
     34                while read module args; do 
    2835 
    29                         # Read in the configuration file. 
    30                         exec 9>&0 < /etc/sysconfig/modules 
     36                        # Ignore comments and blank lines. 
     37                        case "$module" in 
     38                                ""|"#"*) continue ;; 
     39                        esac 
    3140 
    32                                 boot_mesg -n "Loading modules:" ${INFO} 
     41                        # Attempt to load the module, making 
     42                        # sure to pass any arguments provided. 
     43                        modprobe ${module} ${args} >/dev/null 
    3344 
    34                                 while read module args 
    35                                 do 
    36                                         # Ignore comments and blank lines. 
    37                                         case "${module}" in 
    38                                                 ""|\#*) continue ;; 
    39                                         esac 
     45                        # Print the module name if successful, 
     46                        # otherwise take note. 
     47                        if [ $? -eq 0 ]; then 
     48                                boot_mesg -n " ${module}" ${NORMAL} 
     49                        else 
     50                                failedmod="${failedmod} ${module}" 
     51                        fi 
     52                done < /etc/sysconfig/modules 
    4053 
    41                                         # Attempt to load the module, making 
    42                                         # sure to pass any arguments provided. 
    43                                         modprobe ${module} ${args} > /dev/null 
     54                boot_mesg "" ${NORMAL} 
     55                # Print a message about successfully loaded 
     56                # modules on the correct line. 
     57                echo_ok 
    4458 
    45                                         # Print the module name if successful, 
    46                                         # otherwise take note. 
    47                                         if [ ${?} -eq 0 ]; then 
    48                                                 boot_mesg -n " ${module}" ${NORMAL} 
    49                                         else 
    50                                                 failedmod="${failedmod} ${module}" 
    51                                         fi 
    52                                 done 
    53  
    54                                 boot_mesg "" ${NORMAL} 
    55                                 # Print a message about successfully loaded 
    56                                 # modules on the correct line. 
    57                                 echo_ok 
    58  
    59                                 # Print a failure message with a list of any 
    60                                 # modules that may have failed to load. 
    61                                 if [ "${failedmod}" ]; then 
    62                                         boot_mesg "Failed to load modules:${failedmod}" ${FAILURE} 
    63                                         echo_failure 
    64                                 fi 
    65  
    66                         exec 0>&9 9>&- 
    67  
     59                # Print a failure message with a list of any 
     60                # modules that may have failed to load. 
     61                if [ -n "${failedmod}" ]; then 
     62                        boot_mesg "Failed to load modules:${failedmod}" ${FAILURE} 
     63                        echo_failure 
    6864                fi 
    6965                ;;