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
|
#! /bin/sh
set -e
. /usr/share/debconf/confmodule
# File paths for various configuration files
FILE_PATH_NM_CONFIG=etc/NetworkManager/system-connections
FILE_INTERFACES=/etc/network/interfaces
FILE_NETCFG_CONNECTION_TYPE=/tmp/connection_type
# The connection type file is written by the nm-conf code.
# The base-installer snippet will already take care of copying
# the generated interfaces file, so if we are not dealing
# with nm-conf anyway: just exit.
if [ ! -e $FILE_NETCFG_CONNECTION_TYPE ]; then
logger -t netcfg "DEBUG: copy-config: $FILE_NETCFG_CONNECTION_TYPE not found: netcfg did not complete or was compiled without network-manager support; exiting."
exit 0
fi
# Flag to determine whether Network Manager is installed.
if in-target sh -c "dpkg-query -s network-manager 2>/dev/null | grep -q '^Status: install ok installed'"; then
NM_IS_INSTALLED=true
else
NM_IS_INSTALLED=false
fi
# The type of the connection used during installation
NETCFG_CONNECTION_TYPE=$(cat $FILE_NETCFG_CONNECTION_TYPE | \
grep "connection type" | cut -d ':' -f2 | sed 's/ //g')
NETCFG_CONNECTION_SECURITY=$(cat $FILE_NETCFG_CONNECTION_TYPE | \
grep "security" | cut -d ':' -f2 | sed 's/ //g')
# netcfg/target_network_config question values
CONFIG_NM="nm_config"
CONFIG_INTERFACES="ifupdown"
CONFIG_LOOPBACK="loopback"
db_get netcfg/target_network_config
# Check for preseeding. If the value of the question is empty then set
# default options. Document automatic selection changes in the template.
if [ -z "$RET" ]; then
if $NM_IS_INSTALLED; then
db_set netcfg/target_network_config $CONFIG_NM
else
if [ "$NETCFG_CONNECTION_TYPE" = "wireless" ]; then
db_set netcfg/target_network_config $CONFIG_LOOPBACK
else # vlan/wired
db_set netcfg/target_network_config $CONFIG_INTERFACES
fi
fi
fi
db_get netcfg/target_network_config
case $RET in
$CONFIG_NM)
# Copy NM config file. First make sure the directory exists
mkdir -p /target/$FILE_PATH_NM_CONFIG
cp /$FILE_PATH_NM_CONFIG/* /target/$FILE_PATH_NM_CONFIG/
# Rewrite /etc/network/interfaces to contain only loopback
netcfg write_loopback
;;
$CONFIG_LOOPBACK)
# Rewrite /etc/network/interfaces to contain only loopback
netcfg write_loopback
;;
esac
case $RET in
$CONFIG_NM|$CONFIG_LOOPBACK)
# Copy /etc/network/interfaces to target.
mkdir -p /target$(dirname $FILE_INTERFACES)
cp $FILE_INTERFACES /target$FILE_INTERFACES
;;
esac
exit 0
|