Update of fai-configuration and documentation
[grml-live.git] / etc / grml / fai / live-initramfs / grml-script.init-top
1 #!/bin/sh
2
3 # helper functions {{{
4
5 echo "debug: scripts/init-top/grml running"
6
7 # get boot command line
8 CMDLINE="$(cat /proc/cmdline)"
9
10 # Simple shell grep
11 stringinfile(){
12   case "$(cat $2)" in *$1*) return 0;; esac
13   return 1
14 }
15
16 # same for strings
17 stringinstring(){
18   case "$2" in *$1*) return 0;; esac
19   return 1
20 }
21
22 # Reread boot command line; echo last parameter's argument or return false.
23 getbootparam(){
24   stringinstring " $1=" "$CMDLINE" || return 1
25   result="${CMDLINE##*$1=}"
26   result="${result%%[   ]*}"
27   echo "$result"
28   return 0
29 }
30
31 # Check boot commandline for specified option
32 checkbootparam(){
33   stringinstring " $1" "$CMDLINE"
34   return "$?"
35 }
36
37 if checkbootparam "nocolor" ; then
38   echo "Disabling colors in bootsequence as requested on commandline."
39   # Reset fb color mode
40   RESET="\e]R"
41   # ANSI COLORS
42   # Erase to end of line
43   CRE="\r\e[K"
44   # Clear and reset Screen
45   CLEAR="\ec"
46 else
47   # Reset fb color mode
48   RESET="\e]R"
49   # ANSI COLORS
50   # Erase to end of line
51   CRE="\r\e[K"
52   # Clear and reset Screen
53   CLEAR="\ec"
54   # Normal color
55   NORMAL="\e[0;39m"
56   # RED: Failure or error message
57   RED="\e[1;31m"
58   # GREEN: Success message
59   GREEN="\e[1;32m"
60   # YELLOW: Descriptions
61   YELLOW="\e[1;33m"
62   # BLUE: System mesages
63   BLUE="\e[1;34m"
64   # MAGENTA: Found devices or drivers
65   MAGENTA="\e[1;35m"
66   # CYAN: Questions
67   CYAN="\e[1;36m"
68   # BOLD WHITE: Hint
69   WHITE="\e[1;37m"
70 fi
71
72 log_grml_failure_msg () {
73   echo -n " ${RED}*${NORMAL} $@"
74 }
75
76 # int log_grml_begin_message (char *message)
77 log_grml_begin_msg () {
78   echo -n " ${GREEN}*${NORMAL} $@"
79 }
80
81 log_grml_warn_msg () {
82   echo -n " ${YELLOW}*${NORMAL} $@"
83 }
84
85 # int log_grml_end_message (int exitstatus)
86 SUCCESS=" ${BLUE}[ ${GREEN}ok ${BLUE}]${NORMAL}"
87 FAILED=" ${NORMAL}[${RED}fail${NORMAL}]"
88
89 # }}}
90
91 # welcome splash {{{
92
93 DISTRI="$(getbootparam 'distri' 2>/dev/null)"
94 if [ -n "$DISTRI" ] ; then
95 SPLASH="
96 ${RED} $DISTRI
97
98 ${WHITE}based on grml.org.
99
100 ${NORMAL}"
101 else
102 SPLASH="
103 ${RED}   ____ ____  __  __ _
104 ${RED}  / ___|  _ \|  \/  | |
105 ${RED} | |  _| |_) | |\/| | |
106 ${RED} | |_| |  _ <| |  | | |___
107 ${RED}  \____|_| \_\_|  |_|_____|
108
109 ${WHITE}grml.org - Linux for sysadmins and texttool users.
110 ${NORMAL}"
111 fi
112
113 echo ""
114 echo "${WHITE}Welcome to"
115 echo "$SPLASH"
116
117 # don't output anything if running with bootsplash feature
118 if checkbootparam "splash" ; then
119   exec >/dev/null </dev/null 2>&1
120 fi
121 # }}}
122
123 # No kernel messages while probing modules:
124 if ! grep -qe debug -qe verbose /proc/cmdline 2>/dev/null ; then
125    [ -r /proc/sys/kernel/printk ] && echo "0" > /proc/sys/kernel/printk
126 fi
127
128 if grep -q 'boot=live' /proc/cmdline 2>/dev/null ; then
129    log_grml_begin_msg "Finished early booting sequence." ; echo "$SUCCESS"
130    log_grml_begin_msg "Searching for GRML file, this might take a few seconds..."
131    echo 
132 fi
133
134 # vim: foldmethod=marker expandtab ai ft=sh