Update welcome splash ascii art
[grml-live.git] / etc / grml / fai / config / files / usr / share / initramfs-tools / scripts / init-top / grml / GRMLBASE
1 #!/bin/sh
2 #
3 # This file was deployed via grml-live's
4 # ${GRML_FAI_CONFIG}/config/scripts/GRMLBASE/42-branding script, using
5 # ${GRML_FAI_CONFIG}/config/files/usr/share/initramfs-tools/scripts/init-top/grml/GRMLBASE
6 #
7 # Filename:      /usr/share/initramfs-tools/scripts/init-top/grml
8 # Purpose:       Early boot progress handler
9 # Authors:       grml-team (grml.org),
10 #                (c) Michael Prokop <mika@grml.org>
11 # Bug-Reports:   see http://grml.org/bugs/
12 # License:       This file is licensed under the GPL v2 or any later version.
13 ################################################################################
14
15 # prereq header {{{
16 # without this header booting will fail with:
17 # "PANIC: Circular dependancy.  Exiting."
18 PREREQ=""
19 prereqs()
20 {
21         echo "$PREREQ"
22 }
23 case $1 in
24 # get pre-requisites
25 prereqs)
26         prereqs
27         exit 0
28         ;;
29 esac
30 # }}}
31
32 # helper functions {{{
33
34 if grep -qe debug -qe verbose /proc/cmdline 2>/dev/null ; then
35    echo "debug: scripts/init-top/grml running">/dev/console
36 fi
37
38 # get boot command line
39 CMDLINE="$(cat /proc/cmdline)"
40
41 # Simple shell grep
42 stringinfile(){
43   case "$(cat $2)" in *$1*) return 0;; esac
44   return 1
45 }
46
47 # same for strings
48 stringinstring(){
49   case "$2" in *$1*) return 0;; esac
50   return 1
51 }
52
53 # Reread boot command line; echo last parameter's argument or return false.
54 getbootparam(){
55   stringinstring " $1=" "$CMDLINE" || return 1
56   result="${CMDLINE##*$1=}"
57   result="${result%%[   ]*}"
58   echo "$result"
59   return 0
60 }
61
62 # Check boot commandline for specified option
63 checkbootparam(){
64   stringinstring " $1" "$CMDLINE"
65   return "$?"
66 }
67
68 if checkbootparam "nocolor" ; then
69   echo "Disabling colors in bootsequence as requested on commandline."
70   # Reset fb color mode
71   RESET="\e]R"
72   # ANSI COLORS
73   # Erase to end of line
74   CRE="\r\e[K"
75   # Clear and reset Screen
76   CLEAR="\ec"
77 else
78   # Reset fb color mode
79   RESET="\e]R"
80   # ANSI COLORS
81   # Erase to end of line
82   CRE="\r\e[K"
83   # Clear and reset Screen
84   CLEAR="\ec"
85   # Normal color
86   NORMAL="\e[0;39m"
87   # RED: Failure or error message
88   RED="\e[1;31m"
89   # GREEN: Success message
90   GREEN="\e[1;32m"
91   # YELLOW: Descriptions
92   YELLOW="\e[1;33m"
93   # BLUE: System mesages
94   BLUE="\e[1;34m"
95   # MAGENTA: Found devices or drivers
96   MAGENTA="\e[1;35m"
97   # CYAN: Questions
98   CYAN="\e[1;36m"
99   # BOLD WHITE: Hint
100   WHITE="\e[1;37m"
101 fi
102
103 log_grml_failure_msg () {
104   echo -n " ${RED}*${NORMAL} $@"
105 }
106
107 # int log_grml_begin_message (char *message)
108 log_grml_begin_msg () {
109   echo -n " ${GREEN}*${NORMAL} $@"
110 }
111
112 log_grml_warn_msg () {
113   echo -n " ${YELLOW}*${NORMAL} $@"
114 }
115
116 # int log_grml_end_message (int exitstatus)
117 SUCCESS=" ${BLUE}[ ${GREEN}ok ${BLUE}]${NORMAL}"
118 FAILED=" ${NORMAL}[${RED}fail${NORMAL}]"
119
120 # }}}
121
122 # welcome splash {{{
123
124 DISTRI="$(getbootparam 'distri' 2>/dev/null)"
125
126 if [ -r /etc/grml_version ] ; then
127    GRML_VERSION="$(cat /etc/grml_version)"
128 fi
129
130 if checkbootparam "quiet" ; then
131     echo -e "${CLEAR}"
132 fi
133
134 if [ -n "$DISTRI" ] ; then
135 SPLASH="
136 ${RED} $DISTRI
137
138 ${WHITE}based on grml.org.
139
140 ${NORMAL}"
141 else
142 SPLASH="
143 ${YELLOW}   ____              _
144 ${YELLOW}  / ___| _ __ _____ | |
145 ${YELLOW} | |  _|| / /|     || |
146 ${YELLOW} | |_| ||  / | | | || |   
147 ${YELLOW}  \____||_|  |_|_|_||_|    
148
149 ${WHITE}Grml Live Linux - http://grml.org/${NORMAL}"
150 fi
151
152 echo ""
153 echo "${WHITE}Welcome to"
154 echo "$SPLASH"
155 echo
156
157 if [ -n "$GRML_VERSION" ] ; then
158    log_grml_begin_msg "Running $GRML_VERSION"
159    echo
160 fi
161
162 # }}}
163
164 ## /proc/cmdline handling {{{
165 # No kernel messages while probing modules:
166 if ! grep -qe debug -qe verbose /proc/cmdline 2>/dev/null ; then
167    [ -r /proc/sys/kernel/printk ] && echo "0" > /proc/sys/kernel/printk
168 fi
169
170 # Make sure we support squashfs:
171 if ! grep -q squashfs /proc/filesystems ; then
172    modprobe -q squashfs || log_grml_failure_msg "Warning: looks like you do not have support for squashfs"
173 fi
174
175 if grep -q 'boot=live' /proc/cmdline 2>/dev/null ; then
176    log_grml_begin_msg "Finished early booting sequence." ; echo "$SUCCESS"
177    log_grml_begin_msg "Searching for GRML file, this might take a few seconds..."
178    echo
179 fi
180 ## }}}
181
182 # vim: foldmethod=marker expandtab ai ft=sh