File: auto-install.sh

package info (click to toggle)
preseed 1.85
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 800 kB
  • ctags: 12
  • sloc: sh: 435; perl: 153; makefile: 5
file content (57 lines) | stat: -rwxr-xr-x 1,148 bytes parent folder | download | duplicates (3)
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
#!/bin/sh

set -e

. /usr/share/debconf/confmodule
. /lib/preseed/preseed.sh

if [ -e /var/run/preseed_unspecified_at_boot ]; then
	if [ -n "$(dhcp_preseed_url)" ]; then
		rm /var/run/preseed_unspecified_at_boot
	else
		db_input critical preseed/url || true
		db_go || true
	fi
fi

# BEGIN: testable
db_get preseed/url && url="$RET"
[ "$url" ] || exit 0

if [ "${url%%://*}" != "$url" ]; then
	proto="${url%%://*}"
	base="${url#*://}"
else
	proto=http
	base="$url"
fi

if ! expr "$base" : [^/]*$ >/dev/null; then
	host_port="${base%%/*}"
	dir="${base#*/}"
else
	host_port="$base"
	db_get auto-install/defaultroot && dir="$RET"
fi

if expr "$host_port" : '.*\[[:a-fA-F0-9]*\]' > /dev/null; then
	# IPv6 address with or without port
	:
elif expr $host_port : [^.]*$ >/dev/null; then
	db_get netcfg/get_domain && domain="$RET"

	if [ -n "$domain" ] && [ "$domain" != "unassigned-domain" ] && [ "$domain" != "unnassigned-domain" ]; then
		host=${host_port%%:*}
		if [ "$host" = "$host_port" ]; then
			port=""
		else
			port=":${host_port#*:}"
		fi

		host_port="$host.$domain$port"

	fi
fi

db_set preseed/url $proto://$host_port/$dir
# END: testable