summaryrefslogtreecommitdiff
path: root/scripts/live-functions
blob: c5055a0a642c14458eb7fc708d10178c77e01826 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh

. /scripts/functions
. /live.vars

log_wait_msg ()
{
	# Print a message and wait for enter
	if [ -x /sbin/usplash_write ]
	then
		/sbin/usplash_write "INPUTENTER ${@}"
		read nunya < /dev/.initramfs/usplash_outfifo
	fi

	_log_msg "Waiting: ${@} ..."
}

really_export ()
{
	STRING="${1}"
	VALUE="$(eval echo -n \${$STRING})"

	if [ -f /live.vars ] && cat /live.vars | grep -sq "export ${STRING}"
	then
		sed -i -e 's/\('${STRING}'=\).*$/\1'${VALUE}'/' /live.vars
	else
		echo "export ${STRING}=\"${VALUE}\"" >> /live.vars
	fi

	eval export "${STRING}"="${VALUE}"
}

lang2locale() {
	langpart="${1%%_*}"
	if [ "$1" != "C" ]; then
		# Match the language code with 3rd field in languagelist
		line=$(grep -v "^#" /root/usr/share/live-initramfs/languagelist | cut -f3,4,5 -d\; | grep -v ';C$' | grep "^$langpart;")
		if [ -n "$line" ]; then
			if [ "$(echo "$line" | grep -c '')" -gt 1 ]; then
				# More than one match; try matching the
				# country as well.
				countrypart="${1#*_}"
				if [ "$countrypart" = "$1" ]; then
					countryline="$(echo "$line" | head -n1)"
					echo "${countryline##*;}"
					return
				fi
				countrypart="${countrypart%%[@.]*}"
				countryline="$(echo "$line" | grep ";$countrypart;" | head -n1 || true)"
				if [ "$countryline" ]; then
					echo "${countryline##*;}"
					return
				fi
			fi
			echo "${line##*;}"
		fi
	else
		echo "C"
	fi
}