functions 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  1. #!/bin/sh
  2. ########################################################################
  3. # Begin boot functions
  4. #
  5. # Description : Run Level Control Functions
  6. #
  7. # Authors : Gerard Beekmans - gerard@linuxfromscratch.org
  8. # Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
  9. #
  10. # Version : LFS 7.0
  11. #
  12. # Notes : With code based on Matthias Benkmann's simpleinit-msb
  13. # http://winterdrache.de/linux/newboot/index.html
  14. #
  15. # The file should be located in /lib/boot
  16. #
  17. ########################################################################
  18. # Set any needed environment variables e.g. HEADLESS
  19. [ -r /etc/sysconfig/init_params ] && . /etc/sysconfig/init_params
  20. ## Environmental setup
  21. # Setup default values for environment
  22. umask 022
  23. export PATH="/bin:/usr/bin:/sbin:/usr/sbin"
  24. # Signal sent to running processes to refresh their configuration
  25. RELOADSIG="HUP"
  26. # Number of seconds between STOPSIG and FALLBACK when stopping processes
  27. KILLDELAY="3"
  28. ## Screen Dimensions
  29. # Find current screen size
  30. if [ -z "${COLUMNS}" ]; then
  31. COLUMNS=$(stty size)
  32. COLUMNS=${COLUMNS##* }
  33. fi
  34. # When using remote connections, such as a serial port, stty size returns 0
  35. if [ "${COLUMNS}" = "0" ]; then
  36. COLUMNS=80
  37. fi
  38. ## Measurements for positioning result messages
  39. COL=$((${COLUMNS} - 8))
  40. WCOL=$((${COL} - 2))
  41. ## Provide an echo that supports -e and -n
  42. # If formatting is needed, $ECHO should be used
  43. case "`echo -e -n test`" in
  44. -[en]*)
  45. ECHO=/bin/echo
  46. ;;
  47. *)
  48. ECHO=echo
  49. ;;
  50. esac
  51. ## Set Cursor Position Commands, used via $ECHO
  52. SET_COL="\\033[${COL}G" # at the $COL char
  53. SET_WCOL="\\033[${WCOL}G" # at the $WCOL char
  54. CURS_UP="\\033[1A\\033[0G" # Up one line, at the 0'th char
  55. ## Set color commands, used via $ECHO
  56. # Please consult `man console_codes for more information
  57. # under the "ECMA-48 Set Graphics Rendition" section
  58. #
  59. # Warning: when switching from a 8bit to a 9bit font,
  60. # the linux console will reinterpret the bold (1;) to
  61. # the top 256 glyphs of the 9bit font. This does
  62. # not affect framebuffer consoles
  63. NORMAL="\\033[0;39m" # Standard console grey
  64. SUCCESS="\\033[1;32m" # Success is green
  65. WARNING="\\033[1;33m" # Warnings are yellow
  66. FAILURE="\\033[1;31m" # Failures are red
  67. INFO="\\033[1;36m" # Information is light cyan
  68. BRACKET="\\033[1;34m" # Brackets are blue
  69. STRING_LENGTH="0" # the length of the current message
  70. #*******************************************************************************
  71. # Function - boot_mesg()
  72. #
  73. # Purpose: Sending information from bootup scripts to the console
  74. #
  75. # Inputs: $1 is the message
  76. # $2 is the colorcode for the console
  77. #
  78. # Outputs: Standard Output
  79. #
  80. # Dependencies: - sed for parsing strings.
  81. # - grep for counting string length.
  82. #
  83. # Todo:
  84. #*******************************************************************************
  85. boot_mesg()
  86. {
  87. local ECHOPARM=""
  88. while true
  89. do
  90. case "${1}" in
  91. -n)
  92. ECHOPARM=" -n "
  93. shift 1
  94. ;;
  95. -*)
  96. echo "Unknown Option: ${1}"
  97. return 1
  98. ;;
  99. *)
  100. break
  101. ;;
  102. esac
  103. done
  104. ## Figure out the length of what is to be printed to be used
  105. ## for warning messages.
  106. STRING_LENGTH=$((${#1} + 1))
  107. # Print the message to the screen
  108. ${ECHO} ${ECHOPARM} -e "${2}${1}"
  109. # Log the message
  110. ${ECHO} ${ECHOPARM} -e "${2}${1}" >> /run/var/bootlog
  111. }
  112. boot_mesg_flush()
  113. {
  114. # Reset STRING_LENGTH for next message
  115. STRING_LENGTH="0"
  116. }
  117. echo_ok()
  118. {
  119. ${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${SUCCESS} OK ${BRACKET}]"
  120. ${ECHO} -e "${NORMAL}"
  121. boot_mesg_flush
  122. ${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${SUCCESS} OK ${BRACKET}]" >> /run/var/bootlog
  123. ${ECHO} -e "${NORMAL}" >> /run/var/bootlog
  124. }
  125. echo_failure()
  126. {
  127. ${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${FAILURE} FAIL ${BRACKET}]"
  128. ${ECHO} -e "${NORMAL}"
  129. boot_mesg_flush
  130. ${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${FAILURE} FAIL ${BRACKET}]" >> /run/var/bootlog
  131. ${ECHO} -e "${NORMAL}" >> /run/var/bootlog
  132. }
  133. echo_warning()
  134. {
  135. ${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${WARNING} WARN ${BRACKET}]"
  136. ${ECHO} -e "${NORMAL}"
  137. boot_mesg_flush
  138. ${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${WARNING} WARN ${BRACKET}]" >> /run/var/bootlog
  139. ${ECHO} -e "${NORMAL}" >> /run/var/bootlog
  140. }
  141. echo_skipped()
  142. {
  143. ${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${WARNING} SKIP ${BRACKET}]"
  144. ${ECHO} -e "${NORMAL}"
  145. boot_mesg_flush
  146. ${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${WARNING} SKIP ${BRACKET}]" >> /run/var/bootlog
  147. ${ECHO} -e "${NORMAL}" >> /run/var/bootlog
  148. }
  149. wait_for_user()
  150. {
  151. # Wait for the user by default
  152. [ "${HEADLESS=0}" = "0" ] && read ENTER
  153. }
  154. evaluate_retval()
  155. {
  156. error_value="${?}"
  157. if [ ${error_value} = 0 ]; then
  158. echo_ok
  159. else
  160. echo_failure
  161. fi
  162. # This prevents the 'An Unexpected Error Has Occurred' from trivial
  163. # errors.
  164. return 0
  165. }
  166. print_status()
  167. {
  168. if [ "${#}" = "0" ]; then
  169. echo "Usage: ${0} {success|warning|failure}"
  170. return 1
  171. fi
  172. case "${1}" in
  173. success)
  174. echo_ok
  175. ;;
  176. warning)
  177. # Leave this extra case in because old scripts
  178. # may call it this way.
  179. case "${2}" in
  180. running)
  181. ${ECHO} -e -n "${CURS_UP}"
  182. ${ECHO} -e -n "\\033[${STRING_LENGTH}G "
  183. boot_mesg "Already running." ${WARNING}
  184. echo_warning
  185. ;;
  186. not_running)
  187. ${ECHO} -e -n "${CURS_UP}"
  188. ${ECHO} -e -n "\\033[${STRING_LENGTH}G "
  189. boot_mesg "Not running." ${WARNING}
  190. echo_warning
  191. ;;
  192. not_available)
  193. ${ECHO} -e -n "${CURS_UP}"
  194. ${ECHO} -e -n "\\033[${STRING_LENGTH}G "
  195. boot_mesg "Not available." ${WARNING}
  196. echo_warning
  197. ;;
  198. *)
  199. # This is how it is supposed to
  200. # be called
  201. echo_warning
  202. ;;
  203. esac
  204. ;;
  205. failure)
  206. echo_failure
  207. ;;
  208. esac
  209. }
  210. reloadproc()
  211. {
  212. local pidfile=""
  213. local failure=0
  214. while true
  215. do
  216. case "${1}" in
  217. -p)
  218. pidfile="${2}"
  219. shift 2
  220. ;;
  221. -*)
  222. log_failure_msg "Unknown Option: ${1}"
  223. return 2
  224. ;;
  225. *)
  226. break
  227. ;;
  228. esac
  229. done
  230. if [ "${#}" -lt "1" ]; then
  231. log_failure_msg "Usage: reloadproc [-p pidfile] pathname"
  232. return 2
  233. fi
  234. # This will ensure compatibility with previous LFS Bootscripts
  235. if [ -n "${PIDFILE}" ]; then
  236. pidfile="${PIDFILE}"
  237. fi
  238. # Is the process running?
  239. if [ -z "${pidfile}" ]; then
  240. pidofproc -s "${1}"
  241. else
  242. pidofproc -s -p "${pidfile}" "${1}"
  243. fi
  244. # Warn about stale pid file
  245. if [ "$?" = 1 ]; then
  246. boot_mesg -n "Removing stale pid file: ${pidfile}. " ${WARNING}
  247. rm -f "${pidfile}"
  248. fi
  249. if [ -n "${pidlist}" ]; then
  250. for pid in ${pidlist}
  251. do
  252. kill -"${RELOADSIG}" "${pid}" || failure="1"
  253. done
  254. (exit ${failure})
  255. evaluate_retval
  256. else
  257. boot_mesg "Process ${1} not running." ${WARNING}
  258. echo_warning
  259. fi
  260. }
  261. statusproc()
  262. {
  263. local pidfile=""
  264. local base=""
  265. local ret=""
  266. while true
  267. do
  268. case "${1}" in
  269. -p)
  270. pidfile="${2}"
  271. shift 2
  272. ;;
  273. -*)
  274. log_failure_msg "Unknown Option: ${1}"
  275. return 2
  276. ;;
  277. *)
  278. break
  279. ;;
  280. esac
  281. done
  282. if [ "${#}" != "1" ]; then
  283. shift 1
  284. log_failure_msg "Usage: statusproc [-p pidfile] pathname"
  285. return 2
  286. fi
  287. # Get the process basename
  288. base="${1##*/}"
  289. # This will ensure compatibility with previous LFS Bootscripts
  290. if [ -n "${PIDFILE}" ]; then
  291. pidfile="${PIDFILE}"
  292. fi
  293. # Is the process running?
  294. if [ -z "${pidfile}" ]; then
  295. pidofproc -s "${1}"
  296. else
  297. pidofproc -s -p "${pidfile}" "${1}"
  298. fi
  299. # Store the return status
  300. ret=$?
  301. if [ -n "${pidlist}" ]; then
  302. ${ECHO} -e "${INFO}${base} is running with Process"\
  303. "ID(s) ${pidlist}.${NORMAL}"
  304. else
  305. if [ -n "${base}" -a -e "/var/run/${base}.pid" ]; then
  306. ${ECHO} -e "${WARNING}${1} is not running but"\
  307. "/var/run/${base}.pid exists.${NORMAL}"
  308. else
  309. if [ -n "${pidfile}" -a -e "${pidfile}" ]; then
  310. ${ECHO} -e "${WARNING}${1} is not running"\
  311. "but ${pidfile} exists.${NORMAL}"
  312. else
  313. ${ECHO} -e "${INFO}${1} is not running.${NORMAL}"
  314. fi
  315. fi
  316. fi
  317. # Return the status from pidofproc
  318. return $ret
  319. }
  320. # The below functions are documented in the LSB-generic 2.1.0
  321. #*******************************************************************************
  322. # Function - pidofproc [-s] [-p pidfile] pathname
  323. #
  324. # Purpose: This function returns one or more pid(s) for a particular daemon
  325. #
  326. # Inputs: -p pidfile, use the specified pidfile instead of pidof
  327. # pathname, path to the specified program
  328. #
  329. # Outputs: return 0 - Success, pid's in stdout
  330. # return 1 - Program is dead, pidfile exists
  331. # return 2 - Invalid or excessive number of arguments,
  332. # warning in stdout
  333. # return 3 - Program is not running
  334. #
  335. # Dependencies: pidof, echo, head
  336. #
  337. # Todo: Remove dependency on head
  338. # This replaces getpids
  339. # Test changes to pidof
  340. #
  341. #*******************************************************************************
  342. pidofproc()
  343. {
  344. local pidfile=""
  345. local lpids=""
  346. local silent=""
  347. pidlist=""
  348. while true
  349. do
  350. case "${1}" in
  351. -p)
  352. pidfile="${2}"
  353. shift 2
  354. ;;
  355. -s)
  356. # Added for legacy opperation of getpids
  357. # eliminates several '> /dev/null'
  358. silent="1"
  359. shift 1
  360. ;;
  361. -*)
  362. log_failure_msg "Unknown Option: ${1}"
  363. return 2
  364. ;;
  365. *)
  366. break
  367. ;;
  368. esac
  369. done
  370. if [ "${#}" != "1" ]; then
  371. shift 1
  372. log_failure_msg "Usage: pidofproc [-s] [-p pidfile] pathname"
  373. return 2
  374. fi
  375. if [ -n "${pidfile}" ]; then
  376. if [ ! -r "${pidfile}" ]; then
  377. return 3 # Program is not running
  378. fi
  379. lpids=`head -n 1 ${pidfile}`
  380. for pid in ${lpids}
  381. do
  382. if [ "${pid}" -ne "$$" -a "${pid}" -ne "${PPID}" ]; then
  383. kill -0 "${pid}" 2>/dev/null &&
  384. pidlist="${pidlist} ${pid}"
  385. fi
  386. if [ "${silent}" != "1" ]; then
  387. echo "${pidlist}"
  388. fi
  389. test -z "${pidlist}" &&
  390. # Program is dead, pidfile exists
  391. return 1
  392. # else
  393. return 0
  394. done
  395. else
  396. pidlist=`pidof -o $$ -o $PPID -x "$1"`
  397. if [ "${silent}" != "1" ]; then
  398. echo "${pidlist}"
  399. fi
  400. # Get provide correct running status
  401. if [ -n "${pidlist}" ]; then
  402. return 0
  403. else
  404. return 3
  405. fi
  406. fi
  407. if [ "$?" != "0" ]; then
  408. return 3 # Program is not running
  409. fi
  410. }
  411. #*******************************************************************************
  412. # Function - loadproc [-f] [-n nicelevel] [-p pidfile] pathname [args]
  413. #
  414. # Purpose: This runs the specified program as a daemon
  415. #
  416. # Inputs: -f, run the program even if it is already running
  417. # -n nicelevel, specifies a nice level. See nice(1).
  418. # -p pidfile, uses the specified pidfile
  419. # pathname, pathname to the specified program
  420. # args, arguments to pass to specified program
  421. #
  422. # Outputs: return 0 - Success
  423. # return 2 - Invalid of excessive number of arguments,
  424. # warning in stdout
  425. # return 4 - Program or service status is unknown
  426. #
  427. # Dependencies: nice, rm
  428. #
  429. # Todo: LSB says this should be called start_daemon
  430. # LSB does not say that it should call evaluate_retval
  431. # It checks for PIDFILE, which is deprecated.
  432. # Will be removed after BLFS 6.0
  433. # loadproc returns 0 if program is already running, not LSB compliant
  434. #
  435. #*******************************************************************************
  436. loadproc()
  437. {
  438. local pidfile=""
  439. local forcestart=""
  440. local nicelevel="10"
  441. # This will ensure compatibility with previous LFS Bootscripts
  442. if [ -n "${PIDFILE}" ]; then
  443. pidfile="${PIDFILE}"
  444. fi
  445. while true
  446. do
  447. case "${1}" in
  448. -f)
  449. forcestart="1"
  450. shift 1
  451. ;;
  452. -n)
  453. nicelevel="${2}"
  454. shift 2
  455. ;;
  456. -p)
  457. pidfile="${2}"
  458. shift 2
  459. ;;
  460. -*)
  461. log_failure_msg "Unknown Option: ${1}"
  462. return 2 #invalid or excess argument(s)
  463. ;;
  464. *)
  465. break
  466. ;;
  467. esac
  468. done
  469. if [ "${#}" = "0" ]; then
  470. log_failure_msg "Usage: loadproc [-f] [-n nicelevel] [-p pidfile] pathname [args]"
  471. return 2 #invalid or excess argument(s)
  472. fi
  473. if [ -z "${forcestart}" ]; then
  474. if [ -z "${pidfile}" ]; then
  475. pidofproc -s "${1}"
  476. else
  477. pidofproc -s -p "${pidfile}" "${1}"
  478. fi
  479. case "${?}" in
  480. 0)
  481. log_warning_msg "Unable to continue: ${1} is running"
  482. return 0 # 4
  483. ;;
  484. 1)
  485. boot_mesg "Removing stale pid file: ${pidfile}" ${WARNING}
  486. rm -f "${pidfile}"
  487. ;;
  488. 3)
  489. ;;
  490. *)
  491. log_failure_msg "Unknown error code from pidofproc: ${?}"
  492. return 4
  493. ;;
  494. esac
  495. fi
  496. nice -n "${nicelevel}" "${@}"
  497. evaluate_retval # This is "Probably" not LSB compliant,
  498. # but required to be compatible with older bootscripts
  499. return 0
  500. }
  501. #*******************************************************************************
  502. # Function - killproc [-p pidfile] pathname [signal]
  503. #
  504. # Purpose:
  505. #
  506. # Inputs: -p pidfile, uses the specified pidfile
  507. # pathname, pathname to the specified program
  508. # signal, send this signal to pathname
  509. #
  510. # Outputs: return 0 - Success
  511. # return 2 - Invalid of excessive number of arguments,
  512. # warning in stdout
  513. # return 4 - Unknown Status
  514. #
  515. # Dependencies: kill, rm
  516. #
  517. # Todo: LSB does not say that it should call evaluate_retval
  518. # It checks for PIDFILE, which is deprecated.
  519. # Will be removed after BLFS 6.0
  520. #
  521. #*******************************************************************************
  522. killproc()
  523. {
  524. local pidfile=""
  525. local killsig=TERM # default signal is SIGTERM
  526. pidlist=""
  527. # This will ensure compatibility with previous LFS Bootscripts
  528. if [ -n "${PIDFILE}" ]; then
  529. pidfile="${PIDFILE}"
  530. fi
  531. while true
  532. do
  533. case "${1}" in
  534. -p)
  535. pidfile="${2}"
  536. shift 2
  537. ;;
  538. -*)
  539. log_failure_msg "Unknown Option: ${1}"
  540. return 2
  541. ;;
  542. *)
  543. break
  544. ;;
  545. esac
  546. done
  547. if [ "${#}" = "2" ]; then
  548. killsig="${2}"
  549. elif [ "${#}" != "1" ]; then
  550. shift 2
  551. log_failure_msg "Usage: killproc [-p pidfile] pathname [signal]"
  552. return 2
  553. fi
  554. # Is the process running?
  555. if [ -z "${pidfile}" ]; then
  556. pidofproc -s "${1}"
  557. else
  558. pidofproc -s -p "${pidfile}" "${1}"
  559. fi
  560. # Remove stale pidfile
  561. if [ "$?" = 1 ]; then
  562. boot_mesg "Removing stale pid file: ${pidfile}." ${WARNING}
  563. rm -f "${pidfile}"
  564. fi
  565. # If running, send the signal
  566. if [ -n "${pidlist}" ]; then
  567. for pid in ${pidlist}
  568. do
  569. kill -${killsig} ${pid} 2>/dev/null
  570. # Wait up to 3 seconds, for ${pid} to terminate
  571. case "${killsig}" in
  572. TERM|SIGTERM|KILL|SIGKILL)
  573. # sleep in 1/10ths of seconds and
  574. # multiply KILLDELAY by 10
  575. local dtime="${KILLDELAY}0"
  576. while [ "${dtime}" != "0" ]
  577. do
  578. kill -0 ${pid} 2>/dev/null || break
  579. sleep 0.1
  580. dtime=$(( ${dtime} - 1))
  581. done
  582. # If ${pid} is still running, kill it
  583. kill -0 ${pid} 2>/dev/null && kill -KILL ${pid} 2>/dev/null
  584. ;;
  585. esac
  586. done
  587. # Check if the process is still running if we tried to stop it
  588. case "${killsig}" in
  589. TERM|SIGTERM|KILL|SIGKILL)
  590. if [ -z "${pidfile}" ]; then
  591. pidofproc -s "${1}"
  592. else
  593. pidofproc -s -p "${pidfile}" "${1}"
  594. fi
  595. # Program was terminated
  596. if [ "$?" != "0" ]; then
  597. # Remove the pidfile if necessary
  598. if [ -f "${pidfile}" ]; then
  599. rm -f "${pidfile}"
  600. fi
  601. echo_ok
  602. return 0
  603. else # Program is still running
  604. echo_failure
  605. return 4 # Unknown Status
  606. fi
  607. ;;
  608. *)
  609. # Just see if the kill returned successfully
  610. evaluate_retval
  611. ;;
  612. esac
  613. else # process not running
  614. print_status warning not_running
  615. fi
  616. }
  617. #*******************************************************************************
  618. # Function - log_success_msg "message"
  619. #
  620. # Purpose: Print a success message
  621. #
  622. # Inputs: $@ - Message
  623. #
  624. # Outputs: Text output to screen
  625. #
  626. # Dependencies: echo
  627. #
  628. # Todo: logging
  629. #
  630. #*******************************************************************************
  631. log_success_msg()
  632. {
  633. ${ECHO} -n -e "${BOOTMESG_PREFIX}${@}"
  634. ${ECHO} -e "${SET_COL}""${BRACKET}""[""${SUCCESS}"" OK ""${BRACKET}""]""${NORMAL}"
  635. ${ECHO} -n -e "${BOOTMESG_PREFIX}${@}" >> /run/var/bootlog
  636. ${ECHO} -e "${SET_COL}""${BRACKET}""[""${SUCCESS}"" OK ""${BRACKET}""]""${NORMAL}" \
  637. >> /run/var/bootlog
  638. return 0
  639. }
  640. #*******************************************************************************
  641. # Function - log_failure_msg "message"
  642. #
  643. # Purpose: Print a failure message
  644. #
  645. # Inputs: $@ - Message
  646. #
  647. # Outputs: Text output to screen
  648. #
  649. # Dependencies: echo
  650. #
  651. # Todo: logging
  652. #
  653. #*******************************************************************************
  654. log_failure_msg() {
  655. ${ECHO} -n -e "${BOOTMESG_PREFIX}${@}"
  656. ${ECHO} -e "${SET_COL}""${BRACKET}""[""${FAILURE}"" FAIL ""${BRACKET}""]""${NORMAL}"
  657. ${ECHO} -n -e "${BOOTMESG_PREFIX}${@}" >> /run/var/bootlog
  658. ${ECHO} -e "${SET_COL}""${BRACKET}""[""${FAILURE}"" FAIL ""${BRACKET}""]""${NORMAL}" \
  659. >> /run/var/bootlog
  660. return 0
  661. }
  662. #*******************************************************************************
  663. # Function - log_warning_msg "message"
  664. #
  665. # Purpose: print a warning message
  666. #
  667. # Inputs: $@ - Message
  668. #
  669. # Outputs: Text output to screen
  670. #
  671. # Dependencies: echo
  672. #
  673. # Todo: logging
  674. #
  675. #*******************************************************************************
  676. log_warning_msg() {
  677. ${ECHO} -n -e "${BOOTMESG_PREFIX}${@}"
  678. ${ECHO} -e "${SET_COL}""${BRACKET}""[""${WARNING}"" WARN ""${BRACKET}""]""${NORMAL}"
  679. ${ECHO} -n -e "${BOOTMESG_PREFIX}${@}" >> /run/var/bootlog
  680. ${ECHO} -e "${SET_COL}""${BRACKET}""[""${WARNING}"" WARN ""${BRACKET}""]""${NORMAL}" \
  681. >> /run/var/bootlog
  682. return 0
  683. }
  684. #*******************************************************************************
  685. # Function - log_skipped_msg "message"
  686. #
  687. # Purpose: print a message that the script was skipped
  688. #
  689. # Inputs: $@ - Message
  690. #
  691. # Outputs: Text output to screen
  692. #
  693. # Dependencies: echo
  694. #
  695. # Todo: logging
  696. #
  697. #*******************************************************************************
  698. log_skipped_msg() {
  699. ${ECHO} -n -e "${BOOTMESG_PREFIX}${@}"
  700. ${ECHO} -e "${SET_COL}""${BRACKET}""[""${WARNING}"" SKIP ""${BRACKET}""]""${NORMAL}"
  701. ${ECHO} -n -e "${BOOTMESG_PREFIX}${@}" >> /run/var/bootlog
  702. ${ECHO} -e "${SET_COL}""${BRACKET}""[""${WARNING}"" SKIP ""${BRACKET}""]""${NORMAL}" \
  703. >> /run/var/bootlog
  704. return 0
  705. }
  706. # End boot functions