summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile.am1
-rw-r--r--configure.ac2
-rw-r--r--scripts/Makemodule.am1
-rwxr-xr-xscripts/ifcfg.sh.in89
-rw-r--r--services/Makemodule.am2
-rw-r--r--services/ifcfg.in6
7 files changed, 102 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 3a291c4..73b3efb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,8 +27,10 @@ services/devfs
services/procfs
services/sysfs
services/ifrename
+services/ifcfg
scripts/devfs.sh
scripts/ifrename.sh
+scripts/ifcfg.sh
etc/initd.env
diff --git a/Makefile.am b/Makefile.am
index 01e21a2..0b24ded 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -38,3 +38,4 @@ install-data-local:
$(LN_S) $(TEMPLATEDIR)/sync $(DESTDIR)$(SVCDIR)/sync@reboot
$(LN_S) $(TEMPLATEDIR)/sigkill $(DESTDIR)$(SVCDIR)/sigkill@reboot
$(LN_S) $(TEMPLATEDIR)/sigterm $(DESTDIR)$(SVCDIR)/sigterm@reboot
+ $(LN_S) $(TEMPLATEDIR)/ifcfg $(DESTDIR)$(SVCDIR)/ifcfg
diff --git a/configure.ac b/configure.ac
index 13b11eb..f37258e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -53,8 +53,10 @@ AC_CONFIG_FILES([services/sysfs])
AC_CONFIG_FILES([services/devfs])
AC_CONFIG_FILES([services/procfs])
AC_CONFIG_FILES([services/ifrename])
+AC_CONFIG_FILES([services/ifcfg])
AC_CONFIG_FILES([scripts/devfs.sh])
AC_CONFIG_FILES([scripts/ifrename.sh])
+AC_CONFIG_FILES([scripts/ifcfg.sh])
AC_CONFIG_FILES([etc/initd.env])
AC_OUTPUT([Makefile])
diff --git a/scripts/Makemodule.am b/scripts/Makemodule.am
index 5759ff0..fa0f917 100644
--- a/scripts/Makemodule.am
+++ b/scripts/Makemodule.am
@@ -1,3 +1,4 @@
helper_SCRIPTS += scripts/devfs.sh scripts/trymount.sh scripts/ifrename.sh
+helper_SCRIPTS += scripts/ifcfg.sh
EXTRA_DIST += scripts/trymount.sh
diff --git a/scripts/ifcfg.sh.in b/scripts/ifcfg.sh.in
new file mode 100755
index 0000000..8f684e7
--- /dev/null
+++ b/scripts/ifcfg.sh.in
@@ -0,0 +1,89 @@
+#!/bin/sh
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# Copyright (C) 2018 - David Oberhollenzer
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+#
+CFGPATH="@ETCPATH@/netcfg"
+
+[ -d "$CFGPATH" ] || exit 0
+
+# configure interfaces
+for IFPATH in /sys/class/net/*; do
+ [ "$IFPATH" == "/sys/class/net/lo" ] && continue
+
+ IF=`basename $IFPATH`
+ CFGFILE="$CFGPATH/$IF"
+
+ [ -f "$CFGFILE" ] || continue
+
+ ip link set dev "$IF" down
+
+ while read LINE;
+ do
+ trimmed=`echo -- $LINE`
+ [ ! -z "$trimmed" ] || continue
+ set $trimmed
+
+ case "$1" in
+ address|addr|ip|ip6|ipv6)
+ shift
+ ip address add $@ dev "$IF"
+ ;;
+ arp|multicast|mtu)
+ ip link set dev "$IF" $@
+ ;;
+ offload)
+ shift
+ ethtool -K "$IF" $@
+ ;;
+ *)
+ ;;
+ esac
+ done < "$CFGFILE"
+done
+
+# configure static routs
+if [ -f "$CFGPATH/routes" ]; then
+ while read LINE;
+ do
+ trimmed=`echo -- $LINE`
+ [ ! -z "$trimmed" ] || continue
+ set $trimmed
+
+ case "$1" in
+ route)
+ shift
+ ip route add $@
+ ;;
+ rule)
+ shift
+ ip rule add $@
+ ;;
+ *)
+ ;;
+ esac
+ done < "$CFGFILE"
+fi
+
+# activate interfaces
+for IFPATH in /sys/class/net/*; do
+ [ "$IFPATH" == "/sys/class/net/lo" ] && continue
+
+ IF=`basename $IFPATH`
+
+ [ ! -f "$CFGPATH/$IF" ] || ip link set dev "$IF" up
+done
diff --git a/services/Makemodule.am b/services/Makemodule.am
index 5dc8c4c..fa51235 100644
--- a/services/Makemodule.am
+++ b/services/Makemodule.am
@@ -4,7 +4,7 @@ init_DATA += services/sysctl services/hwclock services/sysinit
init_DATA += services/reboot services/shutdown services/sigkill
init_DATA += services/sigterm services/sync services/devfs
init_DATA += services/sysfs services/procfs services/tmpfs
-init_DATA += services/vfs services/ifrename
+init_DATA += services/vfs services/ifrename services/ifcfg
EXTRA_DIST += services/sysinit services/vfs services/agetty services/hostname
EXTRA_DIST += services/hwclock services/loopback services/reboot
diff --git a/services/ifcfg.in b/services/ifcfg.in
new file mode 100644
index 0000000..940a289
--- /dev/null
+++ b/services/ifcfg.in
@@ -0,0 +1,6 @@
+description "static network configuration"
+type wait
+target boot
+after sysinit ifrename
+
+exec "@SCRIPTDIR@/ifcfg.sh" \ No newline at end of file