- Timestamp:
- Oct 23, 2007, 1:07:58 AM (17 years ago)
- Branches:
- master
- Children:
- 1680407
- Parents:
- d8a3177
- Location:
- clfs
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
clfs/init.d/checkfs
rd8a3177 r1d02f01 67 67 # Note: -a option used to be -p; but this fails e.g. 68 68 # on fsck.minix 69 fsck ${options} -a -A -C -T 2>/dev/null69 fsck ${options} -a -A -C -T 70 70 error_value=${?} 71 71 -
clfs/init.d/functions
rd8a3177 r1d02f01 51 51 WCOL=$((${COL} - 2)) 52 52 53 ## Set Cursor Position Commands, used via echo -e 53 ## Provide an echo that supports -e and -n 54 # If formatting is needed, $ECHO should be used 55 case "`echo -e -n test`" in 56 -[en]*) 57 ECHO=/bin/echo 58 ;; 59 *) 60 ECHO=echo 61 ;; 62 esac 63 64 ## Set Cursor Position Commands, used via $ECHO 54 65 SET_COL="\\033[${COL}G" # at the $COL char 55 66 SET_WCOL="\\033[${WCOL}G" # at the $WCOL char 56 67 CURS_UP="\\033[1A\\033[0G" # Up one line, at the 0'th char 57 68 58 ## Set color commands, used via echo -e69 ## Set color commands, used via $ECHO 59 70 # Please consult `man console_codes for more information 60 71 # under the "ECMA-48 Set Graphics Rendition" section … … 115 126 116 127 ## Figure out the length of what is to be printed to be used 117 ## for warning messges. 118 STRING_LENGTH="`echo "${1}" | sed \ 119 -e 's,.,.,g' -e 'l 1' | grep -c \$`" 128 ## for warning messages. 129 STRING_LENGTH=$((${#1} + 1)) 120 130 121 131 # Print the message to the screen 122 echo ${ECHOPARM} -e "${2}${1}" 123 if [ "$LOGGING" ]; then 124 DISPLAYLOG="${1}" 125 fi 132 ${ECHO} ${ECHOPARM} -e "${2}${1}" 126 133 127 134 } … … 147 154 echo_ok() 148 155 { 149 echo -n -e "${CURS_UP}${SET_COL}${BRACKET}[${SUCCESS} OK ${BRACKET}]"150 echo -e "${NORMAL}"151 boot_mesg_flush "[ OK ]"152 156 if [ "$LCD_PROG" ]; then 153 157 if [ "$LCD_LINES" = "2" ]; then … … 157 161 LCD_OUT2="${LCD_OUT1:0:12} OK" 158 162 $LCD_PROG "$LCD_OUT2" > /dev/null 2>&1 159 fi 160 fi 163 fi 164 fi 165 ${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${SUCCESS} OK ${BRACKET}]" 166 ${ECHO} -e "${NORMAL}" 167 boot_mesg_flush 161 168 } 162 169 163 170 echo_failure() 164 171 { 165 echo -n -e "${CURS_UP}${SET_COL}${BRACKET}[${FAILURE} FAIL ${BRACKET}]"166 echo -e "${NORMAL}"167 boot_mesg_flush "[ FAIL ]"168 172 if [ "$LCD_PROG" ]; then 169 173 if [ "$LCD_LINES" = "2" ]; then … … 175 179 fi 176 180 fi 181 ${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${FAILURE} FAIL ${BRACKET}]" 182 ${ECHO} -e "${NORMAL}" 183 boot_mesg_flush 177 184 } 178 185 179 186 echo_warning() 180 187 { 181 echo -n -e "${CURS_UP}${SET_COL}${BRACKET}[${WARNING} WARN ${BRACKET}]"182 echo -e "${NORMAL}"183 188 if [ "$LCD_PROG" ]; then 184 189 if [ "$LCD_LINES" = "2" ]; then … … 188 193 LCD_OUT2="${LCD_OUT1:0:10} WARN" 189 194 $LCD_PROG "$LCD_OUT2" > /dev/null 2>&1 190 fi 191 fi 192 boot_mesg_flush "[ WARN ]" 195 fi 196 fi 197 ${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${WARNING} WARN ${BRACKET}]" 198 ${ECHO} -e "${NORMAL}" 199 boot_mesg_flush 193 200 } 194 201 … … 198 205 # $i is inherited by the rc script 199 206 boot_log "\n\n${i} failed and exited with a return value of ${error_value}." 200 boot_mesg_flush201 207 boot_mesg -n "FAILURE:\n\nYou should not be reading this error message.\n\n" ${FAILURE} 202 208 boot_mesg -n " It means that an unforeseen error took" … … 209 215 boot_mesg " clfs-dev@cross-lfs.org.\n" 210 216 boot_mesg_flush 211 if [ "$INTERACTIVE" ]; then 212 boot_mesg -n "Press Enter to continue..." ${INFO} 213 boot_mesg "" ${NORMAL} 214 if [ "$LCD_PROG" ]; then 215 sleep 10 216 else 217 read ENTER 218 fi 219 fi 217 boot_mesg -n "Press Enter to continue..." ${INFO} 218 boot_mesg "" ${NORMAL} 219 read ENTER 220 220 } 221 221 … … 258 258 fi 259 259 260 # boot_mesg_flush261 # echo_warning262 263 260 case "${1}" in 264 261 … … 272 269 case "${2}" in 273 270 running) 274 echo-e -n "${CURS_UP}"275 echo-e -n "\\033[${STRING_LENGTH}G "271 ${ECHO} -e -n "${CURS_UP}" 272 ${ECHO} -e -n "\\033[${STRING_LENGTH}G " 276 273 boot_mesg "Already running." ${WARNING} 277 274 echo_warning 278 275 ;; 279 276 not_running) 280 echo-e -n "${CURS_UP}"281 echo-e -n "\\033[${STRING_LENGTH}G "277 ${ECHO} -e -n "${CURS_UP}" 278 ${ECHO} -e -n "\\033[${STRING_LENGTH}G " 282 279 boot_mesg "Not running." ${WARNING} 283 280 echo_warning 284 281 ;; 285 282 not_available) 286 echo-e -n "${CURS_UP}"287 echo-e -n "\\033[${STRING_LENGTH}G "283 ${ECHO} -e -n "${CURS_UP}" 284 ${ECHO} -e -n "\\033[${STRING_LENGTH}G " 288 285 boot_mesg "Not available." ${WARNING} 289 286 echo_warning … … 307 304 reloadproc() 308 305 { 309 if [ "${#}" = "0" ]; then 310 echo "Usage: reloadproc [{program}]" 311 exit 1 312 fi 313 314 getpids "${1}" 306 local pidfile="" 307 local failure=0 308 309 while true 310 do 311 case "${1}" in 312 -p) 313 pidfile="${2}" 314 shift 2 315 ;; 316 -*) 317 log_failure_msg "Unknown Option: ${1}" 318 return 2 319 ;; 320 *) 321 break 322 ;; 323 esac 324 done 325 326 if [ "${#}" -lt "1" ]; then 327 log_failure_msg "Usage: reloadproc [-p pidfile] pathname" 328 return 2 329 fi 330 331 # This will ensure compatibility with previous CLFS Bootscripts 332 if [ -n "${PIDFILE}" ]; then 333 pidfile="${PIDFILE}" 334 fi 335 336 # Is the process running? 337 if [ -z "${pidfile}" ]; then 338 pidofproc -s "${1}" 339 else 340 pidofproc -s -p "${pidfile}" "${1}" 341 fi 315 342 316 343 if [ -n "${pidlist}" ]; then 317 failure="0"318 344 for pid in ${pidlist} 319 345 do … … 332 358 statusproc() 333 359 { 334 if [ "${#}" = "0" ] 335 then 336 echo "Usage: statusproc {program}" 337 exit 1 338 fi 339 340 getpids "${1}" 360 local pidfile="" 361 local base="" 362 local ret="" 363 364 while true 365 do 366 case "${1}" in 367 -p) 368 pidfile="${2}" 369 shift 2 370 ;; 371 -*) 372 log_failure_msg "Unknown Option: ${1}" 373 return 2 374 ;; 375 *) 376 break 377 ;; 378 esac 379 done 380 381 if [ "${#}" != "1" ]; then 382 shift 1 383 log_failure_msg "Usage: statusproc [-p pidfile] pathname" 384 return 2 385 fi 386 387 # Get the process basename 388 base="${1##*/}" 389 390 # This will ensure compatibility with previous CLFS Bootscripts 391 if [ -n "${PIDFILE}" ]; then 392 pidfile="${PIDFILE}" 393 fi 394 395 # Is the process running? 396 if [ -z "${pidfile}" ]; then 397 pidofproc -s "${1}" 398 else 399 pidofproc -s -p "${pidfile}" "${1}" 400 fi 401 402 # Store the return status 403 ret=$? 341 404 342 405 if [ -n "${pidlist}" ]; then 343 echo-e "${INFO}${base} is running with Process"\406 ${ECHO} -e "${INFO}${base} is running with Process"\ 344 407 "ID(s) ${pidlist}.${NORMAL}" 345 408 else 346 409 if [ -n "${base}" -a -e "/var/run/${base}.pid" ]; then 347 echo-e "${WARNING}${1} is not running but"\410 ${ECHO} -e "${WARNING}${1} is not running but"\ 348 411 "/var/run/${base}.pid exists.${NORMAL}" 349 412 else 350 if [ -n "${ PIDFILE}" -a -e "${PIDFILE}" ]; then351 echo-e "${WARNING}${1} is not running"\352 "but ${ PIDFILE} exists.${NORMAL}"413 if [ -n "${pidfile}" -a -e "${pidfile}" ]; then 414 ${ECHO} -e "${WARNING}${1} is not running"\ 415 "but ${pidfile} exists.${NORMAL}" 353 416 else 354 echo-e "${INFO}${1} is not running.${NORMAL}"417 ${ECHO} -e "${INFO}${1} is not running.${NORMAL}" 355 418 fi 356 419 fi 357 420 fi 421 422 # Return the status from pidofproc 423 return $ret 358 424 } 359 425 … … 426 492 do 427 493 if [ "${pid}" -ne "$$" -a "${pid}" -ne "${PPID}" ]; then 428 kill -0 "${pid}" >/dev/null &&494 kill -0 "${pid}" 2>/dev/null && 429 495 pidlist="${pidlist} ${pid}" 430 496 fi 431 497 432 if [ "${silent}" -ne"1" ]; then498 if [ "${silent}" != "1" ]; then 433 499 echo "${pidlist}" 434 500 fi … … 443 509 else 444 510 pidlist=`pidof -o $$ -o $PPID -x "$1"` 445 if [ " x${silent}" != "x1" ]; then511 if [ "${silent}" != "1" ]; then 446 512 echo "${pidlist}" 447 513 fi … … 592 658 { 593 659 local pidfile="" 594 local killsig= ""660 local killsig=TERM # default signal is SIGTERM 595 661 pidlist="" 596 662 597 # This will ensure compatibility with previous CLFS Bootscripts663 # This will ensure compatibility with previous CLFS Bootscripts 598 664 if [ -n "${PIDFILE}" ]; then 599 665 pidfile="${PIDFILE}" … … 610 676 log_failure_msg "Unknown Option: ${1}" 611 677 return 2 612 ;;678 ;; 613 679 *) 614 680 break … … 625 691 fi 626 692 693 # Is the process running? 627 694 if [ -z "${pidfile}" ]; then 628 695 pidofproc -s "${1}" … … 631 698 fi 632 699 633 # Change....700 # If running, send the signal 634 701 if [ -n "${pidlist}" ]; then 635 702 for pid in ${pidlist} 636 703 do 637 kill -${killsig:-TERM} ${pid} 2>/dev/null 638 if [ -z "${killsig}" ]; then 639 # Wait up to 3 seconds, for ${pid} to terminate 640 local dtime=${KILLDELAY} 704 kill -${killsig} ${pid} 2>/dev/null 705 706 # Wait up to 3 seconds, for ${pid} to terminate 707 case "${killsig}" in 708 TERM|SIGTERM|KILL|SIGKILL) 709 # sleep in 1/10ths of seconds and 710 # multiply KILLDELAY by 10 711 local dtime="${KILLDELAY}0" 641 712 while [ "${dtime}" != "0" ] 642 713 do 643 714 kill -0 ${pid} 2>/dev/null || break 644 sleep 1715 sleep 0.1 645 716 dtime=$(( ${dtime} - 1)) 646 717 done 647 718 # If ${pid} is still running, kill it 648 719 kill -0 ${pid} 2>/dev/null && kill -KILL ${pid} 2>/dev/null 649 fi 720 ;; 721 esac 650 722 done 651 723 652 if [ -z "${killsig}" ]; then 653 pidofproc -s "${1}" 724 # Check if the process is still running if we tried to stop it 725 case "${killsig}" in 726 TERM|SIGTERM|KILL|SIGKILL) 727 if [ -z "${pidfile}" ]; then 728 pidofproc -s "${1}" 729 else 730 pidofproc -s -p "${pidfile}" "${1}" 731 fi 654 732 655 733 # Program was terminated 656 734 if [ "$?" != "0" ]; then 657 # Pidfile Exists735 # Remove the pidfile if necessary 658 736 if [ -f "${pidfile}" ]; then 659 737 rm -f "${pidfile}" … … 665 743 return 4 # Unknown Status 666 744 fi 667 else 668 if [ -z "${pidfile}" ]; then 669 pidofproc -s "${1}" 670 else 671 pidofproc -s -p "${pidfile}" "${1}" 672 fi 673 fi 674 675 evaluate_retval # This is "Probably" not LSB compliant, but required to be compatible with older bootscripts 676 677 else 745 ;; 746 *) 747 # Just see if the kill returned successfully 748 evaluate_retval 749 ;; 750 esac 751 else # process not running 678 752 print_status warning not_running 679 753 fi … … 697 771 log_success_msg() 698 772 { 699 echo-n -e "${BOOTMESG_PREFIX}${@}"700 echo-e "${SET_COL}""${BRACKET}""[""${SUCCESS}"" OK ""${BRACKET}""]""${NORMAL}"773 ${ECHO} -n -e "${BOOTMESG_PREFIX}${@}" 774 ${ECHO} -e "${SET_COL}""${BRACKET}""[""${SUCCESS}"" OK ""${BRACKET}""]""${NORMAL}" 701 775 return 0 702 776 } … … 717 791 #******************************************************************************* 718 792 log_failure_msg() { 719 echo-n -e "${BOOTMESG_PREFIX}${@}"720 echo-e "${SET_COL}""${BRACKET}""[""${FAILURE}"" FAIL ""${BRACKET}""]""${NORMAL}"793 ${ECHO} -n -e "${BOOTMESG_PREFIX}${@}" 794 ${ECHO} -e "${SET_COL}""${BRACKET}""[""${FAILURE}"" FAIL ""${BRACKET}""]""${NORMAL}" 721 795 return 0 722 796 } … … 737 811 #******************************************************************************* 738 812 log_warning_msg() { 739 echo-n -e "${BOOTMESG_PREFIX}${@}"740 echo-e "${SET_COL}""${BRACKET}""[""${WARNING}"" WARN ""${BRACKET}""]""${NORMAL}"813 ${ECHO} -n -e "${BOOTMESG_PREFIX}${@}" 814 ${ECHO} -e "${SET_COL}""${BRACKET}""[""${WARNING}"" WARN ""${BRACKET}""]""${NORMAL}" 741 815 return 0 742 816 } -
clfs/init.d/localnet
rd8a3177 r1d02f01 20 20 start) 21 21 boot_mesg "Bringing up the loopback interface..." 22 ip addr add 127.0.0.1/8 label lo dev lo 22 23 ip link set lo up 23 24 evaluate_retval -
clfs/init.d/modules
rd8a3177 r1d02f01 22 22 start) 23 23 24 # If proc is mounted, find the current kernel 25 # message level 26 if [ -f /proc/sys/kernel/printk ]; then 27 prev_msg=`cat /proc/sys/kernel/printk | \ 28 sed 'l 1' | sed -n '2~0p' | \ 29 sed 's/\\\//'` 30 else 31 prev_msg="6" 32 fi 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 33 29 34 # Now set the message level to 1 so not to make too 35 # much noise when loading modules 36 dmesg -n 1 30 boot_mesg -n "Loading modules:" ${INFO} 37 31 38 32 # Only try to load modules if the user has actually given us 39 33 # some modules to load. 40 if egrep -qv '^(#|$)' /etc/sysconfig/modules 2>/dev/null 41 then 34 while read module args; do 42 35 43 # Read in the configuration file. 44 exec 9>&0 < /etc/sysconfig/modules 36 # Ignore comments and blank lines. 37 case "$module" in 38 ""|"#"*) continue ;; 39 esac 45 40 46 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 47 44 48 while read module args 49 do 50 # Ignore comments and blank lines. 51 case "${module}" in 52 ""|\#*) continue ;; 53 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 54 53 55 # Attempt to load the module, making 56 # sure to pass any arguments provided. 57 modprobe ${module} ${args} 2>&1 > /dev/null 54 boot_mesg "" ${NORMAL} 55 # Print a message about successfully loaded 56 # modules on the correct line. 57 echo_ok 58 58 59 # Print the module name if successful, 60 # otherwise take note. 61 if [ ${?} -eq 0 ]; then 62 boot_mesg -n " ${module}" ${NORMAL} 63 else 64 failedmod="${failedmod} ${module}" 65 fi 66 done 67 68 boot_mesg "" ${NORMAL} 69 # Print a message about successfully loaded 70 # modules on the correct line. 71 echo_ok 72 73 # Print a failure message with a list of any 74 # modules that may have failed to load. 75 if [ "${failedmod}" ]; then 76 boot_mesg "Failed to load modules:${failedmod}" ${FAILURE} 77 echo_failure 78 fi 79 80 exec 0>&9 9>&- 81 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 82 64 fi 83 # Set the kernel message level back to it's previous value.84 dmesg -n "${prev_msg}"85 65 ;; 86 66 *) -
clfs/init.d/mountfs
rd8a3177 r1d02f01 19 19 start) 20 20 boot_mesg "Remounting root file system in read-write mode..." 21 mount -n -o remount,rw / &>/dev/null21 mount -n -o remount,rw / >/dev/null 22 22 evaluate_retval 23 23 … … 36 36 # their option list. _netdev denotes a network filesystem. 37 37 boot_mesg "Mounting remaining file systems..." 38 mount -a -O no_netdev &>/dev/null38 mount -a -O no_netdev >/dev/null 39 39 evaluate_retval 40 40 ;; … … 42 42 stop) 43 43 boot_mesg "Unmounting all other currently mounted file systems..." 44 umount -a -d -r &>/dev/null44 umount -a -d -r >/dev/null 45 45 evaluate_retval 46 46 ;; -
clfs/init.d/mountkernfs
rd8a3177 r1d02f01 20 20 boot_mesg -n "Mounting kernel-based file systems:" ${INFO} 21 21 22 if ! mountpoint /proc &>/dev/null; then22 if ! mountpoint /proc >/dev/null; then 23 23 boot_mesg -n " /proc" ${NORMAL} 24 24 mount -n /proc || failed=1 25 25 fi 26 26 27 if ! mountpoint /sys &>/dev/null; then27 if ! mountpoint /sys >/dev/null; then 28 28 boot_mesg -n " /sys" ${NORMAL} 29 29 mount -n /sys || failed=1 -
clfs/init.d/setclock
rd8a3177 r1d02f01 33 33 start) 34 34 boot_mesg "Setting system clock..." 35 hwclock --hctosys ${CLOCKPARAMS} &>/dev/null35 hwclock --hctosys ${CLOCKPARAMS} >/dev/null 36 36 evaluate_retval 37 37 ;; … … 39 39 stop) 40 40 boot_mesg "Setting hardware clock..." 41 hwclock --systohc ${CLOCKPARAMS} &>/dev/null41 hwclock --systohc ${CLOCKPARAMS} >/dev/null 42 42 evaluate_retval 43 43 ;; 44 44 45 45 *) 46 echo "Usage: ${0} {start }"46 echo "Usage: ${0} {start|stop}" 47 47 ;; 48 48 -
clfs/init.d/sysklogd
rd8a3177 r1d02f01 35 35 reload) 36 36 boot_mesg "Reloading system log daemon config file..." 37 reloadproc syslogd 137 reloadproc syslogd 38 38 ;; 39 39 -
clfs/sysconfig/network-devices/services/ipv4-static
rd8a3177 r1d02f01 44 44 fi 45 45 46 if [ -n "${SOURCE}" ]; then47 args="${args} src ${SOURCE}"48 fi49 50 46 case "${2}" in 51 47 up) 52 48 boot_mesg "Adding IPv4 address ${IP} to the ${1} interface..." 53 if [ "${INTERFACE}" != "" ]; then 54 ip addr add ${args} dev ${1} label ${1} 55 else 56 ip addr add ${args} dev ${1} 57 fi 49 ip addr add ${args} dev ${1} 58 50 evaluate_retval 59 51 60 if [ "${INTERFACE}" = "" ]; then 61 if [ -n "${GATEWAY}" ]; then 62 if ip route | grep -q default; then 63 boot_mesg "Gateway already setup; skipping." ${WARNING} 64 echo_warning 65 else 66 boot_mesg "Setting up default gateway..." 67 ip route add default via ${GATEWAY} dev ${1} 68 evaluate_retval 69 fi 70 fi 52 if [ -n "${GATEWAY}" ]; then 53 if ip route | grep -q default; then 54 boot_mesg "Gateway already setup; skipping." ${WARNING} 55 echo_warning 56 else 57 boot_mesg "Setting up default gateway..." 58 ip route add default via ${GATEWAY} dev ${1} 59 evaluate_retval 60 fi 71 61 fi 72 62 ;; 73 63 74 64 down) 75 if [ "${INTERFACE}" = "" ];then76 boot_mesg "Removing Settings From ${1} interface..."77 ip address flush dev ${1}65 if [ -n "${GATEWAY}" ]; then 66 boot_mesg "Removing default gateway..." 67 ip route del default 78 68 evaluate_retval 79 69 fi 70 71 boot_mesg "Removing IPv4 address ${IP} from the ${1} interface..." 72 ip addr del ${args} dev ${1} 73 evaluate_retval 80 74 ;; 81 75 -
clfs/sysconfig/network-devices/services/ipv4-static-route
rd8a3177 r1d02f01 72 72 fi 73 73 74 if [ -n "${SOURCE}" ]; then 75 args="${args} src ${SOURCE}" 76 fi 77 74 78 case "${2}" in 75 79 up)
Note:
See TracChangeset
for help on using the changeset viewer.