From b9dfdaaa1ae0148dd8a3e78508c636636e7396a6 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Wed, 7 Feb 2024 16:15:21 +0100 Subject: web server done --- rootfs/etc/deinit.d/90_network | 3 +++ rootfs/etc/deinit.d/99_mounts | 3 +++ rootfs/etc/deinitrc | 2 ++ rootfs/etc/httpd.conf | 2 ++ rootfs/etc/ifplugd/ifplugd.action | 3 ++- rootfs/etc/init.d/00_mounts | 3 +++ rootfs/etc/init.d/10_hostname | 3 +++ rootfs/etc/init.d/10_network | 3 +++ rootfs/etc/init.d/rcS | 9 --------- rootfs/etc/initrc | 3 +++ rootfs/etc/inittab | 6 ++++-- rootfs/etc/network/interfaces | 8 ++++---- rootfs/etc/network/interfaces.d/eth0 | 2 ++ rootfs/etc/network/interfaces.d/lo | 2 ++ rootfs/etc/sv/httpd | 2 ++ rootfs/etc/sv/ifplugd | 3 +++ rootfs/etc/sv/syslog | 2 ++ 17 files changed, 43 insertions(+), 16 deletions(-) create mode 100644 rootfs/etc/deinit.d/90_network create mode 100644 rootfs/etc/deinit.d/99_mounts create mode 100755 rootfs/etc/deinitrc create mode 100644 rootfs/etc/init.d/00_mounts create mode 100644 rootfs/etc/init.d/10_hostname create mode 100644 rootfs/etc/init.d/10_network delete mode 100755 rootfs/etc/init.d/rcS create mode 100755 rootfs/etc/initrc create mode 100644 rootfs/etc/network/interfaces.d/eth0 create mode 100644 rootfs/etc/network/interfaces.d/lo create mode 100755 rootfs/etc/sv/httpd create mode 100755 rootfs/etc/sv/ifplugd create mode 100755 rootfs/etc/sv/syslog (limited to 'rootfs/etc') diff --git a/rootfs/etc/deinit.d/90_network b/rootfs/etc/deinit.d/90_network new file mode 100644 index 0000000..106e6b7 --- /dev/null +++ b/rootfs/etc/deinit.d/90_network @@ -0,0 +1,3 @@ +#!/bin/sh +# disable all network interfaces +ifdown -a diff --git a/rootfs/etc/deinit.d/99_mounts b/rootfs/etc/deinit.d/99_mounts new file mode 100644 index 0000000..359d592 --- /dev/null +++ b/rootfs/etc/deinit.d/99_mounts @@ -0,0 +1,3 @@ +#!/bin/sh +# unmount all drives +umount -a -r diff --git a/rootfs/etc/deinitrc b/rootfs/etc/deinitrc new file mode 100755 index 0000000..e681930 --- /dev/null +++ b/rootfs/etc/deinitrc @@ -0,0 +1,2 @@ +#!/bin/sh +for f in /etc/deinit.d/* ; do . "$f" ; done diff --git a/rootfs/etc/httpd.conf b/rootfs/etc/httpd.conf index 2881728..f04b54c 100644 --- a/rootfs/etc/httpd.conf +++ b/rootfs/etc/httpd.conf @@ -1,2 +1,4 @@ H:/srv/http I:index.html +P:/on:http://localhost/cgi-bin/on +P:/off:http://localhost/cgi-bin/off diff --git a/rootfs/etc/ifplugd/ifplugd.action b/rootfs/etc/ifplugd/ifplugd.action index e5b35ec..e0e59ef 100755 --- a/rootfs/etc/ifplugd/ifplugd.action +++ b/rootfs/etc/ifplugd/ifplugd.action @@ -5,5 +5,6 @@ NEW_STATE="$2" test -n "$INTERFACE" test -n "$NEW_STATE" -exec ip link set "$INTERFACE" "$NEW_STATE" +[ "$NEW_STATE" = "up" ] && exec ifup "$INTERFACE" +[ "$NEW_STATE" = "down" ] && exec ifdown "$INTERFACE" diff --git a/rootfs/etc/init.d/00_mounts b/rootfs/etc/init.d/00_mounts new file mode 100644 index 0000000..804880c --- /dev/null +++ b/rootfs/etc/init.d/00_mounts @@ -0,0 +1,3 @@ +#!/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 new file mode 100644 index 0000000..064cea2 --- /dev/null +++ b/rootfs/etc/init.d/10_hostname @@ -0,0 +1,3 @@ +#!/bin/sh +# update hostname +hostname -F /etc/hostname diff --git a/rootfs/etc/init.d/10_network b/rootfs/etc/init.d/10_network new file mode 100644 index 0000000..03dc3f8 --- /dev/null +++ b/rootfs/etc/init.d/10_network @@ -0,0 +1,3 @@ +#!/bin/sh +# up all network interfaces +ifup -a -f diff --git a/rootfs/etc/init.d/rcS b/rootfs/etc/init.d/rcS deleted file mode 100755 index b819ce4..0000000 --- a/rootfs/etc/init.d/rcS +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# core -mount -a # mount all drives in /etc/fstab -hostname -F /etc/hostname # update hostname - -# system services -syslogd # system log -ifplugd # automatically link hot-plugged ethernet connections - diff --git a/rootfs/etc/initrc b/rootfs/etc/initrc new file mode 100755 index 0000000..a3291fd --- /dev/null +++ b/rootfs/etc/initrc @@ -0,0 +1,3 @@ +#!/bin/sh +for f in /etc/init.d/* ; do . "$f" ; done + diff --git a/rootfs/etc/inittab b/rootfs/etc/inittab index 3f0c41a..ffc4115 100644 --- a/rootfs/etc/inittab +++ b/rootfs/etc/inittab @@ -1,6 +1,8 @@ # /etc/inittab init(8) -::sysinit:/etc/init.d/rcS -::shutdown:/bin/umount -a -r + +::sysinit:/etc/initrc +::shutdown:/etc/deinitrc + ::restart:/sbin/init # put a shell on ttyS0 (serial header on board) diff --git a/rootfs/etc/network/interfaces b/rootfs/etc/network/interfaces index 5307bb0..644f5f0 100644 --- a/rootfs/etc/network/interfaces +++ b/rootfs/etc/network/interfaces @@ -1,6 +1,6 @@ # interfaces(5) configuration -auto eth0 -iface eth0 inet dhcp +source /etc/network/interfaces.d/lo +source /etc/network/interfaces.d/eth0 -auto lo -iface lo inet loopback +# NOTE: this should work but doesn't: +# source /etc/network/interfaces.d/* diff --git a/rootfs/etc/network/interfaces.d/eth0 b/rootfs/etc/network/interfaces.d/eth0 new file mode 100644 index 0000000..81922ce --- /dev/null +++ b/rootfs/etc/network/interfaces.d/eth0 @@ -0,0 +1,2 @@ +auto eth0 +iface eth0 inet dhcp diff --git a/rootfs/etc/network/interfaces.d/lo b/rootfs/etc/network/interfaces.d/lo new file mode 100644 index 0000000..f1bd92e --- /dev/null +++ b/rootfs/etc/network/interfaces.d/lo @@ -0,0 +1,2 @@ +auto lo +iface lo inet loopback diff --git a/rootfs/etc/sv/httpd b/rootfs/etc/sv/httpd new file mode 100755 index 0000000..477041c --- /dev/null +++ b/rootfs/etc/sv/httpd @@ -0,0 +1,2 @@ +#!/bin/sh +exec httpd -f diff --git a/rootfs/etc/sv/ifplugd b/rootfs/etc/sv/ifplugd new file mode 100755 index 0000000..cef959a --- /dev/null +++ b/rootfs/etc/sv/ifplugd @@ -0,0 +1,3 @@ +#!/bin/sh +# automatically link hot-plugged ethernet connections +exec ifplugd -n diff --git a/rootfs/etc/sv/syslog b/rootfs/etc/sv/syslog new file mode 100755 index 0000000..cdcfeaf --- /dev/null +++ b/rootfs/etc/sv/syslog @@ -0,0 +1,2 @@ +#!/bin/sh +exec syslogd -n -- cgit v1.2.3