source: ubiquity/trunk/fuentes/d-i/source/netcfg/finish-install.d/55netcfg-copy-config @ 3069

Last change on this file since 3069 was 3069, checked in by kbut, 3 years ago

Update from upstream

  • Property svn:executable set to *
File size: 2.4 KB
Line 
1#! /bin/sh
2set -e
3
4. /usr/share/debconf/confmodule
5
6# File paths for various configuration files
7FILE_PATH_NM_CONFIG=etc/NetworkManager/system-connections
8FILE_INTERFACES=/etc/network/interfaces
9FILE_NETCFG_CONNECTION_TYPE=/tmp/connection_type
10
11# The connection type file is written by the nm-conf code.
12# The base-installer snippet will already take care of copying
13# the generated interfaces file, so if we are not dealing
14# with nm-conf anyway: just exit.
15if [ ! -e $FILE_NETCFG_CONNECTION_TYPE ]; then
16        logger -t netcfg "DEBUG: copy-config: $FILE_NETCFG_CONNECTION_TYPE not found: netcfg did not complete or was compiled without network-manager support; exiting."
17        exit 0
18fi
19
20# Flag to determine whether Network Manager is installed.
21if in-target sh -c "dpkg-query -s network-manager 2>/dev/null | grep -q '^Status: install ok installed'"; then
22        NM_IS_INSTALLED=true
23else
24        NM_IS_INSTALLED=false
25fi
26
27# The type of the connection used during installation
28NETCFG_CONNECTION_TYPE=$(cat $FILE_NETCFG_CONNECTION_TYPE | \
29    grep "connection type" | cut -d ':' -f2 | sed 's/ //g')
30NETCFG_CONNECTION_SECURITY=$(cat $FILE_NETCFG_CONNECTION_TYPE | \
31    grep "security" | cut -d ':' -f2 | sed 's/ //g')
32
33# netcfg/target_network_config question values
34CONFIG_NM="nm_config"
35CONFIG_INTERFACES="ifupdown"
36CONFIG_LOOPBACK="loopback"
37
38db_get netcfg/target_network_config
39
40# Check for preseeding. If the value of the question is empty then set
41# default options. Document automatic selection changes in the template.
42if [ -z "$RET" ]; then
43        if $NM_IS_INSTALLED; then
44                db_set netcfg/target_network_config $CONFIG_NM
45        else
46                if [ "$NETCFG_CONNECTION_TYPE" = "wireless" ]; then
47                        db_set netcfg/target_network_config $CONFIG_LOOPBACK
48                else # vlan/wired
49                        db_set netcfg/target_network_config $CONFIG_INTERFACES
50                fi
51        fi
52fi
53
54db_get netcfg/target_network_config
55
56case $RET in
57    $CONFIG_NM)
58        # Copy NM config file. First make sure the directory exists
59        mkdir -p /target/$FILE_PATH_NM_CONFIG
60        cp /$FILE_PATH_NM_CONFIG/* /target/$FILE_PATH_NM_CONFIG/
61
62        # Rewrite /etc/network/interfaces to contain only loopback
63        netcfg write_loopback
64        ;;
65
66    $CONFIG_LOOPBACK)
67        # Rewrite /etc/network/interfaces to contain only loopback
68        netcfg write_loopback
69        ;;
70esac
71
72case $RET in
73    $CONFIG_NM|$CONFIG_LOOPBACK)
74        # Copy /etc/network/interfaces to target.
75        mkdir -p /target$(dirname $FILE_INTERFACES)
76        cp $FILE_INTERFACES /target$FILE_INTERFACES
77        ;;
78esac
79
80exit 0
Note: See TracBrowser for help on using the repository browser.