lfs-execline-scripts

Repository for execline scripts used in my linux-from-scratch builds
Log | Files | Refs

commit ba5fb52b2ace9c9ab000987f5d12d5cbf50f579b
parent 4c75bb198a1e37c6bdad34684c9817b830b6d134
Author: mrgrouse <mrgrouse@usbos.my.domain>
Date:   Sun,  3 Aug 2025 01:18:11 -0400

Create startup oneshot services for hwclock, basic network (unfinished), dhcp amd smdev.

Diffstat:
Asvc/services/hwclock | 19+++++++++++++++++++
Asvc/services/hwclock.conf | 8++++++++
Asvc/services/network | 29+++++++++++++++++++++++++++++
Asvc/services/network.conf | 13+++++++++++++
Asvc/services/sdhcp | 16++++++++++++++++
Asvc/services/smdev | 16++++++++++++++++
6 files changed, 101 insertions(+), 0 deletions(-)

diff --git a/svc/services/hwclock b/svc/services/hwclock @@ -0,0 +1,19 @@ +#!/home/mrgrouse/.local/src/static-linux-binaries/skarnet/execline/execlineb -S1 +# Use execlineb -WS1 for debug/testing (errors out on bad syntax) + +# set PID to pid of running process (may (not) exist) +#backtick PID { pidof -o %PPID $bins } + +envfile /etc/svc.d/default/hwclock + +case -N -- $1 + { + "-s" { + foreground { printf "Setting system clock..." } + foreground { hwclock $HWCLOCK_UP /dev/rtc0 } + } + "-k" { + foreground { printf "Saving system clock..." } + foreground { hwclock $HWCLOCK_DOWN /dev/rtc0 } + } + } { foreground { /bin/printf "usage: %s -s|-k\n" $0 } exit 1 } diff --git a/svc/services/hwclock.conf b/svc/services/hwclock.conf @@ -0,0 +1,7 @@ +# hwclock svc service config file + +# set system clock from hardware +HWCLOCK_UP=-s + +# save the system clock to the hardware +HWCLOCK_DOWN=-w +\ No newline at end of file diff --git a/svc/services/network b/svc/services/network @@ -0,0 +1,29 @@ +#!/home/mrgrouse/.local/src/static-linux-binaries/skarnet/execline/execlineb -S1 +# Use execlineb -WS1 for debug/testing (errors out on bad syntax) + +# set PID to pid of running process (may (not) exist) +#backtick PID { pidof -o %PPID $bins } +envfile /etc/svc.d/default/network + +case -N -- $1 + { + "-s" { + # iproute2/busybox (ewww!) + ip addr add 127.0.0.1/8 dev lo broadcast + scope host + ip link set lo up + + # ifconfig (net-tools) (yay!) + #ifconfig lo up 127.0.0.1/8 + #ifconfig $DEV1 mtu $DEV1_MTU + #route add default gw $GW_ADDY $DEV1 + } + "-k" { + # iproute2/busybox (ewww!) + ip link set lo down + ip link set $DEV1 down + + # ifconfig (net-tools) (yay!) + #ifconfig lo down + #ifconfig $DEV1 down + } + } { foreground { /bin/printf "usage: %s -s|-k\n" $0 } exit 1 } diff --git a/svc/services/network.conf b/svc/services/network.conf @@ -0,0 +1,13 @@ +#!/home/mrgrouse/.local/src/static-linux-binaries/skarnet/execline/execlineb -S1 +# our main network device +#DEV1=eth0 +DEV1=wlan0 + +# Our device's mtu (only needed if using net-tools) +#DEV1_MTU=1000 + +# Our device's gateway (TODO: find this var via sdhcp) +#GW_ADDY=10.0.0.1 + +# Arguments for the sdhcp command (-d flag will stop it from editing /etc/resolv.conf) (see sdhcp man page) +SDHCP_ARGS=-d diff --git a/svc/services/sdhcp b/svc/services/sdhcp @@ -0,0 +1,16 @@ +#!/home/mrgrouse/.local/src/static-linux-binaries/skarnet/execline/execlineb -S1 +# Use execlineb -WS1 for testing/debugging (errors out on bad syntax) + +envfile /etc/svc.d/default/network + +case -N -- $1 + { + "-s" { + background { printf "Getting DHCP Address on %s...\n" $DEV1 } + foreground { sdhcp $SDHCP_ARGS -ef $DEV1 } + } + "-k" { + # svc -k network + exit 0 + } + } { foreground { /bin/printf "usage: %s -s|-k\n" $0 } exit 1 } diff --git a/svc/services/smdev b/svc/services/smdev @@ -0,0 +1,16 @@ +#!/home/mrgrouse/.local/src/static-linux-binaries/skarnet/execline/execlineb -S1 +# Use execlineb -WS1 for debug/testing (errors out on bad syntax) + +case -N -- $1 + { + "-s" { + background { printf "Populating /dev with smdev...\n" + foreground { smdev -s } + background { printf "Registering smdev as kernel hotplug manager...\n" } + redirfd -w 1 /proc/sys/kernel/hotplug { printf "/sbin/smdev" } + } + "-k" { + background { printf "Removing kernel hotplug manager...\n" } + redirfd -w 1 /proc/sys/kernel/hotplug { printf "\0" } + } + } { foreground { /bin/printf "usage: %s -s|-k\n" $0 } exit 1 }