1
0
Fork 0
mirror of https://github.com/pygos/init-scripts.git synced 2024-05-18 19:56:14 +02:00

Compare commits

...

4 commits
v3 ... master

Author SHA1 Message Date
David Oberhollenzer 9e08d160bc Bump version number
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-09-18 13:07:09 +02:00
David Oberhollenzer 418ca4bc72 Propperly unmount the overlay partition on shutdown
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-09-18 13:07:09 +02:00
David Oberhollenzer 628adf2e03 Move contents of devfs.sh script into service file
Conditionals can be eliminated, since we know exactely what the
situation looks like on Linux.

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-09-18 13:07:09 +02:00
David Oberhollenzer 7ecb124df2 Replace static network config script with iproute2 batch file
A lot simpler than make-shift DSL parsing with bash.

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-08-11 01:41:28 +02:00
13 changed files with 42 additions and 144 deletions

2
.gitignore vendored
View file

@ -8,8 +8,6 @@ configure
install-sh
missing
reboot
scripts/devfs.sh
scripts/ifcfg.sh
scripts/ifrename.sh
scripts/modules_load.sh
services/devfs

View file

@ -35,10 +35,12 @@ install-data-local:
$(LN_S) $(TEMPLATEDIR)/sync $(DESTDIR)$(SVCDIR)/sync@shutdown
$(LN_S) $(TEMPLATEDIR)/sigkill $(DESTDIR)$(SVCDIR)/sigkill@shutdown
$(LN_S) $(TEMPLATEDIR)/sigterm $(DESTDIR)$(SVCDIR)/sigterm@shutdown
$(LN_S) $(TEMPLATEDIR)/unmount $(DESTDIR)$(SVCDIR)/unmount@shutdown
$(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)/ifdown $(DESTDIR)$(SVCDIR)/ifdown@reboot
$(LN_S) $(TEMPLATEDIR)/unmount $(DESTDIR)$(SVCDIR)/unmount@reboot
$(LN_S) $(TEMPLATEDIR)/ifcfg $(DESTDIR)$(SVCDIR)/ifcfg
$(LN_S) $(TEMPLATEDIR)/modules $(DESTDIR)$(SVCDIR)/modules
$(LN_S) $(TEMPLATEDIR)/network $(DESTDIR)$(SVCDIR)/network

View file

@ -1,6 +1,6 @@
AC_PREREQ([2.60])
AC_INIT([init-scripts], [3], [goliath@infraroot.at], init-scripts)
AC_INIT([init-scripts], [4], [goliath@infraroot.at], init-scripts)
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign subdir-objects dist-xz])
AM_SILENT_RULES([yes])
@ -36,9 +36,7 @@ AC_CONFIG_FILES([services/sshd_keygen])
AC_CONFIG_FILES([services/mountusr])
AC_CONFIG_FILES([services/tmpfsvar])
AC_CONFIG_FILES([services/dhcpcd])
AC_CONFIG_FILES([scripts/devfs.sh])
AC_CONFIG_FILES([scripts/ifrename.sh])
AC_CONFIG_FILES([scripts/ifcfg.sh])
AC_CONFIG_FILES([scripts/modules_load.sh])
AC_CONFIG_FILES([crontab/swclock])

View file

@ -90,6 +90,8 @@ For the shutdown and reboot targets, the following services are executed:
* sigterm - send the SIGTERM signal to all processes and wait for 5 seconds
* sigkill - send the SIGKILL signal to all remaining processes
* ifdown - bring all network interfaces down
* unmount - unmount the overlay mount points and the underlying
writeable filesystem
* sync - run the sync command

View file

@ -34,46 +34,12 @@ Extension cards or external network adapters should be given a different prefix
to avoid changes in the order as they come and go.
## Interface Configuration
## Static Interface and Route Configuration
After interface renaming, for each network interface, the configuration path is
scanned for files with the same name as the interface.
Each successfully found configuration file is processed line by line, top to
bottom. Each line may contain a keyword, followed by multiple arguments.
The following keywords can be used to add IPv4 or IPv6 network addresses to
an interface:
* address
* addr
* ip
* ip6
* ipv6
Those commands are expected to be followed by an IPv4 or IPv6 address and
network mask.
Furthermore, the following commands can be used for configuring interface
parameters:
* `arp {on|off}`
* `multicast {on|off}`
* `mtu <value>`
* `offload [rx {on|off}] [tx {on|off}] [sg {on|off}] [tso {on|off}]`
* `offload [gso {on|off}] [gro {on|off}] [lro {on|off}] [rxvlan {on|off}]`
* `offload [txvlan {on|off}] [ntuple {on|off}] [rxhash {on|off}]`
* `offload [ufo {on|off}]`
## Route Configuration
After interface configuration is done, routes and rules are restored from a
file named `routes` in the same configuration path.
The file may contain lines starting with `route` or `rule`. Everything that
follows is passed on to `ip route add` or `ip rule add` respectively.
After interface renaming, an iproute2 batch script `/etc/netcfg/static` is
executed with the `-force` option is set, i.e. it will plough throug the
entire script without aborting, but the service will be marked as having
failed if any of the batch lines fail.
## Net Filter Tables

