mirror of
https://github.com/pygos/init.git
synced 2024-11-22 03:09:46 +01:00
Add service and helper script for static network configuration
After interface renaming is done, perform the following actions: - Configure each interface for which we have a configuration file - Configuration file contains lines that we pass directly to iproute2 - Configure static routing in a similar fashion - Set the configured interfaces up Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
This commit is contained in:
parent
0ded476534
commit
a22a212d3a
7 changed files with 102 additions and 1 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -27,8 +27,10 @@ services/devfs
|
||||||
services/procfs
|
services/procfs
|
||||||
services/sysfs
|
services/sysfs
|
||||||
services/ifrename
|
services/ifrename
|
||||||
|
services/ifcfg
|
||||||
|
|
||||||
scripts/devfs.sh
|
scripts/devfs.sh
|
||||||
scripts/ifrename.sh
|
scripts/ifrename.sh
|
||||||
|
scripts/ifcfg.sh
|
||||||
|
|
||||||
etc/initd.env
|
etc/initd.env
|
||||||
|
|
|
@ -38,3 +38,4 @@ install-data-local:
|
||||||
$(LN_S) $(TEMPLATEDIR)/sync $(DESTDIR)$(SVCDIR)/sync@reboot
|
$(LN_S) $(TEMPLATEDIR)/sync $(DESTDIR)$(SVCDIR)/sync@reboot
|
||||||
$(LN_S) $(TEMPLATEDIR)/sigkill $(DESTDIR)$(SVCDIR)/sigkill@reboot
|
$(LN_S) $(TEMPLATEDIR)/sigkill $(DESTDIR)$(SVCDIR)/sigkill@reboot
|
||||||
$(LN_S) $(TEMPLATEDIR)/sigterm $(DESTDIR)$(SVCDIR)/sigterm@reboot
|
$(LN_S) $(TEMPLATEDIR)/sigterm $(DESTDIR)$(SVCDIR)/sigterm@reboot
|
||||||
|
$(LN_S) $(TEMPLATEDIR)/ifcfg $(DESTDIR)$(SVCDIR)/ifcfg
|
||||||
|
|
|
@ -53,8 +53,10 @@ AC_CONFIG_FILES([services/sysfs])
|
||||||
AC_CONFIG_FILES([services/devfs])
|
AC_CONFIG_FILES([services/devfs])
|
||||||
AC_CONFIG_FILES([services/procfs])
|
AC_CONFIG_FILES([services/procfs])
|
||||||
AC_CONFIG_FILES([services/ifrename])
|
AC_CONFIG_FILES([services/ifrename])
|
||||||
|
AC_CONFIG_FILES([services/ifcfg])
|
||||||
AC_CONFIG_FILES([scripts/devfs.sh])
|
AC_CONFIG_FILES([scripts/devfs.sh])
|
||||||
AC_CONFIG_FILES([scripts/ifrename.sh])
|
AC_CONFIG_FILES([scripts/ifrename.sh])
|
||||||
|
AC_CONFIG_FILES([scripts/ifcfg.sh])
|
||||||
AC_CONFIG_FILES([etc/initd.env])
|
AC_CONFIG_FILES([etc/initd.env])
|
||||||
|
|
||||||
AC_OUTPUT([Makefile])
|
AC_OUTPUT([Makefile])
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
helper_SCRIPTS += scripts/devfs.sh scripts/trymount.sh scripts/ifrename.sh
|
helper_SCRIPTS += scripts/devfs.sh scripts/trymount.sh scripts/ifrename.sh
|
||||||
|
helper_SCRIPTS += scripts/ifcfg.sh
|
||||||
|
|
||||||
EXTRA_DIST += scripts/trymount.sh
|
EXTRA_DIST += scripts/trymount.sh
|
||||||
|
|
89
scripts/ifcfg.sh.in
Executable file
89
scripts/ifcfg.sh.in
Executable file
|
@ -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
|
|
@ -4,7 +4,7 @@ init_DATA += services/sysctl services/hwclock services/sysinit
|
||||||
init_DATA += services/reboot services/shutdown services/sigkill
|
init_DATA += services/reboot services/shutdown services/sigkill
|
||||||
init_DATA += services/sigterm services/sync services/devfs
|
init_DATA += services/sigterm services/sync services/devfs
|
||||||
init_DATA += services/sysfs services/procfs services/tmpfs
|
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/sysinit services/vfs services/agetty services/hostname
|
||||||
EXTRA_DIST += services/hwclock services/loopback services/reboot
|
EXTRA_DIST += services/hwclock services/loopback services/reboot
|
||||||
|
|
6
services/ifcfg.in
Normal file
6
services/ifcfg.in
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
description "static network configuration"
|
||||||
|
type wait
|
||||||
|
target boot
|
||||||
|
after sysinit ifrename
|
||||||
|
|
||||||
|
exec "@SCRIPTDIR@/ifcfg.sh"
|
Loading…
Reference in a new issue