Silence 'script-not-executable' lintian warning - live-functions script is always...
[live-boot-grml.git] / scripts / live-functions
1
2 . /scripts/functions
3 . /live.vars
4
5 # Override log_*_msg until #494257 is merged
6
7 _log_msg()
8 {
9         if [ "$quiet" = "y" ]; then return; fi
10         printf "$@"
11 }
12
13 log_success_msg()
14 {
15         _log_msg "Success: $@\n"
16 }
17
18 log_failure_msg()
19 {
20         _log_msg "Failure: $@\n"
21 }
22
23 log_warning_msg()
24 {
25         _log_msg "Warning: $@\n"
26 }
27
28 log_begin_msg()
29 {
30         if [ -x /sbin/usplash_write ]; then
31                 /sbin/usplash_write "TEXT $@"
32         fi
33         _log_msg "Begin: $@ ... "
34 }
35
36 log_end_msg()
37 {
38         if [ -x /sbin/usplash_write ]; then
39                 /sbin/usplash_write "SUCCESS ok"
40         fi
41         _log_msg "done.\n"
42 }
43
44 ##
45
46 log_wait_msg ()
47 {
48         # Print a message and wait for enter
49         if [ -x /sbin/usplash_write ]
50         then
51                 /sbin/usplash_write "INPUTENTER ${@}"
52                 read nunya < /dev/.initramfs/usplash_outfifo
53         fi
54
55         _log_msg "Waiting: ${@} ... \n"
56 }
57
58 really_export ()
59 {
60         STRING="${1}"
61         VALUE="$(eval echo -n \${$STRING})"
62
63         if [ -f /live.vars ] && cat /live.vars | grep -sq "export ${STRING}"
64         then
65                 sed -i -e 's/\('${STRING}'=\).*$/\1'${VALUE}'/' /live.vars
66         else
67                 echo "export ${STRING}=\"${VALUE}\"" >> /live.vars
68         fi
69
70         eval export "${STRING}"="${VALUE}"
71 }
72
73 lang2locale() {
74         langpart="${1%%_*}"
75         if [ "$1" != "C" ]; then
76                 # Match the language code with 3rd field in languagelist
77                 line=$(grep -v "^#" /root/usr/share/live-initramfs/languagelist | cut -f3,4,5 -d\; | grep -v ';C$' | grep "^$langpart;")
78                 if [ -n "$line" ]; then
79                         if [ "$(echo "$line" | grep -c '')" -gt 1 ]; then
80                                 # More than one match; try matching the
81                                 # country as well.
82                                 countrypart="${1#*_}"
83                                 if [ "$countrypart" = "$1" ]; then
84                                         countryline="$(echo "$line" | head -n1)"
85                                         echo "${countryline##*;}"
86                                         return
87                                 fi
88                                 countrypart="${countrypart%%[@.]*}"
89                                 countryline="$(echo "$line" | grep ";$countrypart;" | head -n1 || true)"
90                                 if [ "$countryline" ]; then
91                                         echo "${countryline##*;}"
92                                         return
93                                 fi
94                         fi
95                         echo "${line##*;}"
96                 fi
97         else
98                 echo "C"
99         fi
100 }
101
102 # Override panic from scripts/functions
103 panic() {
104
105         DEB_1="\033[1;31m .''\`.  \033[0m"
106         DEB_2="\033[1;31m: :'  : \033[0m"
107         DEB_3="\033[1;31m\`. \`'\`  \033[0m"
108         DEB_4="\033[1;31m  \`-    \033[0m"
109
110         LIVELOG="\033[1;37m/live.log\033[0m"
111         DEBUG="\033[1;37mdebug\033[0m"
112
113         # Reset redirections to avoid buffering
114         exec 1>&6 6>&-
115         exec 2>&7 7>&-
116         kill ${tailpid}
117
118         printf "\n\n"
119         printf "     ${DEB_1}\n"
120         printf "     ${DEB_2}  \033[1;37mBOOT FAILED!\033[0m\n"
121         printf "     ${DEB_3}\n"
122         printf "     ${DEB_4}  This Debian Live image failed to boot.\n\n"
123
124         printf "  Please file a bug against the 'live-initramfs' package or email the Debian\n"
125         printf "  Live mailing list at <debian-live-devel@lists.alioth.debian.org>, making\n"
126         printf "  sure to note the exact version, name and distribution of the image you were\n"
127         printf "  attempting to boot.\n\n"
128
129         printf "  The file ${LIVELOG} contains some debugging information but booting with the\n"
130         printf "  ${DEBUG} command-line parameter will greatly increase its verbosity which is\n"
131         printf "  extremely useful when diagnosing issues.\n\n"
132
133         if [ -n "${panic}" ]; then
134                 printf "  live-initramfs will now restart your system. "
135         else
136                 printf "  live-initramfs will now start a shell. "
137         fi
138         printf "The error message was:\n\n    "
139
140         # Call original panic
141         . /scripts/functions
142         panic "$@"
143 }