View file

@ -1,5 +1,5 @@
helper_SCRIPTS += scripts/devfs.sh scripts/trymount.sh scripts/ifrename.sh
helper_SCRIPTS += scripts/ifcfg.sh scripts/ifdown.sh scripts/modules_load.sh
helper_SCRIPTS += scripts/trymount.sh scripts/ifrename.sh
helper_SCRIPTS += scripts/ifdown.sh scripts/modules_load.sh
helper_SCRIPTS += scripts/setntpdate.sh scripts/overlay.sh
EXTRA_DIST += scripts/trymount.sh scripts/ifdown.sh scripts/setntpdate.sh

View file

@ -1,21 +0,0 @@
#!/bin/sh
mount -t devtmpfs none /dev
[ -c /dev/console ] || mknod -m 600 /dev/console c 5 1
[ -c /dev/tty ] || mknod -m 666 /dev/tty c 5 0
[ -c /dev/null ] || mknod -m 666 /dev/null c 1 3
[ -c /dev/kmsg ] || mknod -m 660 /dev/kmsg c 1 11
[ -e /dev/fd ] || ln -snf /proc/self/fd /dev/fd
[ -e /dev/stdin ] || ln -snf /proc/self/fd/0 /dev/stdin
[ -e /dev/stdout ] || ln -snf /proc/self/fd/1 /dev/stdout
[ -e /dev/stderr ] || ln -snf /proc/self/fd/2 /dev/stderr
[ -e /proc/kcore ] && ln -snf /proc/kcore /dev/core
mkdir -p /dev/mqueue -m 1777
mkdir -p /dev/pts -m 0755
mkdir -p /dev/shm -m 1777
@SCRIPTDIR@/trymount.sh "/dev/mqueue" "mqueue" "noexec,nosuid,nodev"
@SCRIPTDIR@/trymount.sh "/dev/pts" "devpts" "noexec,nosuid,gid=5,mode=0620"
@SCRIPTDIR@/trymount.sh "/dev/shm" "tmpfs" "noexec,nosuid,nodev,mode=1777"

View file

@ -1,71 +0,0 @@
#!/bin/sh
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

View file

@ -8,7 +8,7 @@ init_DATA += services/unbound services/dnsmasq services/ifdown services/modules
init_DATA += services/network services/hostapd services/nft services/sigkill
init_DATA += services/sshd services/sshd_keygen services/consolefont
init_DATA += services/nginx services/usyslogd services/klogd
init_DATA += services/gcrond services/mountusr
init_DATA += services/gcrond services/mountusr services/unmount
init_DATA += services/tmpfsrun services/tmpfsvar
if DHCPCLIENT
@ -24,4 +24,4 @@ EXTRA_DIST += services/sync services/sysctl services/tmpfs
EXTRA_DIST += services/dhcpcdmaster services/unbound
EXTRA_DIST += services/usyslogd services/dnsmasq services/network
EXTRA_DIST += services/consolefont services/gcrond services/nginx
EXTRA_DIST += services/tmpfsrun
EXTRA_DIST += services/tmpfsrun services/unmount

View file

@ -3,4 +3,20 @@ type wait
target boot
after procfs sysfs
before vfs
exec "@SCRIPTDIR@/devfs.sh"
exec {
mount -t devtmpfs none /dev
ln -snf /proc/self/fd /dev/fd
ln -snf /proc/self/fd/0 /dev/stdin
ln -snf /proc/self/fd/1 /dev/stdout
ln -snf /proc/self/fd/2 /dev/stderr
ln -snf /proc/kcore /dev/core
mkdir -p /dev/mqueue -m 1777
mkdir -p /dev/pts -m 0755
mkdir -p /dev/shm -m 1777
"@SCRIPTDIR@/trymount.sh" /dev/mqueue mqueue noexec,nosuid,nodev
"@SCRIPTDIR@/trymount.sh" /dev/pts devpts noexec,nosuid,gid=5,mode=0620
"@SCRIPTDIR@/trymount.sh" /dev/shm tmpfs noexec,nosuid,nodev,mode=1777
}

View file

@ -3,5 +3,4 @@ type wait
target boot
after sysinit ifrename
before network
exec "@SCRIPTDIR@/ifcfg.sh"
exec ip -force -batch "@ETCPATH@/netcfg/static"

View file

@ -2,6 +2,6 @@ description "stop all network interfaces"
type wait
target %0
after sigkill sigterm
before sync
before sync unmount
exec "@SCRIPTDIR@/ifdown.sh"

9
services/unmount Normal file
View file

@ -0,0 +1,9 @@
description unmount overlay filesystem
type wait
target %0
after sigkill
before sync
exec {
umount -nli /var/lib /usr /etc
umount -nli /cfg/overlay
}