lfs-execline-scripts

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

commit 4266f9b32cac71ba120553c2e8f9f275cb5c9ea6
parent ae31bfb40875e55c736f0cf962f9f0b8e73fba2a
Author: mrgrouse <bdmfegys@duck.com>
Date:   Mon, 21 Jul 2025 00:43:10 -0400

create svc directory, create bare.sh execline script to replace svc's shell version

Diffstat:
Asvc/bare.sh | 38++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+), 0 deletions(-)

diff --git a/svc/bare.sh b/svc/bare.sh @@ -0,0 +1,38 @@ +#!/bin/execlineb -S1 +# do execlineb -WS1 for testing (errors out on bad syntax) +if { eltest "$#" = 0 } foreground + { + define SERVICE "$0" + shift -n 1 + } + +# we may need to change this bc said file may ned to run some code +# we can put maybe EXTSCRIPTS=1 in said config if it needs to run an external script, which we can +# then check for and tghen run said script +if { eltest -e "/bin/svc.d/default/${SERVICE}" } + { + envfile { "/bin/svc.d/default/${SERVICE}" } + } +define BIN "" +# loop thru std $PATH +forx i { /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin } +{ + #if ex: /bin/$SERVICE is executable + if { eltest -x ${i}/${SERVICE} } + { + # set BIN to path of executable + define BIN ${i}/${SERVICE} + } +} + +if { eltest -v BIN } exit 1 + +# set PID to pid of running process (may (not) exist) +backtick PID { pidof -o %PPID $BIN } + +case -N -- $1 + { + "-s" { if { eltest -v PID } { exec $BIN $PARAMS } } # if $PID is empty, run $BIN $PARAMS + "-k" { if { eltest ! -v PID } kill -9 $PID } # if $PID isn't empty, run kill -9 $PID &>/dev/null + "*" { foreground { printf "usage: %s -s|-k\n" $0 } exit 1 } # FIXME globs probably don't work in this case, fix for execline + }