summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2011-07-05 21:33:35 -0400
committerDave Reisner <dreisner@archlinux.org>2011-08-02 08:23:04 -0400
commit43a6e277b5b73a6141f2b222d0b826f1d37013d6 (patch)
tree6fd861abae4b4b394aacce2c48b06e0d600a86e0
parent7ea398ed600bc2c4d8a1d1487911f5db52f42c93 (diff)
lib-network: revamp for iproute2 syntax
This is a vast simplification of the setup and doesn't insert default values since there's no "on/off" array as there was with the net-tools setup. If nothing is defined, its not added to the config. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
-rw-r--r--src/core/libs/lib-network.sh24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/core/libs/lib-network.sh b/src/core/libs/lib-network.sh
index 5e8c5fc..3e7914b 100644
--- a/src/core/libs/lib-network.sh
+++ b/src/core/libs/lib-network.sh
@@ -14,36 +14,30 @@ target_configure_network()
source "$RUNTIME_DIR/aif-network-settings" 2>/dev/null || return 1
- IFO=${INTERFACE_PREV:-eth0} # old iface: a previously entered one, or the arch default
IFN=${INTERFACE:-eth0} # new iface: a specified one, or the arch default
- # comment out any existing uncommented entries, whether specified by us, or arch defaults.
- for var in eth0 $IFO INTERFACES gateway ROUTES; do
- sed -i "s/^$var=/#$var=/" "${var_TARGET_DIR}/etc/rc.conf" || return 1
- done
sed -i "s/^nameserver/#nameserver/" "${var_TARGET_DIR}/etc/resolv.conf" || return 1
- if [[ -f "${var_TARGET_DIR}/etc/profile.d/proxy.sh" ]]
- then
+ if [[ -f "${var_TARGET_DIR}/etc/profile.d/proxy.sh" ]]; then
sed -i "s/^export/#export/" "${var_TARGET_DIR}/etc/profile.d/proxy.sh" || return 1
fi
+ sed -i "s/^\(interface\)=/\1=$IFN/" "${var_TARGET_DIR}/etc/rc.conf" || return 1
if (( ! DHCP )); then
- local line="$IFN=\"$IFN ${IPADDR:-192.168.0.2} netmask ${SUBNET:-255.255.255.0} broadcast ${BROADCAST:-192.168.0.255}\""
- append_after_last "/$IFO\|eth0/" "$line" "${var_TARGET_DIR}/etc/rc.conf" || return 1
+ sed -i "s/^\(address\)=/\1=$IPADDR/;s/^\(netmask\)=/\1=$SUBNET/" "${var_TARGET_DIR}/etc/rc.conf"
+
+ if [[ $BROADCAST ]]; then
+ sed -i "s/^\(broadcast\)=/\1=$BROADCAST/" "${var_TARGET_DIR}/etc/rc.conf" || return 1
+ fi
if [[ $GW ]]; then
- append_after_last "/gateway/" "gateway=\"default gw $GW\"" "${var_TARGET_DIR}/etc/rc.conf" || return 1
- append_after_last "/ROUTES/" "ROUTES=(gateway)" "${var_TARGET_DIR}/etc/rc.conf" || return 1
+ sed -i "s/^\(gateway\)=/\1=$GW/" "${var_TARGET_DIR}/etc/rc.conf" || return 1
fi
+
if [[ $DNS ]]; then
echo "nameserver $DNS" >> "${var_TARGET_DIR}/etc/resolv.conf" || return 2
fi
- else
- append_after_last "/$IFO\|eth0/" "$IFN=\"dhcp\"" "${var_TARGET_DIR}/etc/rc.conf" || return 1
fi
- append_after_last "/$IFO\|eth0/" "INTERFACES=($IFN)" "${var_TARGET_DIR}/etc/rc.conf" || return 1
-
if [[ $PROXY_HTTP ]]; then
echo "export http_proxy=$PROXY_HTTP" >> "${var_TARGET_DIR}/etc/profile.d/proxy.sh" || return 1
chmod a+x "${var_TARGET_DIR}/etc/profile.d/proxy.sh" || return 1