echo "Some information:"
echo " \$hostname: $hostname"
echo " \$system_name: $system_name"
+echo " \$gateway: $gateway"
+echo " \$mac_address_eth0: $mac_address_eth0"
+echo " \$ip_address_eth0: $ip_address_eth0"
echo " \$IP_ADDRESS_ETH0: $IP_ADDRESS_ETH0"
echo " \$SIMPLE_HOSTNAME: $SIMPLE_HOSTNAME"
echo " \$DOMAIN: $DOMAIN"
echo "net.ipv6.conf.lo.disable_ipv6 = 1" | tee -a "${sysctl_file}"
}
+#-----------------------------------------------------------
+mac_exists() {
+
+ [[ -z "$1" ]] && return 1
+ local mac_address="$1"
+
+ ip -o link | grep -i "${mac_address}" 2>/dev/null >/dev/null
+ return $?
+
+}
+
+#-----------------------------------------------------------
+get_ifname() {
+
+ [[ -z "$1" ]] && return 1
+ local mac_address="$1"
+
+ ip -o link | grep -i "${mac_address}" | sed -e 's/^[0-9]*: //' -e 's/:.*//'
+
+}
+
+#-----------------------------------------------------------
+install_network() {
+
+ echo
+ log "Generating network configuration ..."
+
+ local temp_dir=$( mktemp -d 'tmp.XXXXXXXXXX.cobbler' )
+ local tmp_nw_cfg="${temp_dir}/network"
+ local tmp_nw_script_dir="${temp_dir}/network-scripts"
+ local old_dir="/etc/sysconfig/network/network-scripts/.old"
+ local ifcfg_file=
+
+ mkdir -pv "${tmp_nw_script_dir}"
+ mkdir -pv "${old_dir}"
+
+ echo "Generating /etc/sysconfig/network ..."
+ #cp -pv /etc/sysconfig/network-scripts/ifcfg-lo "${tmp_nw_script_dir}"
+ grep -v 'GATEWAY|HOSTNAME' /etc/sysconfig/network > "${tmp_nw_cfg}"
+ echo "GATEWAY=${gateway}" >> "${tmp_nw_cfg}"
+ echo "HOSTNAME=${hostname}" >> "${tmp_nw_cfg}"
+ mv -v /etc/sysconfig/network "/etc/sysconfig/network.orig.$( date -r /etc/sysconfig/network +'%Y-%m-%d_%H:%M:%S' )"
+ mv -v "${tmp_nw_cfg}" /etc/sysconfig/network
+
+ # Also set the hostname now, some applications require it
+ /bin/hostname "${hostname}"
+
+ local dev_file="${tmp_nw_script_dir}/ifcfg-eth0"
+ echo "Generating '${dev_file}' ..."
+
+ cat <<-EOF >"${dev_file}"
+ Name="System eth0"
+ DEVICE=eth0
+ ONBOOT=yes
+ HWADDR=${mac_address_eth0}
+ TYPE=Ethernet
+ BOOTPROTO=none
+ IPADDR=${ip_address_eth0}
+ NETMASK=255.255.254.0
+ DEFROUTE=yes
+ IPV4_FAILURE_FATAL=yes
+ IPV6INIT=no
+ DNS1=217.66.52.10
+ DNS2=93.188.109.13
+ DNS3=212.91.225.75
+ DOMAIN="pixelpark.com pixelpark.net"
+
+ EOF
+
+ for ifcfg_file in /etc/sysconfig/network-scripts/ifcfg-* ; do
+ local bname=$(basename "${ifcfg_file}" )
+ if [[ "${bname}" == "ifcfg-lo" ]] ; then
+ continue
+ fi
+ mv -v "${ifcfg_file}" "${old_dir}"
+ done
+ mv -v "${dev_file}" "/etc/sysconfig/network/network-scripts"
+
+ rm -vf "${temp_dir}"
+
+}
+
+#-----------------------------------------------------------
+manage_dns() {
+
+ log "Generating /etc/resolv.conf ..."
+ if [[ -f /etc/resolv.conf ]] ; then
+ mv -v /etc/resolv.conf "/etc/resolv.conf.orig.$( date -r /etc/resolv.conf +'%Y-%m-%d_%H:%M:%S' )"
+ fi
+ cat <<-EOF >"/etc/resolv.conf"
+ search pixelpark.net pixelpark.com
+ nameserver 217.66.52.10
+ nameserver 93.188.109.13
+ nameserver 212.91.225.75
+
+ EOF
+
+}
+
#-----------------------------------------------------------
main() {
create_etc_hosts
set_hostname
disable_ipv6
+ install_network
+ manage_dns
}