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