Commit 52ee4a82 authored by Mikhail Efremov's avatar Mikhail Efremov

live: Replace etcnet-dhcp hook with setup-network.

Setup network settings: 1. Init /etc/hosts with "127.0.0.1 localhost" 2. Set hostname, domainname 3. Set defaults for NetworkManager or attempt to autoconfigure eth0 by etcnet. Based on init3-network script from m-p-d.
parent b8ece7f7
#!/bin/sh -efu
# attempt to autoconfigure ethernet
[ -x /sbin/dhcpcd -o -x /sbin/dhclient ] || {
echo "NOT configuring DHCP for eth0" >&2
exit 0
}
echo "configuring DHCP for eth0" >&2
mkdir -p /etc/net/ifaces/eth0 && {
echo TYPE=eth
echo BOOTPROTO=dhcp
} > /etc/net/ifaces/eth0/options ||:
#!/bin/sh
# Setup network settings
# 1. Init /etc/hosts with "127.0.0.1 localhost"
# 2. Set hostname, domainname
# 3. Set defaults for NetworkManager or
# attempt to autoconfigure eth0 by etcnet.
. shell-config
verbose()
{
if [ -n "$GLOBAL_VERBOSE" ]; then
echo "HOOK: 50-setup-network: $@"
fi
}
verbose "has started"
# At startup time hostname may be changed by live-hostname package.
HOSTNAME="localhost.localdomain"
DOMAINNAME="localdomain"
verbose "Init /etc/hosts with 127.0.0.1 localhost"
echo "127.0.0.1 localhost localhost.localdomain" > /etc/hosts
netcfg="/etc/sysconfig/network"
verbose "Enable networking, set hostname to $HOSTNAME, domainname to $DOMAINNAME"
shell_config_set "$netcfg" NETWORKING yes
shell_config_set "$netcfg" HOSTNAME "$HOSTNAME"
shell_config_set "$netcfg" DOMAINNAME "$DOMAINNAME"
if [ -x /usr/sbin/NetworkManager ] ; then
verbose "Setup defaults for NetworkManager"
shell_config_set /etc/net/ifaces/default/options-eth NM_CONTROLLED yes
shell_config_set /etc/net/ifaces/default/options-eth DISABLED yes
shell_config_set /etc/net/ifaces/default/options-eth BOOTPROTO dhcp
else
# attempt to autoconfigure ethernet by etcnet
if [ -x /sbin/dhcpcd -o -x /sbin/dhclient ]; then
verbose "configuring DHCP for eth0"
mkdir -p /etc/net/ifaces/eth0 && {
echo TYPE=eth
echo BOOTPROTO=dhcp
} > /etc/net/ifaces/eth0/options
else
verbose "NOT configuring DHCP for eth0"
fi
fi
verbose "finished"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment