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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
#!/bin/sh
# Import foo/bar=baz from environment variables into the debconf db.
set -e
export DEBIAN_FRONTEND=none
. /usr/share/debconf/confmodule
# The hostname parameter might have been consumed by the kernel already
# (kernel parameter since v6.0-rc1):
if [ "$(hostname)" != '(none)' -a "$(hostname)" != '?' ]; then
# Propagate accordingly so that the debconf magic can happen as usual
# (#1031643):
hostname="$(hostname)"
# Unset in UTS so that netcfg doesn't see an already-set hostname, which
# would defeat the idea of supplying a default value (#1035349).
#
# Notes:
# - If using `hostname ''`, busybox's hostname would return '?' instead
# of '(none)'; the former happens when the first character of the
# nodename member of the utsname struct is null; the latter is the
# actual default string, courtesy of CONFIG_DEFAULT_HOSTNAME since
# 2011, and of the hardcoded '(none)' before then.
# - netcfg's dhcp.c detects both empty string and '(none)', so setting
# either of those should work equally well.
# - Settle for '(none)' to stay in line with what would have happened
# if the kernel hadn't started considering hostname to be a kernel
# parameter: the default value would have been kept.
hostname '(none)'
fi
NEWLINE='
'
OLDIFS=$IFS
IFS=$NEWLINE
for line in $(set); do
var="${line%%=*}"
val="${line#[!=]*=}"
# support preseeding without forcing seen flag
if [ "${var%\?}" != "$var" ]; then
var="${var%\?}"
seen=
else
seen=1
fi
# grep out the normal variables with no slashes
varnoslash="${var##*/*}"
if [ "$val" != "" ]; then
if [ "$varnoslash" != "" ]; then
var=$(grep "^$varnoslash[[:space:]]" /etc/preseed_aliases) || true
var=${var#*[[:space:]]}
fi
if [ "$var" != "" ]; then
owner="${var%:*}"
if [ "$owner" = "$var" ]; then
owner="d-i"
fi
var="${var#*:}"
# remove single quotes from around value
val="${val#\'}"
val="${val%\'}"
# remove double quotes (user can type those for values
# with spaces)
val="${val#\"}"
val="${val%\"}"
IFS=$OLDIFS
if ! db_set "$var" "$val"; then
db_register debian-installer/dummy "$var"
db_set "$var" "$val"
db_subst "$var" ID "$var"
fi
if db_metaget "$var" type; then
type="$RET"
else
type=unknown
fi
echo "$owner $var $type $val" >> /var/lib/preseed/log
if [ "$seen" ]; then
db_fset "$var" seen true
else
echo "$owner $var seen false" >> /var/lib/preseed/log
fi
IFS=$NEWLINE
fi
fi
done
|