diff --git a/postinstall.one b/postinstall.one index 7f9fe42..00194e7 100755 --- a/postinstall.one +++ b/postinstall.one @@ -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 + diff --git a/src/etc/one-context.d/loc-10-network##rpm.one b/src/etc/one-context.d/loc-10-network##rpm.one index df472b9..6617f00 100755 --- a/src/etc/one-context.d/loc-10-network##rpm.one +++ b/src/etc/one-context.d/loc-10-network##rpm.one @@ -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 < /etc/sysconfig/network-scripts/ifcfg-${DEV} + ) > ${CONFIG_PATH}/ifcfg-${DEV} ifup ${DEV} diff --git a/src/etc/one-context.d/loc-11-dns##one b/src/etc/one-context.d/loc-11-dns##one index 7409267..464c12e 100755 --- a/src/etc/one-context.d/loc-11-dns##one +++ b/src/etc/one-context.d/loc-11-dns##one @@ -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 diff --git a/src/etc/one-context.d/loc-23-selinux-ssh##rpm b/src/etc/one-context.d/loc-23-selinux-ssh##rpm index 164d1c1..bfc513d 100755 --- a/src/etc/one-context.d/loc-23-selinux-ssh##rpm +++ b/src/etc/one-context.d/loc-23-selinux-ssh##rpm @@ -1 +1 @@ -restorecon -R -v /root/.ssh +[ -x /sbin/restorecon ] && restorecon -R -v /root/.ssh diff --git a/src/etc/one-context.d/net-15-hostname##one b/src/etc/one-context.d/net-15-hostname##one index 9085e3b..293d0bf 100755 --- a/src/etc/one-context.d/net-15-hostname##one +++ b/src/etc/one-context.d/net-15-hostname##one @@ -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() {