From b02e98ad03bfdf37cb17b56034168d4ad8638823 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Wed, 7 Feb 2024 18:41:32 +0100 Subject: fix init system --- rootfs/etc/deinit.d/90_network | 3 --- rootfs/etc/deinit.d/99_mounts | 3 --- rootfs/etc/deinitrc | 2 -- rootfs/etc/init.d/00_mounts | 3 --- rootfs/etc/init.d/10_hostname | 3 --- rootfs/etc/init.d/10_network | 3 --- rootfs/etc/initrc | 3 --- rootfs/etc/inittab | 6 +++--- rootfs/etc/runit/1 | 20 ++++++++++++++++++++ rootfs/etc/runit/2 | 2 ++ rootfs/etc/runit/3 | 6 ++++++ rootfs/etc/sv/httpd | 2 -- rootfs/etc/sv/ifplugd | 3 --- rootfs/etc/sv/syslog | 2 -- rootfs/var/service/httpd/run | 2 ++ rootfs/var/service/ifplugd/run | 3 +++ 16 files changed, 36 insertions(+), 30 deletions(-) delete mode 100644 rootfs/etc/deinit.d/90_network delete mode 100644 rootfs/etc/deinit.d/99_mounts delete mode 100755 rootfs/etc/deinitrc delete mode 100644 rootfs/etc/init.d/00_mounts delete mode 100644 rootfs/etc/init.d/10_hostname delete mode 100644 rootfs/etc/init.d/10_network delete mode 100755 rootfs/etc/initrc create mode 100755 rootfs/etc/runit/1 create mode 100755 rootfs/etc/runit/2 create mode 100755 rootfs/etc/runit/3 delete mode 100755 rootfs/etc/sv/httpd delete mode 100755 rootfs/etc/sv/ifplugd delete mode 100755 rootfs/etc/sv/syslog create mode 100755 rootfs/var/service/httpd/run create mode 100755 rootfs/var/service/ifplugd/run diff --git a/rootfs/etc/deinit.d/90_network b/rootfs/etc/deinit.d/90_network deleted file mode 100644 index 106e6b7..0000000 --- a/rootfs/etc/deinit.d/90_network +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# disable all network interfaces -ifdown -a diff --git a/rootfs/etc/deinit.d/99_mounts b/rootfs/etc/deinit.d/99_mounts deleted file mode 100644 index 359d592..0000000 --- a/rootfs/etc/deinit.d/99_mounts +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# unmount all drives -umount -a -r diff --git a/rootfs/etc/deinitrc b/rootfs/etc/deinitrc deleted file mode 100755 index e681930..0000000 --- a/rootfs/etc/deinitrc +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -for f in /etc/deinit.d/* ; do . "$f" ; done diff --git a/rootfs/etc/init.d/00_mounts b/rootfs/etc/init.d/00_mounts deleted file mode 100644 index 804880c..0000000 --- a/rootfs/etc/init.d/00_mounts +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# mount all drives in /etc/fstab -mount -a diff --git a/rootfs/etc/init.d/10_hostname b/rootfs/etc/init.d/10_hostname deleted file mode 100644 index 064cea2..0000000 --- a/rootfs/etc/init.d/10_hostname +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# update hostname -hostname -F /etc/hostname diff --git a/rootfs/etc/init.d/10_network b/rootfs/etc/init.d/10_network deleted file mode 100644 index 03dc3f8..0000000 --- a/rootfs/etc/init.d/10_network +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# up all network interfaces -ifup -a -f diff --git a/rootfs/etc/initrc b/rootfs/etc/initrc deleted file mode 100755 index a3291fd..0000000 --- a/rootfs/etc/initrc +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -for f in /etc/init.d/* ; do . "$f" ; done - diff --git a/rootfs/etc/inittab b/rootfs/etc/inittab index ffc4115..930ae6c 100644 --- a/rootfs/etc/inittab +++ b/rootfs/etc/inittab @@ -1,7 +1,7 @@ # /etc/inittab init(8) - -::sysinit:/etc/initrc -::shutdown:/etc/deinitrc +# there is no 'real' runit, only busybox init +::sysinit:/etc/runit/1 +::shutdown:/etc/runit/3 ::restart:/sbin/init diff --git a/rootfs/etc/runit/1 b/rootfs/etc/runit/1 new file mode 100755 index 0000000..f693a41 --- /dev/null +++ b/rootfs/etc/runit/1 @@ -0,0 +1,20 @@ +#!/bin/sh +# mount all drives in /etc/fstab +mount -a + +# clear run folder +rm -rf /var/run +mkdir -p /var/run + +# update hostname +hostname -F /etc/hostname + +# up all network interfaces +ifup -a -f + +# start system log +syslogd + +# go to stage 2 (normally runit (/sbin/init) does this by itself, but this is +# using busybox's weird init system) +(setsid /etc/runit/2 1> /dev/null 2> /dev/null &) diff --git a/rootfs/etc/runit/2 b/rootfs/etc/runit/2 new file mode 100755 index 0000000..6a6d609 --- /dev/null +++ b/rootfs/etc/runit/2 @@ -0,0 +1,2 @@ +#!/bin/sh +runsvdir -P /var/service diff --git a/rootfs/etc/runit/3 b/rootfs/etc/runit/3 new file mode 100755 index 0000000..8a0018d --- /dev/null +++ b/rootfs/etc/runit/3 @@ -0,0 +1,6 @@ +#!/bin/sh +# disable all network interfaces +ifdown -a + +# unmount all drives +umount -a -r diff --git a/rootfs/etc/sv/httpd b/rootfs/etc/sv/httpd deleted file mode 100755 index 477041c..0000000 --- a/rootfs/etc/sv/httpd +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec httpd -f diff --git a/rootfs/etc/sv/ifplugd b/rootfs/etc/sv/ifplugd deleted file mode 100755 index cef959a..0000000 --- a/rootfs/etc/sv/ifplugd +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# automatically link hot-plugged ethernet connections -exec ifplugd -n diff --git a/rootfs/etc/sv/syslog b/rootfs/etc/sv/syslog deleted file mode 100755 index cdcfeaf..0000000 --- a/rootfs/etc/sv/syslog +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec syslogd -n diff --git a/rootfs/var/service/httpd/run b/rootfs/var/service/httpd/run new file mode 100755 index 0000000..477041c --- /dev/null +++ b/rootfs/var/service/httpd/run @@ -0,0 +1,2 @@ +#!/bin/sh +exec httpd -f diff --git a/rootfs/var/service/ifplugd/run b/rootfs/var/service/ifplugd/run new file mode 100755 index 0000000..cef959a --- /dev/null +++ b/rootfs/var/service/ifplugd/run @@ -0,0 +1,3 @@ +#!/bin/sh +# automatically link hot-plugged ethernet connections +exec ifplugd -n -- cgit v1.2.3