mirror of
https://github.com/pygos/init-scripts.git
synced 2024-05-18 19:56:14 +02:00
Compare commits
9 commits
Author | SHA1 | Date | |
---|---|---|---|
David Oberhollenzer | 9e08d160bc | ||
David Oberhollenzer | 418ca4bc72 | ||
David Oberhollenzer | 628adf2e03 | ||
David Oberhollenzer | 7ecb124df2 | ||
David Oberhollenzer | 0309ede4b8 | ||
David Oberhollenzer | 36c14c147d | ||
David Oberhollenzer | 98d5ba81be | ||
David Oberhollenzer | 244f4bbe7a | ||
David Oberhollenzer | 655daedb93 |
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -8,8 +8,6 @@ configure
|
|||
install-sh
|
||||
missing
|
||||
reboot
|
||||
scripts/devfs.sh
|
||||
scripts/ifcfg.sh
|
||||
scripts/ifrename.sh
|
||||
scripts/modules_load.sh
|
||||
services/devfs
|
||||
|
@ -29,6 +27,7 @@ services/swclocksave
|
|||
services/sysfs
|
||||
services/mountusr
|
||||
services/tmpfsvar
|
||||
services/dhcpcd
|
||||
crontab/swclock
|
||||
etc/40-ntpsetdate
|
||||
.#*
|
2
LICENSE
2
LICENSE
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2018 David Oberhollenzer <david.oberhollenzer@tele2.at>
|
||||
Copyright (c) 2018 David Oberhollenzer <goliath@infraroot.at>
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
AC_PREREQ([2.60])
|
||||
|
||||
AC_INIT([init-scripts], [2], [david.oberhollenzer@tele2.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])
|
||||
|
@ -35,9 +35,8 @@ AC_CONFIG_FILES([services/sshd])
|
|||
AC_CONFIG_FILES([services/sshd_keygen])
|
||||
AC_CONFIG_FILES([services/mountusr])
|
||||
AC_CONFIG_FILES([services/tmpfsvar])
|
||||
AC_CONFIG_FILES([scripts/devfs.sh])
|
||||
AC_CONFIG_FILES([services/dhcpcd])
|
||||
AC_CONFIG_FILES([scripts/ifrename.sh])
|
||||
AC_CONFIG_FILES([scripts/ifcfg.sh])
|
||||
AC_CONFIG_FILES([scripts/modules_load.sh])
|
||||
|
||||
AC_CONFIG_FILES([crontab/swclock])
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
|
@ -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
|
|
@ -5,17 +5,7 @@ upper=/cfg/overlay/${1}
|
|||
work=/cfg/overlay/${1}_work
|
||||
target=${2}
|
||||
|
||||
if [ ! -d "$target" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -d "$lower" ]; then
|
||||
if [ -d "$upper" ]; then
|
||||
mkdir -p "$work"
|
||||
mount -t overlay overlay \
|
||||
-olowerdir=${lower},upperdir=${upper},workdir=${work} \
|
||||
${target}
|
||||
else
|
||||
mount --bind "$lower" "$target"
|
||||
fi
|
||||
fi
|
||||
mkdir -p "$work" "$upper"
|
||||
mount -t overlay overlay \
|
||||
-olowerdir=${lower},upperdir=${upper},workdir=${work} \
|
||||
"$target"
|
||||
|
|
|
@ -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
|
||||
|
@ -21,7 +21,7 @@ endif
|
|||
EXTRA_DIST += services/sysinit services/vfs services/agetty services/hostname
|
||||
EXTRA_DIST += services/hwclock services/loopback services/klogd
|
||||
EXTRA_DIST += services/sync services/sysctl services/tmpfs
|
||||
EXTRA_DIST += services/dhcpcd services/dhcpcdmaster services/unbound
|
||||
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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -4,4 +4,7 @@ target boot
|
|||
after dhcpcdmaster network
|
||||
|
||||
tty /dev/null
|
||||
exec dhcpcd -n %0
|
||||
exec {
|
||||
"@SCRIPTDIR@/waitfile" 5 200 /run/dhcpcd.sock /run/dhcpcd.pid
|
||||
dhcpcd -n %0
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
description "DHCP client - master service"
|
||||
type wait
|
||||
type respawn limit 5
|
||||
target boot
|
||||
after network
|
||||
tty /dev/null
|
||||
|
||||
exec {
|
||||
mkdir -p /var/db/dhcpcd
|
||||
dhcpcd --inactive
|
||||
dhcpcd --inactive --nobackground
|
||||
}
|
||||
|
|
|
@ -3,5 +3,4 @@ type wait
|
|||
target boot
|
||||
after sysinit ifrename
|
||||
before network
|
||||
|
||||
exec "@SCRIPTDIR@/ifcfg.sh"
|
||||
exec ip -force -batch "@ETCPATH@/netcfg/static"
|
||||
|
|
|
@ -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"
|
|
@ -1,6 +1,6 @@
|
|||
description "start nginx web server"
|
||||
type once
|
||||
description "nginx web server"
|
||||
type respawn limit 10
|
||||
target boot
|
||||
after network
|
||||
tty /dev/null
|
||||
exec nginx
|
||||
exec nginx -g "daemon off;"
|
||||
|
|
9
services/unmount
Normal file
9
services/unmount
Normal 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
|
||||
}
|
Loading…
Reference in a new issue