Merge pull request #75 from kvaps/suse

Add: openSUSE support
pull/76/head
Vlastimil Holer 8 years ago committed by GitHub
commit ebbb7ffae0

@ -32,7 +32,7 @@ then
fi
if [ -f /etc/init.d/one-context ]; then
if [ -d /etc/sysconfig/network-scripts ]; then
if [ -d /etc/sysconfig/network-scripts ] || [ -d /etc/sysconfig/network ]; then
chkconfig --add one-context-local
chkconfig --add one-context
elif [ -d /etc/network ]; then
@ -79,3 +79,12 @@ if [ -d /etc/sysconfig/network-scripts ]; then
rm -f /etc/sysconfig/network-scripts/ifcfg-eth*
fi
# openSUSE based distros
if [ -d /etc/sysconfig/network ]; then
# Prepare network files
rm -f /etc/sysconfig/network/ifcfg-eth*
rm -f /etc/sysconfig/network/ifroute-eth*
sed -i '/^NETCONFIG_DNS_STATIC_SERVERS=/ s/=.*$/=""/' /etc/sysconfig/network/config
sed -i '/^NETCONFIG_DNS_STATIC_SEARCHLIST=/ s/=.*$/=""/' /etc/sysconfig/network/config
fi

@ -105,7 +105,11 @@ IPADDR=$IP
EOT
if [ -n "$GATEWAY" ]; then
echo "GATEWAY=$GATEWAY"
if [ "$CONFIG_PATH" = "/etc/sysconfig/network" ]; then
echo "default $GATEWAY - $DEV" >> /etc/sysconfig/network/ifroute-$DEV
else
echo "GATEWAY=$GATEWAY"
fi
fi
if [ -n "$MTU" ]; then
@ -125,7 +129,11 @@ EOT
fi
if [ -n "$GATEWAY6" ]; then
echo "IPV6_DEFAULTGW=$GATEWAY6"
if [ "$CONFIG_PATH" = "/etc/sysconfig/network" ]; then
echo "default $GATEWAY6 - $DEV" >> /etc/sysconfig/network/ifroute-$DEV
else
echo "IPV6_DEFAULTGW=$GATEWAY6"
fi
fi
if [ -n "$MTU" ]; then
@ -153,6 +161,12 @@ get_dev()
gen_network_configuration()
{
if [ -d /etc/sysconfig/network-scripts ]; then
CONFIG_PATH=/etc/sysconfig/network-scripts
elif [ -d /etc/sysconfig/network ]; then
CONFIG_PATH=/etc/sysconfig/network
fi
INTERFACE_MAC=$(get_interface_mac)
CONTEXT_INTERFACES=$(get_context_interfaces)
GATEWAY_IFACE_NUM=$(echo "$GATEWAY_IFACE" | sed 's/^ETH//')
@ -179,17 +193,23 @@ gen_network_configuration()
[ -z "${DEV}" ] && continue
(
rm -f /etc/sysconfig/network/ifroute-$DEV
cat <<EOT
DEVICE=$DEV
BOOTPROTO=none
ONBOOT=yes
BOOTPROTO=static
NM_CONTROLLED=no
TYPE=Ethernet
EOT
if [ "$CONFIG_PATH" = "/etc/sysconfig/network" ]; then
echo "STARTMODE=auto"
else
echo "ONBOOT=yes"
fi
[[ -n $IP ]] && gen_iface_conf
[[ -n $IP6 ]] && gen_iface6_conf
) > /etc/sysconfig/network-scripts/ifcfg-${DEV}
) > ${CONFIG_PATH}/ifcfg-${DEV}
ifup ${DEV}

@ -46,7 +46,14 @@ for nameserver in $nameservers; do
echo nameserver $nameserver >> /etc/resolv.conf
done
if [ -f /etc/sysconfig/network/config ]; then
sed -i "/^NETCONFIG_DNS_STATIC_SERVERS=/ s/=.*$/=\"$nameservers\"/" /etc/sysconfig/network/config
fi
[ -z "$searchdomains" ] && exit 0
echo search $searchdomains >> /etc/resolv.conf
if [ -f /etc/sysconfig/network/config ]; then
sed -i "/^NETCONFIG_DNS_STATIC_SEARCHLIST=/ s/=.*$/=\"$searchdomains\"/" /etc/sysconfig/network/config
fi

@ -1 +1 @@
restorecon -R -v /root/.ssh
[ -x /sbin/restorecon ] && restorecon -R -v /root/.ssh

@ -24,7 +24,7 @@ function set_domainname() {
}
function get_first_ip() {
hostname -I | cut -d' ' -f1
ip route get 1 | awk '{print $NF;exit}'
}
function get_dns_name() {

Loading…
Cancel
Save