From a8f3360e938b3cfc8b785222be522cdbf83e5692 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Mon, 5 Nov 2018 15:56:27 +0100 Subject: [PATCH] Split default init scripts into seperate package Signed-off-by: David Oberhollenzer --- .gitignore | 22 ------- Makefile.am | 29 ++------- README.md | 14 ++-- configure.ac | 20 ------ docs/defconfig.md | 119 ---------------------------------- docs/network.md | 83 ------------------------ netcfg/ifrename | 13 ---- scripts/Makemodule.am | 5 -- scripts/devfs.sh.in | 21 ------ scripts/ifcfg.sh.in | 89 ------------------------- scripts/ifdown.sh | 26 -------- scripts/ifrename.sh.in | 65 ------------------- scripts/modules_load.sh.in | 39 ----------- scripts/setntpdate.sh | 67 ------------------- scripts/trymount.sh | 7 -- services/Makemodule.am | 27 -------- services/agetty | 6 -- services/consolefont | 6 -- services/devfs.in | 6 -- services/dhcpcd | 7 -- services/dhcpcdmaster | 10 --- services/dnsmasq | 6 -- services/gcrond | 5 -- services/hostapd.in | 7 -- services/hostname | 6 -- services/hwclock | 6 -- services/ifcfg.in | 7 -- services/ifdown.in | 7 -- services/ifrename.in | 7 -- services/klogd | 6 -- services/loopback | 10 --- services/modules.in | 7 -- services/network | 4 -- services/nft.in | 7 -- services/nginx | 6 -- services/procfs.in | 9 --- services/sigkill.in | 6 -- services/sigterm.in | 9 --- services/sshd.in | 5 -- services/sshd_keygen.in | 14 ---- services/swclock.in | 6 -- services/swclocksave.gcron.in | 3 - services/swclocksave.in | 7 -- services/sync | 6 -- services/sysctl | 7 -- services/sysfs.in | 13 ---- services/sysinit | 5 -- services/tmpfs | 5 -- services/unbound | 6 -- services/usyslogd | 6 -- services/vfs | 4 -- 51 files changed, 8 insertions(+), 875 deletions(-) delete mode 100644 docs/defconfig.md delete mode 100644 docs/network.md delete mode 100644 netcfg/ifrename delete mode 100644 scripts/Makemodule.am delete mode 100644 scripts/devfs.sh.in delete mode 100755 scripts/ifcfg.sh.in delete mode 100644 scripts/ifdown.sh delete mode 100755 scripts/ifrename.sh.in delete mode 100644 scripts/modules_load.sh.in delete mode 100755 scripts/setntpdate.sh delete mode 100644 scripts/trymount.sh delete mode 100644 services/Makemodule.am delete mode 100644 services/agetty delete mode 100644 services/consolefont delete mode 100644 services/devfs.in delete mode 100644 services/dhcpcd delete mode 100644 services/dhcpcdmaster delete mode 100644 services/dnsmasq delete mode 100644 services/gcrond delete mode 100644 services/hostapd.in delete mode 100644 services/hostname delete mode 100644 services/hwclock delete mode 100644 services/ifcfg.in delete mode 100644 services/ifdown.in delete mode 100644 services/ifrename.in delete mode 100644 services/klogd delete mode 100644 services/loopback delete mode 100644 services/modules.in delete mode 100644 services/network delete mode 100644 services/nft.in delete mode 100644 services/nginx delete mode 100644 services/procfs.in delete mode 100644 services/sigkill.in delete mode 100644 services/sigterm.in delete mode 100644 services/sshd.in delete mode 100644 services/sshd_keygen.in delete mode 100644 services/swclock.in delete mode 100644 services/swclocksave.gcron.in delete mode 100644 services/swclocksave.in delete mode 100644 services/sync delete mode 100755 services/sysctl delete mode 100644 services/sysfs.in delete mode 100644 services/sysinit delete mode 100644 services/tmpfs delete mode 100644 services/unbound delete mode 100644 services/usyslogd delete mode 100644 services/vfs diff --git a/.gitignore b/.gitignore index 4a53b47..5eb592a 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Makefile.am b/Makefile.am index 19b79e8..f818627 100644 --- a/Makefile.am +++ b/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 diff --git a/README.md b/README.md index 305686c..2ddf025 100644 --- a/README.md +++ b/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. diff --git a/configure.ac b/configure.ac index 068940b..9e5f607 100644 --- a/configure.ac +++ b/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]) diff --git a/docs/defconfig.md b/docs/defconfig.md deleted file mode 100644 index 346e900..0000000 --- a/docs/defconfig.md +++ /dev/null @@ -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. diff --git a/docs/network.md b/docs/network.md deleted file mode 100644 index f111a8f..0000000 --- a/docs/network.md +++ /dev/null @@ -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 ` - * `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`. diff --git a/netcfg/ifrename b/netcfg/ifrename deleted file mode 100644 index 08909fa..0000000 --- a/netcfg/ifrename +++ /dev/null @@ -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" -# eth*,*,port diff --git a/scripts/Makemodule.am b/scripts/Makemodule.am deleted file mode 100644 index f29f5f9..0000000 --- a/scripts/Makemodule.am +++ /dev/null @@ -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 diff --git a/scripts/devfs.sh.in b/scripts/devfs.sh.in deleted file mode 100644 index af002f6..0000000 --- a/scripts/devfs.sh.in +++ /dev/null @@ -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" diff --git a/scripts/ifcfg.sh.in b/scripts/ifcfg.sh.in deleted file mode 100755 index 8f684e7..0000000 --- a/scripts/ifcfg.sh.in +++ /dev/null @@ -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 . -# -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/scripts/ifdown.sh b/scripts/ifdown.sh deleted file mode 100644 index 2e2b30e..0000000 --- a/scripts/ifdown.sh +++ /dev/null @@ -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 . -# -for IFPATH in /sys/class/net/*; do - [ "$IFPATH" == "/sys/class/net/lo" ] && continue - - IF=`basename $IFPATH` - - ip link set dev "$IF" down -done diff --git a/scripts/ifrename.sh.in b/scripts/ifrename.sh.in deleted file mode 100755 index fee5444..0000000 --- a/scripts/ifrename.sh.in +++ /dev/null @@ -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 . -# -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" diff --git a/scripts/modules_load.sh.in b/scripts/modules_load.sh.in deleted file mode 100644 index 518228c..0000000 --- a/scripts/modules_load.sh.in +++ /dev/null @@ -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 . -# -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" diff --git a/scripts/setntpdate.sh b/scripts/setntpdate.sh deleted file mode 100755 index c0ed1b4..0000000 --- a/scripts/setntpdate.sh +++ /dev/null @@ -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 . -# - -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 $? diff --git a/scripts/trymount.sh b/scripts/trymount.sh deleted file mode 100644 index 9be77f6..0000000 --- a/scripts/trymount.sh +++ /dev/null @@ -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 diff --git a/services/Makemodule.am b/services/Makemodule.am deleted file mode 100644 index 7aae6c2..0000000 --- a/services/Makemodule.am +++ /dev/null @@ -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 diff --git a/services/agetty b/services/agetty deleted file mode 100644 index 6c8945b..0000000 --- a/services/agetty +++ /dev/null @@ -1,6 +0,0 @@ -description agetty on %0 -exec agetty %0 linux -type respawn -target boot -after network -tty "/dev/%0" diff --git a/services/consolefont b/services/consolefont deleted file mode 100644 index 1584db9..0000000 --- a/services/consolefont +++ /dev/null @@ -1,6 +0,0 @@ -description set console font -type once -target boot -before sysinit -after vfs -exec setfont %0 diff --git a/services/devfs.in b/services/devfs.in deleted file mode 100644 index 271eae7..0000000 --- a/services/devfs.in +++ /dev/null @@ -1,6 +0,0 @@ -description "mount /dev" -type wait -target boot -after procfs sysfs -before vfs -exec "@SCRIPTDIR@/devfs.sh" diff --git a/services/dhcpcd b/services/dhcpcd deleted file mode 100644 index 184a843..0000000 --- a/services/dhcpcd +++ /dev/null @@ -1,7 +0,0 @@ -description "DHCP client on %0" -type once -target boot -after dhcpcdmaster network - -tty /dev/null -exec dhcpcd -n %0 diff --git a/services/dhcpcdmaster b/services/dhcpcdmaster deleted file mode 100644 index 879497a..0000000 --- a/services/dhcpcdmaster +++ /dev/null @@ -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 -} diff --git a/services/dnsmasq b/services/dnsmasq deleted file mode 100644 index 4045824..0000000 --- a/services/dnsmasq +++ /dev/null @@ -1,6 +0,0 @@ -description "dnsmasq DNS & DHCP server" -type respawn limit 5 -target boot -after network unbound - -exec dnsmasq -k diff --git a/services/gcrond b/services/gcrond deleted file mode 100644 index 0ee1ee5..0000000 --- a/services/gcrond +++ /dev/null @@ -1,5 +0,0 @@ -description start gcron daemon -exec gcrond -type respawn -target boot -after network diff --git a/services/hostapd.in b/services/hostapd.in deleted file mode 100644 index 172aa6f..0000000 --- a/services/hostapd.in +++ /dev/null @@ -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" diff --git a/services/hostname b/services/hostname deleted file mode 100644 index d0daa23..0000000 --- a/services/hostname +++ /dev/null @@ -1,6 +0,0 @@ -description reload hostname -exec hostname --file /etc/hostname -type wait -target boot -before sysinit -after hwclock vfs diff --git a/services/hwclock b/services/hwclock deleted file mode 100644 index 7eac1da..0000000 --- a/services/hwclock +++ /dev/null @@ -1,6 +0,0 @@ -description restore time from RTC -exec hwclock --hctosys --utc -type wait -target boot -before sysinit -after vfs modules diff --git a/services/ifcfg.in b/services/ifcfg.in deleted file mode 100644 index c2b4127..0000000 --- a/services/ifcfg.in +++ /dev/null @@ -1,7 +0,0 @@ -description "static network configuration" -type wait -target boot -after sysinit ifrename -before network - -exec "@SCRIPTDIR@/ifcfg.sh" \ No newline at end of file diff --git a/services/ifdown.in b/services/ifdown.in deleted file mode 100644 index 1310098..0000000 --- a/services/ifdown.in +++ /dev/null @@ -1,7 +0,0 @@ -description "stop all network interfaces" -type wait -target %0 -after sigkill sigterm -before sync - -exec "@SCRIPTDIR@/ifdown.sh" \ No newline at end of file diff --git a/services/ifrename.in b/services/ifrename.in deleted file mode 100644 index efb00de..0000000 --- a/services/ifrename.in +++ /dev/null @@ -1,7 +0,0 @@ -description "rename network interfaces" -type wait -target boot -after sysinit -before network - -exec "@SCRIPTDIR@/ifrename.sh" \ No newline at end of file diff --git a/services/klogd b/services/klogd deleted file mode 100644 index aaca59a..0000000 --- a/services/klogd +++ /dev/null @@ -1,6 +0,0 @@ -description "starting uklogd" -exec klogd -type respawn limit 5 -target boot -after usyslogd -before sysinit diff --git a/services/loopback b/services/loopback deleted file mode 100644 index 53118b5..0000000 --- a/services/loopback +++ /dev/null @@ -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 -} diff --git a/services/modules.in b/services/modules.in deleted file mode 100644 index e8c1863..0000000 --- a/services/modules.in +++ /dev/null @@ -1,7 +0,0 @@ -description "load kernel modules" -type wait -target boot -after vfs usyslogd -before sysinit - -exec "@SCRIPTDIR@/modules_load.sh" \ No newline at end of file diff --git a/services/network b/services/network deleted file mode 100644 index 5ba505c..0000000 --- a/services/network +++ /dev/null @@ -1,4 +0,0 @@ -description "static network configuration completed" -type wait -target boot -after sysinit \ No newline at end of file diff --git a/services/nft.in b/services/nft.in deleted file mode 100644 index 21caab0..0000000 --- a/services/nft.in +++ /dev/null @@ -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" diff --git a/services/nginx b/services/nginx deleted file mode 100644 index 6a36af9..0000000 --- a/services/nginx +++ /dev/null @@ -1,6 +0,0 @@ -description "start nginx web server" -type once -target boot -after network -tty /dev/null -exec nginx diff --git a/services/procfs.in b/services/procfs.in deleted file mode 100644 index 8c0743b..0000000 --- a/services/procfs.in +++ /dev/null @@ -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 -} diff --git a/services/sigkill.in b/services/sigkill.in deleted file mode 100644 index cddd49d..0000000 --- a/services/sigkill.in +++ /dev/null @@ -1,6 +0,0 @@ -description send SIGKILL to remaining processes -exec "@SCRIPTDIR@/killall5" 9 -type wait -target %0 -after sigterm -before sync shutdown reboot diff --git a/services/sigterm.in b/services/sigterm.in deleted file mode 100644 index 7e77fba..0000000 --- a/services/sigterm.in +++ /dev/null @@ -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 -} diff --git a/services/sshd.in b/services/sshd.in deleted file mode 100644 index a6292bc..0000000 --- a/services/sshd.in +++ /dev/null @@ -1,5 +0,0 @@ -description "OpenSSH server" -type respawn limit 5 -target boot -after network sshd_keygen -exec "@SBINPATH@/sshd" -D diff --git a/services/sshd_keygen.in b/services/sshd_keygen.in deleted file mode 100644 index 6425e63..0000000 --- a/services/sshd_keygen.in +++ /dev/null @@ -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 -} diff --git a/services/swclock.in b/services/swclock.in deleted file mode 100644 index 02c4c27..0000000 --- a/services/swclock.in +++ /dev/null @@ -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 diff --git a/services/swclocksave.gcron.in b/services/swclocksave.gcron.in deleted file mode 100644 index 24e162b..0000000 --- a/services/swclocksave.gcron.in +++ /dev/null @@ -1,3 +0,0 @@ -interval hourly -tty truncate @STATEFILESPATH@/swclock -exec date --utc +%%m%%d%%H%%M%%Y.%%S diff --git a/services/swclocksave.in b/services/swclocksave.in deleted file mode 100644 index 683ded7..0000000 --- a/services/swclocksave.in +++ /dev/null @@ -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 diff --git a/services/sync b/services/sync deleted file mode 100644 index d7217f9..0000000 --- a/services/sync +++ /dev/null @@ -1,6 +0,0 @@ -description sync -exec sync -type wait -target %0 -after sigkill sigterm -before reboot shutdown diff --git a/services/sysctl b/services/sysctl deleted file mode 100755 index 6664297..0000000 --- a/services/sysctl +++ /dev/null @@ -1,7 +0,0 @@ -description configure kernel paramters -tty /dev/null -exec sysctl --system -type wait -target boot -before sysinit -after vfs loopback diff --git a/services/sysfs.in b/services/sysfs.in deleted file mode 100644 index 8eebd0a..0000000 --- a/services/sysfs.in +++ /dev/null @@ -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 -} diff --git a/services/sysinit b/services/sysinit deleted file mode 100644 index 801ac97..0000000 --- a/services/sysinit +++ /dev/null @@ -1,5 +0,0 @@ -description basic system initialization -type wait -target boot -after vfs -before network \ No newline at end of file diff --git a/services/tmpfs b/services/tmpfs deleted file mode 100644 index 411a42b..0000000 --- a/services/tmpfs +++ /dev/null @@ -1,5 +0,0 @@ -description "mount /tmp" -type wait -target boot -before vfs -exec mount -t tmpfs none /tmp diff --git a/services/unbound b/services/unbound deleted file mode 100644 index e9980ab..0000000 --- a/services/unbound +++ /dev/null @@ -1,6 +0,0 @@ -description "Unbound resolver" -type respawn limit 5 -target boot -after network - -exec unbound -d diff --git a/services/usyslogd b/services/usyslogd deleted file mode 100644 index 6b378d9..0000000 --- a/services/usyslogd +++ /dev/null @@ -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 \ No newline at end of file diff --git a/services/vfs b/services/vfs deleted file mode 100644 index b699976..0000000 --- a/services/vfs +++ /dev/null @@ -1,4 +0,0 @@ -description VFS setup done -type wait -target boot -before sysinit \ No newline at end of file