mirror of
https://github.com/pygos/init.git
synced 2024-11-22 03:09:46 +01:00
Split default init scripts into seperate package
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
This commit is contained in:
parent
5923ad488a
commit
a8f3360e93
51 changed files with 8 additions and 875 deletions
22
.gitignore
vendored
22
.gitignore
vendored
|
@ -22,26 +22,4 @@ killall5
|
|||
runsvc
|
||||
gcrond
|
||||
|
||||
services/sigkill
|
||||
services/sigterm
|
||||
services/devfs
|
||||
services/procfs
|
||||
services/sysfs
|
||||
services/ifrename
|
||||
services/ifcfg
|
||||
services/ifdown
|
||||
services/modules
|
||||
services/hostapd
|
||||
services/swclock
|
||||
services/swclocksave
|
||||
services/nft
|
||||
services/sshd
|
||||
services/sshd_keygen
|
||||
services/swclocksave.gcron
|
||||
|
||||
scripts/devfs.sh
|
||||
scripts/ifrename.sh
|
||||
scripts/ifcfg.sh
|
||||
scripts/modules_load.sh
|
||||
|
||||
etc/initd.env
|
||||
|
|
29
Makefile.am
29
Makefile.am
|
@ -6,14 +6,15 @@ AM_CFLAGS = $(WARN_CFLAGS)
|
|||
bin_PROGRAMS =
|
||||
sbin_PROGRAMS =
|
||||
noinst_LIBRARIES =
|
||||
nobase_sysconf_DATA = netcfg/ifrename
|
||||
nobase_sysconf_DATA =
|
||||
sysconf_DATA = etc/initd.env
|
||||
EXTRA_DIST = README.md LICENSE docs netcfg
|
||||
|
||||
helperdir = @SCRIPTDIR@
|
||||
helper_PROGRAMS =
|
||||
helper_SCRIPTS =
|
||||
|
||||
EXTRA_DIST = README.md LICENSE docs
|
||||
|
||||
dist_man1_MANS =
|
||||
dist_man8_MANS =
|
||||
|
||||
|
@ -21,8 +22,6 @@ include lib/Makemodule.am
|
|||
include cmd/Makemodule.am
|
||||
include initd/Makemodule.am
|
||||
include crond/Makemodule.am
|
||||
include scripts/Makemodule.am
|
||||
include services/Makemodule.am
|
||||
|
||||
install-exec-hook:
|
||||
(cd $(DESTDIR)$(sbindir); $(LN_S) shutdown reboot)
|
||||
|
@ -31,27 +30,7 @@ install-data-local:
|
|||
$(MKDIR_P) $(DESTDIR)$(man8dir)
|
||||
(cd $(DESTDIR)$(man8dir); $(LN_S) shutdown.8 reboot.8)
|
||||
$(MKDIR_P) $(DESTDIR)$(SVCDIR)
|
||||
$(LN_S) $(TEMPLATEDIR)/loopback $(DESTDIR)$(SVCDIR)/loopback
|
||||
$(LN_S) $(TEMPLATEDIR)/hostname $(DESTDIR)$(SVCDIR)/hostname
|
||||
$(LN_S) $(TEMPLATEDIR)/sysctl $(DESTDIR)$(SVCDIR)/sysctl
|
||||
$(LN_S) $(TEMPLATEDIR)/sysinit $(DESTDIR)$(SVCDIR)/sysinit
|
||||
$(LN_S) $(TEMPLATEDIR)/procfs $(DESTDIR)$(SVCDIR)/procfs
|
||||
$(LN_S) $(TEMPLATEDIR)/sysfs $(DESTDIR)$(SVCDIR)/sysfs
|
||||
$(LN_S) $(TEMPLATEDIR)/devfs $(DESTDIR)$(SVCDIR)/devfs
|
||||
$(LN_S) $(TEMPLATEDIR)/tmpfs $(DESTDIR)$(SVCDIR)/tmpfs
|
||||
$(LN_S) $(TEMPLATEDIR)/vfs $(DESTDIR)$(SVCDIR)/vfs
|
||||
$(LN_S) $(TEMPLATEDIR)/ifdown $(DESTDIR)$(SVCDIR)/ifdown@shutdown
|
||||
$(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)/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)/ifcfg $(DESTDIR)$(SVCDIR)/ifcfg
|
||||
$(LN_S) $(TEMPLATEDIR)/modules $(DESTDIR)$(SVCDIR)/modules
|
||||
$(LN_S) $(TEMPLATEDIR)/network $(DESTDIR)$(SVCDIR)/network
|
||||
$(MKDIR_P) $(DESTDIR)$(TEMPLATEDIR)
|
||||
if GCROND
|
||||
$(MKDIR_P) $(DESTDIR)$(GCRONDIR)
|
||||
$(LN_S) $(TEMPLATEDIR)/gcrond $(DESTDIR)$(SVCDIR)/gcrond
|
||||
endif
|
||||
|
|
14
README.md
14
README.md
|
@ -23,10 +23,10 @@ in `/etc/init.d`. This can be done more conveniently using the `service`
|
|||
command line tool.
|
||||
|
||||
|
||||
A default setup is provided, as needed for the Pygos system, including helper
|
||||
scripts for setting up mount points and for network configuration. If you want
|
||||
to use the init daemon for another system, you may have to toss out or adapt
|
||||
some of the default configuration and make your own.
|
||||
A default setup for the Pygos system, including helper scripts for setting up
|
||||
mount points and for network configuration, is provided in a seperate package.
|
||||
This package only contains the bare init framework without any default
|
||||
configuration.
|
||||
|
||||
|
||||
Right now, the system is in a "basically works" proof of concept stage and
|
||||
|
@ -46,12 +46,6 @@ command line tools.
|
|||
See [docs/services.md](docs/services.md) for more information on service
|
||||
description files.
|
||||
|
||||
See [docs/network.md](docs/network.md) for information on how the network
|
||||
configuration works.
|
||||
|
||||
See [docs/defconfig.md](docs/defconfig.md) for an explanation on the default
|
||||
services and configuration provided with this package.
|
||||
|
||||
See [docs/gcron.md](docs/gcron.md) for details on the cron implementation.
|
||||
|
||||
|
||||
|
|
20
configure.ac
20
configure.ac
|
@ -61,26 +61,6 @@ AC_DEFINE_DIR(STATEFILESPATH, prefix/var/lib, [Path for persistent state files])
|
|||
|
||||
AC_DEFINE_DIR(PREFIXPATH, prefix, [Fully expaneded installation prefix])
|
||||
|
||||
AC_CONFIG_FILES([services/sigkill])
|
||||
AC_CONFIG_FILES([services/sigterm])
|
||||
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([services/ifdown])
|
||||
AC_CONFIG_FILES([services/modules])
|
||||
AC_CONFIG_FILES([services/hostapd])
|
||||
AC_CONFIG_FILES([services/swclock])
|
||||
AC_CONFIG_FILES([services/swclocksave])
|
||||
AC_CONFIG_FILES([services/swclocksave.gcron])
|
||||
AC_CONFIG_FILES([services/nft])
|
||||
AC_CONFIG_FILES([services/sshd])
|
||||
AC_CONFIG_FILES([services/sshd_keygen])
|
||||
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([etc/initd.env])
|
||||
|
||||
AC_OUTPUT([Makefile])
|
||||
|
|
|
@ -1,119 +0,0 @@
|
|||
# Default Service Configuration
|
||||
|
||||
## Pseudo Services
|
||||
|
||||
The default configuration contains a number of "pseudo services" in the boot
|
||||
target that don't actually do anything but are merely used as anchors in
|
||||
service dependencies, i.e. they indicate that some sort of milestone in the
|
||||
boot sequence has been reached. Everything that is part of that milestone
|
||||
specifies that it should be run *before* that pseudo service and everything
|
||||
that requires that this milestone has been reached, specifies that it wants
|
||||
to run afterwards.
|
||||
|
||||
The pseudo targets are (in the order that they are executed):
|
||||
|
||||
* vfs
|
||||
|
||||
All services that do mount point setup go before this, all service that
|
||||
depend on the fully mounted rootfs go after this.
|
||||
|
||||
* sysinit
|
||||
|
||||
The system has reached a sane state, i.e. the hostname is set, the system
|
||||
clock has a sane value, modules and kernel parameters are loaded, some
|
||||
very basic, fundamental services are running.
|
||||
Everything that is part of that setup process goes between `vfs` and
|
||||
`sysinit`, everything that requires a sane setup goes *after* `sysinit`.
|
||||
|
||||
* network
|
||||
|
||||
Network configuration is done. All services that do network configuration
|
||||
should position themselves between `sysinit` and `network`. Everything that
|
||||
requires a fully configured networking setup should go *after* `network`.
|
||||
|
||||
## Default Bootup Services
|
||||
|
||||
This section outlines the services for the boot target that are enabled by
|
||||
default.
|
||||
|
||||
|
||||
The following services are enabled by default and run *before* the `vfs` target
|
||||
for filesystem setup:
|
||||
|
||||
* procfs - mount `procfs` to `/proc` and try to mount additional pseudo
|
||||
filesystems in `/proc` such as `binfmt_misc`
|
||||
* tmpfs - mount a `tmpfs` to `/tmp`
|
||||
* sysfs - mount `sysfs` to `/sys` and try to mount additional pseudo
|
||||
filesystems in `/sys` (e.g. `securityfs`, `configfs`, ...)
|
||||
* devfs - mount `devtmpfs` to `/dev`, try to mount additional pseudo
|
||||
filesystems in `/dev` (e.g. `devpts`, `mqueue`, ...) and try to create
|
||||
some additional device nodes and symlinks.
|
||||
|
||||
|
||||
The following services are enabled by default and configured to run *after*
|
||||
the `vfs` target and *before* the `sysinit` target:
|
||||
|
||||
* hostname - reload hostname `/etc/hostname`
|
||||
* loopback - bring the loopback device up
|
||||
* modules - iterate over the file `/etc/modules` and try to load each module
|
||||
using modprobe.
|
||||
* sysctl - restore kernel parameters using `sysctl --system`. See `sysctl(8)`
|
||||
for a list of possible locations that the parameters are read from.
|
||||
|
||||
|
||||
The following services are enabled by default and configured to run *after*
|
||||
the `sysinit` target and *before* the `network` target:
|
||||
|
||||
* ifcfg - static network configuration
|
||||
Does the static network configuration outlined in [network.md](network.md)
|
||||
|
||||
The following services are enabled by default and configured to run *after*
|
||||
the `network` target:
|
||||
|
||||
* gcrond - if the `gcrond` daemon is compiled with this package, this service
|
||||
is enabled by default.
|
||||
|
||||
|
||||
## Default Shutdown and Reboot Services
|
||||
|
||||
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
|
||||
* sync - run the sync command
|
||||
|
||||
|
||||
## Additional Services not Enabled by Default
|
||||
|
||||
* agetty - A parameterizeable, respawn type `agetty` service. The first
|
||||
parameter is the terminal device that the getty should run on.
|
||||
* consolefont - If enabled, run once before sysinit. Sets the console font
|
||||
to the first parameter.
|
||||
* dhcpcdmaster - If one or more network interfaces should be configured using
|
||||
dhcpcd, this service starts a central `dhcpcd` master instance.
|
||||
* dhcpcd - A parameterizeable single shot service that signals the `dhcpcd`
|
||||
master that it should configure a specific interface. The first parameter
|
||||
is the interface that should be configured by `dhcpcd`.
|
||||
* dnsmasq - A respawn type service for the `dnsmasq` DNS and DHCP server.
|
||||
* hostapd - If the system should operate a WIFI access point, this respawn
|
||||
type service can be enabled to manage an instace of the `hostapd` program.
|
||||
* unbound - A respawn type service that manages an instance of the `unbound`
|
||||
name resolver.
|
||||
* hwclock - If the system has a hardware clock, this service can restore the
|
||||
kernels clock from the hardware at bootup, between the `vfs` and `sysinit`
|
||||
targets.
|
||||
* nft - If enabled, restores net filter table rules during boot.
|
||||
* swclock - For systems that don't have a hardware clock, this service
|
||||
restores a somewhat usable time from a file during boot.
|
||||
* swclocksave - For systems that don't have a hardware clock, this service
|
||||
saves the current time to a file during shutdown or reboot.
|
||||
* sshd_keygen - A wait type service that generates host keys for the OpenSSH
|
||||
server and then disables itself.
|
||||
* sshd - Starts an OpenSSH server after the network pseudo service and after
|
||||
the sshd_keygen service.
|
||||
* nginx - Starts the Nginx server after the network pseudo serivce.
|
||||
* usyslogd - Starts and supervises the `usyslogd` syslog implementation as
|
||||
part of the `sysinit` target.
|
||||
* klogd - Stats and supervises the `klogd` daemon as part of the `sysinit`
|
||||
target. The `klogd` daemon is part of the `usyslog` package.
|
|
@ -1,83 +0,0 @@
|
|||
# Static Network Configuration
|
||||
|
||||
The default configuration provides multiple services that perform network
|
||||
initialization and static configuration using helper scripts that require
|
||||
programs from the `iproute2` package.
|
||||
|
||||
Configuration files are typically stored in `/etc/netcfg/` (depending on
|
||||
configure options).
|
||||
|
||||
Please note that the loopback device is treated specially and not included in
|
||||
any of the network configuration outlined below. The loopback device is brought
|
||||
up and configured by a dedicated service long before the network configuration
|
||||
is done.
|
||||
|
||||
|
||||
## Interface Renaming
|
||||
|
||||
If the `ifrename` service is enabled (it is disabled by default), network
|
||||
interfaces are renamed based on a rule set stored in the file `ifrename`.
|
||||
The file contains comma separated shell globing patterns for the current
|
||||
interface name, MAC address and a prefix for the new interface name.
|
||||
|
||||
For each network interface, rules are processed top to bottom. If the first two
|
||||
globing patterns apply, the interface is renamed. Interfaces with the same
|
||||
prefix are sorted by mac address and a running index is appended to the prefix.
|
||||
|
||||
If none of the rules apply, the interface name is left unchanged.
|
||||
|
||||
|
||||
The intent is, to provide a way to configure persistent, deterministic names for
|
||||
at least all network interfaces that are permanently installed on a board.
|
||||
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
|
||||
## Net Filter Tables
|
||||
|
||||
|
||||
An additional service is provided that restores the nft rule set from
|
||||
`/etc/nftables.rules`.
|
|
@ -1,13 +0,0 @@
|
|||
#
|
||||
# Interface renaming rules
|
||||
#
|
||||
# Format: NAME,MAC,NEWNAME
|
||||
#
|
||||
# NAME and MAC are shell glob patterns. Both must match for a rule to apply.
|
||||
# The first matching rule is chosen (top to bottom).
|
||||
#
|
||||
# Interfaces with the same NEWNAME are sorted by MAC and have a running
|
||||
# index appended to their new name.
|
||||
#
|
||||
# Example: rename all ethernet interfaces to "port<X>"
|
||||
# eth*,*,port
|
|
@ -1,5 +0,0 @@
|
|||
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/setntpdate.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,89 +0,0 @@
|
|||
#!/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
|
|
@ -1,26 +0,0 @@
|
|||
#!/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/>.
|
||||
#
|
||||
for IFPATH in /sys/class/net/*; do
|
||||
[ "$IFPATH" == "/sys/class/net/lo" ] && continue
|
||||
|
||||
IF=`basename $IFPATH`
|
||||
|
||||
ip link set dev "$IF" down
|
||||
done
|
|
@ -1,65 +0,0 @@
|
|||
#!/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/>.
|
||||
#
|
||||
NAMERULES="@ETCPATH@/netcfg/ifrename"
|
||||
TMPPATH="/tmp/ifrename"
|
||||
|
||||
[ -f "$NAMERULES" ] || exit 0
|
||||
|
||||
mkdir -p "$TMPPATH"
|
||||
|
||||
for IFPATH in /sys/class/net/*; do
|
||||
[ "$IFPATH" == "/sys/class/net/lo" ] && continue
|
||||
|
||||
IF=`basename $IFPATH`
|
||||
MAC=`cat $IFPATH/address`
|
||||
|
||||
grep "^[^,]\+,[^,]\+,[a-zA-Z0-9]\+$" $NAMERULES | while read LINE;
|
||||
do
|
||||
NAMECMP=$(echo $LINE | cut -d',' -f1)
|
||||
ADDRCMP=$(echo $LINE | cut -d',' -f2)
|
||||
RULE=$(echo $LINE | cut -d',' -f3)
|
||||
|
||||
case $IF in ($NAMECMP) ;; *) continue;; esac
|
||||
case $MAC in ($ADDRCMP) ;; *) continue;; esac
|
||||
|
||||
echo "$MAC,$IF" >> "$TMPPATH/$RULE"
|
||||
break
|
||||
done
|
||||
done
|
||||
|
||||
for FNAME in $TMPPATH/*; do
|
||||
[ ! -f "$FNAME" ] && break
|
||||
|
||||
IDX=0
|
||||
PREFIX=$(basename $FNAME)
|
||||
|
||||
sort -t',' -k1 -u $FNAME | while read LINE;
|
||||
do
|
||||
OLDNAME=$(echo $LINE | cut -d',' -f2)
|
||||
NEWNAME="$PREFIX$IDX"
|
||||
IDX=`expr $IDX + 1`
|
||||
|
||||
ip link set "$OLDNAME" name "$NEWNAME"
|
||||
done
|
||||
|
||||
rm "$FNAME"
|
||||
done
|
||||
|
||||
rmdir "$TMPPATH"
|
|
@ -1,39 +0,0 @@
|
|||
#!/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/>.
|
||||
#
|
||||
MODLIST="@ETCPATH@/modules"
|
||||
|
||||
if [ ! -f "$MODLIST" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
while read LINE;
|
||||
do
|
||||
trimmed=`echo -- $LINE`
|
||||
[ ! -z "$trimmed" ] || continue
|
||||
set $trimmed
|
||||
|
||||
case "$1" in
|
||||
\#*)
|
||||
;;
|
||||
*)
|
||||
modprobe "$1"
|
||||
;;
|
||||
esac
|
||||
done < "$MODLIST"
|
|
@ -1,67 +0,0 @@
|
|||
#!/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/>.
|
||||
#
|
||||
|
||||
resolve() {
|
||||
local domain="$1"
|
||||
local server="$2"
|
||||
|
||||
if [ -x "$(command -v dig)" ]; then
|
||||
if [ -z "$server" ]; then
|
||||
dig +short "$domain"
|
||||
else
|
||||
dig +short "@$server" "$domain"
|
||||
fi
|
||||
return $?
|
||||
fi
|
||||
|
||||
if [ -x "$(command -v drill)" ]; then
|
||||
if [ -z "$server" ]; then
|
||||
drill "$domain" | grep "^${domain}." | cut -d$'\t' -f5
|
||||
else
|
||||
drill "@$server" "$domain" | grep "^${domain}." |\
|
||||
cut -d$'\t' -f5
|
||||
fi
|
||||
return $?
|
||||
fi
|
||||
exit 1
|
||||
}
|
||||
|
||||
try_update() {
|
||||
while read ip; do
|
||||
if ntpdate -bu "$ip"; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
pool="pool.ntp.org"
|
||||
dns="1.1.1.1"
|
||||
|
||||
# try default DNS server first
|
||||
resolve "$pool" "" | try_update
|
||||
[ $? -eq 0 ] && exit 0
|
||||
|
||||
# try fallback public dns server
|
||||
ping -q -c 1 "$dns" || exit 1
|
||||
|
||||
resolve "$pool" "$dns" | try_update
|
||||
exit $?
|
|
@ -1,7 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ -d "$1" ]; then
|
||||
if grep -qsE "[[:space:]]+$2$" "/proc/filesystems"; then
|
||||
mount -n -t "$2" -o "$3" "$2" "$1"
|
||||
fi
|
||||
fi
|
|
@ -1,27 +0,0 @@
|
|||
initdir = @TEMPLATEDIR@
|
||||
init_DATA = services/agetty services/hostname services/loopback
|
||||
init_DATA += services/sysctl services/hwclock services/sysinit
|
||||
init_DATA += services/sigterm services/sync services/devfs
|
||||
init_DATA += services/sysfs services/procfs services/tmpfs
|
||||
init_DATA += services/vfs services/ifrename services/ifcfg
|
||||
init_DATA += services/dhcpcd services/dhcpcdmaster services/unbound
|
||||
init_DATA += services/dnsmasq services/ifdown services/modules
|
||||
init_DATA += services/network services/hostapd services/swclock
|
||||
init_DATA += services/swclocksave services/nft services/sigkill
|
||||
init_DATA += services/sshd services/sshd_keygen services/consolefont
|
||||
init_DATA += services/nginx services/usyslogd services/klogd
|
||||
|
||||
if GCROND
|
||||
init_DATA += services/swclocksave.gcron
|
||||
endif
|
||||
|
||||
if GCROND
|
||||
init_DATA += services/gcrond
|
||||
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/usyslogd services/dnsmasq services/network
|
||||
EXTRA_DIST += services/consolefont services/gcrond services/nginx
|
|
@ -1,6 +0,0 @@
|
|||
description agetty on %0
|
||||
exec agetty %0 linux
|
||||
type respawn
|
||||
target boot
|
||||
after network
|
||||
tty "/dev/%0"
|
|
@ -1,6 +0,0 @@
|
|||
description set console font
|
||||
type once
|
||||
target boot
|
||||
before sysinit
|
||||
after vfs
|
||||
exec setfont %0
|
|
@ -1,6 +0,0 @@
|
|||
description "mount /dev"
|
||||
type wait
|
||||
target boot
|
||||
after procfs sysfs
|
||||
before vfs
|
||||
exec "@SCRIPTDIR@/devfs.sh"
|
|
@ -1,7 +0,0 @@
|
|||
description "DHCP client on %0"
|
||||
type once
|
||||
target boot
|
||||
after dhcpcdmaster network
|
||||
|
||||
tty /dev/null
|
||||
exec dhcpcd -n %0
|
|
@ -1,10 +0,0 @@
|
|||
description "DHCP client - master service"
|
||||
type wait
|
||||
target boot
|
||||
after network
|
||||
tty /dev/null
|
||||
|
||||
exec {
|
||||
mkdir -p /var/db/dhcpcd
|
||||
dhcpcd --inactive
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
description "dnsmasq DNS & DHCP server"
|
||||
type respawn limit 5
|
||||
target boot
|
||||
after network unbound
|
||||
|
||||
exec dnsmasq -k
|
|
@ -1,5 +0,0 @@
|
|||
description start gcron daemon
|
||||
exec gcrond
|
||||
type respawn
|
||||
target boot
|
||||
after network
|
|
@ -1,7 +0,0 @@
|
|||
description "WIFI access point daemon"
|
||||
type respawn limit 10
|
||||
target boot
|
||||
after sysinit ifrename
|
||||
before network ifcfg
|
||||
|
||||
exec hostapd "@ETCPATH@/hostapd.conf"
|
|
@ -1,6 +0,0 @@
|
|||
description reload hostname
|
||||
exec hostname --file /etc/hostname
|
||||
type wait
|
||||
target boot
|
||||
before sysinit
|
||||
after hwclock vfs
|
|
@ -1,6 +0,0 @@
|
|||
description restore time from RTC
|
||||
exec hwclock --hctosys --utc
|
||||
type wait
|
||||
target boot
|
||||
before sysinit
|
||||
after vfs modules
|
|
@ -1,7 +0,0 @@
|
|||
description "static network configuration"
|
||||
type wait
|
||||
target boot
|
||||
after sysinit ifrename
|
||||
before network
|
||||
|
||||
exec "@SCRIPTDIR@/ifcfg.sh"
|
|
@ -1,7 +0,0 @@
|
|||
description "stop all network interfaces"
|
||||
type wait
|
||||
target %0
|
||||
after sigkill sigterm
|
||||
before sync
|
||||
|
||||
exec "@SCRIPTDIR@/ifdown.sh"
|
|
@ -1,7 +0,0 @@
|
|||
description "rename network interfaces"
|
||||
type wait
|
||||
target boot
|
||||
after sysinit
|
||||
before network
|
||||
|
||||
exec "@SCRIPTDIR@/ifrename.sh"
|
|
@ -1,6 +0,0 @@
|
|||
description "starting uklogd"
|
||||
exec klogd
|
||||
type respawn limit 5
|
||||
target boot
|
||||
after usyslogd
|
||||
before sysinit
|
|
@ -1,10 +0,0 @@
|
|||
description configure network loopback device
|
||||
type wait
|
||||
target boot
|
||||
before sysinit
|
||||
after hostname vfs
|
||||
|
||||
exec {
|
||||
ip addr add 127.0.0.1/8 dev lo brd +
|
||||
ip link set lo up
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
description "load kernel modules"
|
||||
type wait
|
||||
target boot
|
||||
after vfs usyslogd
|
||||
before sysinit
|
||||
|
||||
exec "@SCRIPTDIR@/modules_load.sh"
|
|
@ -1,4 +0,0 @@
|
|||
description "static network configuration completed"
|
||||
type wait
|
||||
target boot
|
||||
after sysinit
|
|
@ -1,7 +0,0 @@
|
|||
description "restore netfilter rule set"
|
||||
type wait
|
||||
target boot
|
||||
after sysinit ifrename
|
||||
before network ifcfg
|
||||
|
||||
exec nft -f "@ETCPATH@/nftables.rules"
|
|
@ -1,6 +0,0 @@
|
|||
description "start nginx web server"
|
||||
type once
|
||||
target boot
|
||||
after network
|
||||
tty /dev/null
|
||||
exec nginx
|
|
@ -1,9 +0,0 @@
|
|||
description "mount /proc"
|
||||
type wait
|
||||
target boot
|
||||
before vfs
|
||||
|
||||
exec {
|
||||
mount -t proc proc /proc
|
||||
"@SCRIPTDIR@/trymount.sh" /proc/sys/fs/binfmt_misc binfmt_misc nodev,noexec,nosuid
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
description send SIGKILL to remaining processes
|
||||
exec "@SCRIPTDIR@/killall5" 9
|
||||
type wait
|
||||
target %0
|
||||
after sigterm
|
||||
before sync shutdown reboot
|
|
@ -1,9 +0,0 @@
|
|||
description send SIGTERM to all processes
|
||||
type wait
|
||||
target %0
|
||||
before sigkill sync reboot shutdown
|
||||
|
||||
exec {
|
||||
"@SCRIPTDIR@/killall5" 15
|
||||
sleep 5
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
description "OpenSSH server"
|
||||
type respawn limit 5
|
||||
target boot
|
||||
after network sshd_keygen
|
||||
exec "@SBINPATH@/sshd" -D
|
|
@ -1,14 +0,0 @@
|
|||
description "OpenSSH server - generate host keys"
|
||||
type wait
|
||||
target boot
|
||||
after network
|
||||
tty /dev/null
|
||||
exec {
|
||||
mkdir -p "@ETCPATH@/ssh/"
|
||||
|
||||
ssh-keygen -f "@ETCPATH@/ssh/host_rsa_key" -N "" -t rsa
|
||||
ssh-keygen -f "@ETCPATH@/ssh/host_ecdsa_key" -N "" -t ecdsa
|
||||
ssh-keygen -f "@ETCPATH@/ssh/host_ed25519_key" -N "" -t ed25519
|
||||
|
||||
service disable sshd_keygen
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
description restore saved time from last shutdown
|
||||
type wait
|
||||
target boot
|
||||
before sysinit
|
||||
after vfs modules
|
||||
exec xargs -a @STATEFILESPATH@/swclock date --utc
|
|
@ -1,3 +0,0 @@
|
|||
interval hourly
|
||||
tty truncate @STATEFILESPATH@/swclock
|
||||
exec date --utc +%%m%%d%%H%%M%%Y.%%S
|
|
@ -1,7 +0,0 @@
|
|||
description write current time to backup file
|
||||
type wait
|
||||
target %0
|
||||
after sigkill
|
||||
before sync
|
||||
tty truncate @STATEFILESPATH@/swclock
|
||||
exec date --utc +%%m%%d%%H%%M%%Y.%%S
|
|
@ -1,6 +0,0 @@
|
|||
description sync
|
||||
exec sync
|
||||
type wait
|
||||
target %0
|
||||
after sigkill sigterm
|
||||
before reboot shutdown
|
|
@ -1,7 +0,0 @@
|
|||
description configure kernel paramters
|
||||
tty /dev/null
|
||||
exec sysctl --system
|
||||
type wait
|
||||
target boot
|
||||
before sysinit
|
||||
after vfs loopback
|
|
@ -1,13 +0,0 @@
|
|||
description "mount /sys"
|
||||
type wait
|
||||
target boot
|
||||
after procfs
|
||||
before vfs
|
||||
|
||||
exec {
|
||||
mount -t sysfs sysfs /sys
|
||||
"@SCRIPTDIR@/trymount.sh" /sys/kernel/security securityfs nodev,noexec,nosuid
|
||||
"@SCRIPTDIR@/trymount.sh" /sys/kernel/config configfs nodev,noexec,nosuid
|
||||
"@SCRIPTDIR@/trymount.sh" /sys/fs/fuse/connections fusectl nodev,noexec,nosuid
|
||||
"@SCRIPTDIR@/trymount.sh" /sys/firmware/efi/efivars efivarfs ro
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
description basic system initialization
|
||||
type wait
|
||||
target boot
|
||||
after vfs
|
||||
before network
|
|
@ -1,5 +0,0 @@
|
|||
description "mount /tmp"
|
||||
type wait
|
||||
target boot
|
||||
before vfs
|
||||
exec mount -t tmpfs none /tmp
|
|
@ -1,6 +0,0 @@
|
|||
description "Unbound resolver"
|
||||
type respawn limit 5
|
||||
target boot
|
||||
after network
|
||||
|
||||
exec unbound -d
|
|
@ -1,6 +0,0 @@
|
|||
description "starting usyslogd"
|
||||
exec usyslogd --chroot --rotate-replace --max-size 8192
|
||||
type respawn limit 5
|
||||
target boot
|
||||
after vfs
|
||||
before sysinit
|
|
@ -1,4 +0,0 @@
|
|||
description VFS setup done
|
||||
type wait
|
||||
target boot
|
||||
before sysinit
|
Loading…
Reference in a new issue