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 ++ rootfs/srv/http/cgi-bin/off | 2 ++ rootfs/srv/http/cgi-bin/on | 2 ++ rootfs/srv/http/index.html | 21 ++++++++++++++------- rootfs/srv/http/off | 2 -- rootfs/srv/http/on | 2 -- 22 files changed, 61 insertions(+), 27 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 create mode 100755 rootfs/srv/http/cgi-bin/off create mode 100755 rootfs/srv/http/cgi-bin/on delete mode 100755 rootfs/srv/http/off delete mode 100755 rootfs/srv/http/on (limited to 'rootfs') 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 diff --git a/rootfs/srv/http/cgi-bin/off b/rootfs/srv/http/cgi-bin/off new file mode 100755 index 0000000..e70be2d --- /dev/null +++ b/rootfs/srv/http/cgi-bin/off @@ -0,0 +1,2 @@ +#!/bin/sh +leds 0 diff --git a/rootfs/srv/http/cgi-bin/on b/rootfs/srv/http/cgi-bin/on new file mode 100755 index 0000000..0da06b0 --- /dev/null +++ b/rootfs/srv/http/cgi-bin/on @@ -0,0 +1,2 @@ +#!/bin/sh +leds 1 diff --git a/rootfs/srv/http/index.html b/rootfs/srv/http/index.html index f60b829..0812323 100644 --- a/rootfs/srv/http/index.html +++ b/rootfs/srv/http/index.html @@ -1,10 +1,17 @@ - - - Hello world! - - -

Turn leds on or off

- + + + Hello world! + + + + + + Turn leds +
+ or +
+ + diff --git a/rootfs/srv/http/off b/rootfs/srv/http/off deleted file mode 100755 index e70be2d..0000000 --- a/rootfs/srv/http/off +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -leds 0 diff --git a/rootfs/srv/http/on b/rootfs/srv/http/on deleted file mode 100755 index 0da06b0..0000000 --- a/rootfs/srv/http/on +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -leds 1 -- cgit v1.2.3