commit 26f46f246d479b6e69558f686ea2e845d147fc20 parent 0795cf8daa8aadebec00a6595df7dcdb7fdf5212 Author: mrgrouse <bdmfegys@duck.com> Date: Sun, 27 Jul 2025 21:08:59 -0400 switch SERVICE variable to $0 variable Diffstat:
| M | svc/bare.sh | | | 49 | +++++++++++++++++++++++++------------------------ |
1 file changed, 25 insertions(+), 24 deletions(-)
diff --git a/svc/bare.sh b/svc/bare.sh @@ -1,41 +1,42 @@ -#!/usr/bin/execlineb -S1 +#!/home/mrgrouse/.local/src/static-linux-binaries/skarnet/execline/execlineb -S1 # do execlineb -WS1 for testing (errors out on bad syntax) -foreground { - if { eltest "$#" = 0 } foreground - { - define SERVICE "$0" - shift -n 1 - } -} +# this was an attempt to define SERVICE as the same as argv[0] but didn't work for some reason +#foreground { +# if { eltest "$#" = 0 } +# 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 foreground { - if { eltest -e "/bin/svc.d/default/${SERVICE}" } - { envfile { "/bin/svc.d/default/${SERVICE}" } } + if { eltest -e "/etc/svc.d/default/${0}" } + { envfile { "/etc/svc.d/default/${0}" } } } -define BIN "" + +define bins "" + # 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} } +forx i { "/bin" "/sbin" "/usr/bin" "/usr/sbin" "/usr/local/bin" "/usr/local/sbin" } + #importas -S PATH + #if ex: /bin/$0 is executable + if { eltest -x "${i}/${0}" } { - # set BIN to path of executable - define BIN ${i}/${SERVICE} + # set bins to path of executable + define bins ${i}/${0} } -} + #exit 1111 # exit forx loop foreground { - if { eltest -v BIN } - { exit 1 } -} + if { eltest -v bins } + exit 1 +} # foregroudn wrapper # set PID to pid of running process (may (not) exist) -backtick PID { pidof -o %PPID $BIN } +backtick PID { pidof -o %PPID $bins } case -N -- $1 { - "-s" { if { eltest -v PID } { exec $BIN $PARAMS } } # if $PID is empty, run $BIN $PARAMS + "-s" { if { eltest -v PID } exec $bins $PARAMS } # if $PID is empty, run $bins $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 } + } { foreground { /bin/printf "usage: %s -s|-k\n" $0 } exit 1 }