commit dc577f86e7e9218ac662f99072fc6cb6501570b6
parent 093090c663d664ae6e05bfbb75ee364ed2a5f570
Author: Jan Pobrislo <ccx@webprojekty.cz>
Date: Thu, 28 Jul 2022 02:19:21 +0200
Static IP configuration
Diffstat:
M | config.aat | | | 5 | +++++ |
M | s6-rc.aat | | | 89 | +++++++++++++++++++++++++++++++++++++++++++++---------------------------------- |
M | s6-rc.fileset | | | 84 | +++++++++++++++++++++++++++++++++++++++++++------------------------------------ |
3 files changed, 102 insertions(+), 76 deletions(-)
diff --git a/config.aat b/config.aat
@@ -7,4 +7,9 @@ tty_max=12
# Number of gettys to spawn (should be less 9 to not overlap with rescue getty)
getty_max=8
+
+static_ip=[
+iface ip cidr
+|#lo 127.0.0.1 8
+eth0 192.168.16.23 24
|}
diff --git a/s6-rc.aat b/s6-rc.aat
@@ -23,9 +23,10 @@ m644
/net-all d m755
/net-all/type cN bundle m644
/net-all/contents
-CN dhcpcd
- unbound
+CN unbound
loopback
+|# dhcpcd
+ net-eth0-static
m644
/ok-mount d m755
@@ -35,6 +36,26 @@ CN ok-sysinit
ok-localmount
m644
+|### Networking ###
+/loopback d m755
+/loopback/type cN oneshot m644
+/loopback/up
+CN if { ip link set lo up }
+ if -nt { ip addr add 127.0.0.1/8 dev lo brd + }
+ pipeline { ip addr show dev lo } grep -q "inet 127\\.0\\.0\\.1"
+m755
+
+@for i in static_ip
+|grep_re = <i.ip>
+/net-{<i.iface>}-static d m755
+/net-{<i.iface>}-static/type cN oneshot m644
+/net-{<i.iface>}-static/up
+CN if { ip link set {<i.iface>} up }
+ if -nt { ip addr add {<i.ip>}/{<i.cidr>} dev {<i.iface>} brd + }
+ pipeline { ip addr show dev {<i.iface>} } grep -qF 'inet {<i.ip>}/'
+m755
+@endfor
+
/dhcpcd d m755
/dhcpcd/type cN longrun m644
/dhcpcd/dependencies
@@ -57,12 +78,26 @@ CN #!/command/execlineb -P
dhcpcd --nobackground
m755
-/dmesg d m755
-/dmesg/type cN oneshot m644
-/dmesg/up
-CN # description="Set the dmesg level for a cleaner boot"
- # dmesg_level=1
- dmesg -n1
+/unbound d m755
+/unbound/type cN longrun m644
+/unbound/dependencies
+CN loopback
+ ok-mount
+ ok-sysinit
+m644
+/unbound/run
+CN #!/command/execlineb -P
+ getpid SERVICE_PID
+ foreground {
+ importas -i SERVICE_PID SERVICE_PID
+ if { test -d /run/cgroup2 }
+ if { mkdir -p /run/cgroup2/s6-rc/unbound }
+ redirfd -w 1 /run/cgroup2/s6-rc/unbound/cgroup.procs
+ printf "%s" ${SERVICE_PID}
+ }
+ unexport SERVICE_PID
+
+ unbound -d
m755
/hostname d m755
@@ -142,6 +177,14 @@ m644
|#/setfont-tty4/up cN redirfd -r 0 /dev/tty4 setfont ter-v14n m644
|#/setfont/type cN bundle m644
+/dmesg d m755
+/dmesg/type cN oneshot m644
+/dmesg/up
+CN # description="Set the dmesg level for a cleaner boot"
+ # dmesg_level=1
+ dmesg -n1
+m755
+
/modules d m755
/modules/dependencies cN dmesg m644
/modules/type cN oneshot m644
@@ -155,14 +198,6 @@ CN foreground { modprobe fuse }
foreground { modprobe virtio_net }
m755
-/loopback d m755
-/loopback/type cN oneshot m644
-/loopback/up
-CN if { ip link set lo up }
- if -nt { ip addr add 127.0.0.1/8 dev lo brd + }
- pipeline { ip addr show dev lo } grep -q "inet 127\\.0\\.0\\.1"
-m755
-
/openrc d m755
/openrc/type cN oneshot m644
/openrc/dependencies
@@ -231,26 +266,4 @@ m644
/swap/type cN oneshot m644
/swap/up cN swapon -a m644
/swap/down cN swapoff -a m644
-
-/unbound d m755
-/unbound/type cN longrun m644
-/unbound/dependencies
-CN loopback
- ok-mount
- ok-sysinit
-m644
-/unbound/run
-CN #!/command/execlineb -P
- getpid SERVICE_PID
- foreground {
- importas -i SERVICE_PID SERVICE_PID
- if { test -d /run/cgroup2 }
- if { mkdir -p /run/cgroup2/s6-rc/unbound }
- redirfd -w 1 /run/cgroup2/s6-rc/unbound/cgroup.procs
- printf "%s" ${SERVICE_PID}
- }
- unexport SERVICE_PID
-
- unbound -d
-m755
|}
diff --git a/s6-rc.fileset b/s6-rc.fileset
@@ -133,9 +133,9 @@ m644
/net-all d m755
/net-all/type cN bundle m644
/net-all/contents
-CN dhcpcd
- unbound
+CN unbound
loopback
+ net-eth0-static
m644
/ok-mount d m755
@@ -145,6 +145,22 @@ CN ok-sysinit
ok-localmount
m644
+/loopback d m755
+/loopback/type cN oneshot m644
+/loopback/up
+CN if { ip link set lo up }
+ if -nt { ip addr add 127.0.0.1/8 dev lo brd + }
+ pipeline { ip addr show dev lo } grep -q "inet 127\\.0\\.0\\.1"
+m755
+
+/net-eth0-static d m755
+/net-eth0-static/type cN oneshot m644
+/net-eth0-static/up
+CN if { ip link set eth0 up }
+ if -nt { ip addr add 192.168.16.23/24 dev eth0 brd + }
+ pipeline { ip addr show dev eth0 } grep -qF 'inet 192.168.16.23/'
+m755
+
/dhcpcd d m755
/dhcpcd/type cN longrun m644
/dhcpcd/dependencies
@@ -167,12 +183,26 @@ CN #!/command/execlineb -P
dhcpcd --nobackground
m755
-/dmesg d m755
-/dmesg/type cN oneshot m644
-/dmesg/up
-CN # description="Set the dmesg level for a cleaner boot"
- # dmesg_level=1
- dmesg -n1
+/unbound d m755
+/unbound/type cN longrun m644
+/unbound/dependencies
+CN loopback
+ ok-mount
+ ok-sysinit
+m644
+/unbound/run
+CN #!/command/execlineb -P
+ getpid SERVICE_PID
+ foreground {
+ importas -i SERVICE_PID SERVICE_PID
+ if { test -d /run/cgroup2 }
+ if { mkdir -p /run/cgroup2/s6-rc/unbound }
+ redirfd -w 1 /run/cgroup2/s6-rc/unbound/cgroup.procs
+ printf "%s" ${SERVICE_PID}
+ }
+ unexport SERVICE_PID
+
+ unbound -d
m755
/hostname d m755
@@ -398,6 +428,14 @@ m644
/kbd_mode-tty12/up cN kbd_mode -u -C /dev/tty12 m644
+/dmesg d m755
+/dmesg/type cN oneshot m644
+/dmesg/up
+CN # description="Set the dmesg level for a cleaner boot"
+ # dmesg_level=1
+ dmesg -n1
+m755
+
/modules d m755
/modules/dependencies cN dmesg m644
/modules/type cN oneshot m644
@@ -411,14 +449,6 @@ CN foreground { modprobe fuse }
foreground { modprobe virtio_net }
m755
-/loopback d m755
-/loopback/type cN oneshot m644
-/loopback/up
-CN if { ip link set lo up }
- if -nt { ip addr add 127.0.0.1/8 dev lo brd + }
- pipeline { ip addr show dev lo } grep -q "inet 127\\.0\\.0\\.1"
-m755
-
/openrc d m755
/openrc/type cN oneshot m644
/openrc/dependencies
@@ -487,25 +517,3 @@ m644
/swap/type cN oneshot m644
/swap/up cN swapon -a m644
/swap/down cN swapoff -a m644
-
-/unbound d m755
-/unbound/type cN longrun m644
-/unbound/dependencies
-CN loopback
- ok-mount
- ok-sysinit
-m644
-/unbound/run
-CN #!/command/execlineb -P
- getpid SERVICE_PID
- foreground {
- importas -i SERVICE_PID SERVICE_PID
- if { test -d /run/cgroup2 }
- if { mkdir -p /run/cgroup2/s6-rc/unbound }
- redirfd -w 1 /run/cgroup2/s6-rc/unbound/cgroup.procs
- printf "%s" ${SERVICE_PID}
- }
- unexport SERVICE_PID
-
- unbound -d
-m755