From 980c5408489a3a3a56e49c3873f1bce6a0155cad Mon Sep 17 00:00:00 2001 From: PS Date: Sun, 1 Feb 2026 12:02:03 +0100 Subject: version 0.2.0.0 --- src/bin/compile-db | 27 +++++++++++++++++++++++++++ src/bin/longrun-make | 36 ++++++++++++++++++++++++++++++++++++ src/bin/oneshot-make | 22 ++++++++++++++++++++++ src/bin/prepare-svscan | 37 +++++++++++++++++++++++++++++++++++++ src/bin/system-db | 7 +++++++ src/bin/system-ml | 31 +++++++++++++++++++++++++++++++ src/bin/system-rc | 5 +++++ src/bin/system-run | 6 ++++++ src/bin/system-shutdown-daemon | 31 +++++++++++++++++++++++++++++++ src/bin/user-db | 13 +++++++++++++ src/bin/user-init | 26 ++++++++++++++++++++++++++ src/bin/user-ml | 33 +++++++++++++++++++++++++++++++++ src/bin/user-rc | 11 +++++++++++ src/bin/user-run | 12 ++++++++++++ src/bin/user-shutdown | 23 +++++++++++++++++++++++ src/bin/user-tmpfs | 17 +++++++++++++++++ 16 files changed, 337 insertions(+) create mode 100755 src/bin/compile-db create mode 100755 src/bin/longrun-make create mode 100755 src/bin/oneshot-make create mode 100755 src/bin/prepare-svscan create mode 100755 src/bin/system-db create mode 100755 src/bin/system-ml create mode 100755 src/bin/system-rc create mode 100755 src/bin/system-run create mode 100755 src/bin/system-shutdown-daemon create mode 100755 src/bin/user-db create mode 100755 src/bin/user-init create mode 100755 src/bin/user-ml create mode 100755 src/bin/user-rc create mode 100755 src/bin/user-run create mode 100755 src/bin/user-shutdown create mode 100755 src/bin/user-tmpfs (limited to 'src/bin') diff --git a/src/bin/compile-db b/src/bin/compile-db new file mode 100755 index 0000000..22b63b4 --- /dev/null +++ b/src/bin/compile-db @@ -0,0 +1,27 @@ +#!@shebangdir@/execlineb -WS2 + +# ISC license. + +multisubstitute { + define CONFIGDIR ${1} + define LIVEDIR ${2} +} + +backtick -ED" " OLDDB { realpath ${CONFIGDIR}/compiled } +backtick -E DATE { date +%s } +elglob SOURCES ${CONFIGDIR}/src/* + +if { s6-rc-compile -v2 ${CONFIGDIR}/compiled-${DATE} ${SOURCES} } + +if { + if -x0 { eltest -d ${LIVEDIR} } + if -n -x0 { s6-rc-update -v2 -l ${LIVEDIR} ${CONFIGDIR}/compiled-${DATE} } + if { s6-rc-update -v2 -l ${LIVEDIR} ${CONFIGDIR}/compiled } + if { rm -Rf ${CONFIGDIR}/compiled-${DATE} } + exit 1 +} + +if { ln -sf compiled-${DATE} ${CONFIGDIR}/compiled/compiled } +if { mv -f ${CONFIGDIR}/compiled/compiled ${CONFIGDIR}/ } + +rm -Rf ${OLDDB} diff --git a/src/bin/longrun-make b/src/bin/longrun-make new file mode 100755 index 0000000..2b5b433 --- /dev/null +++ b/src/bin/longrun-make @@ -0,0 +1,36 @@ +#!@shebangdir@/execlineb -WS5 + +# ISC license. + +multisubstitute { + define WORKINGDIR ${1} + define NAME ${2} + define TYPE ${3} + define SCRIPT ${4} + define DEPENDENCIES ${5} +} + +if { mkdir -p ${WORKINGDIR}/${NAME}-${TYPE} } + +background { + if { eltest ${TYPE} = log } + s6-setlock ${WORKINGDIR}/${NAME}-log/consumer-for + if -n { grep -Fq -- ${NAME}-srv ${WORKINGDIR}/${NAME}-log/consumer-for } + background { redirfd -a 1 ${WORKINGDIR}/${NAME}-log/consumer-for echo ${NAME}-srv } + background { redirfd -w 1 ${WORKINGDIR}/${NAME}-log/pipeline-name echo ${NAME} } +} + +background { + if { eltest ${TYPE} = srv } + redirfd -w 1 ${WORKINGDIR}/${NAME}-srv/producer-for echo ${NAME}-log +} + +background { redirfd -w 1 ${WORKINGDIR}/${NAME}-${TYPE}/type echo longrun } +background { redirfd -w 1 ${WORKINGDIR}/${NAME}-${TYPE}/notification-fd echo 3 } +background { redirfd -w 1 ${WORKINGDIR}/${NAME}-${TYPE}/run echo ${SCRIPT} } +background { + if { eltest ${DEPENDENCIES} != none } + define -s SPLITDEPENDENCIES ${DEPENDENCIES} + if { mkdir -p ${WORKINGDIR}/${NAME}-${TYPE}/dependencies.d } + touch ${WORKINGDIR}/${NAME}-${TYPE}/dependencies.d/${SPLITDEPENDENCIES} +} diff --git a/src/bin/oneshot-make b/src/bin/oneshot-make new file mode 100755 index 0000000..4d255b2 --- /dev/null +++ b/src/bin/oneshot-make @@ -0,0 +1,22 @@ +#!@shebangdir@/execlineb -WS5 + +# ISC license. + +multisubstitute { + define WORKINGDIR ${1} + define NAME ${2} + define UPSCRIPT ${3} + define DOWNSCRIPT ${4} + define DEPENDENCIES ${5} +} + +if { mkdir -p ${WORKINGDIR}/${NAME} } + +background { redirfd -w 1 ${WORKINGDIR}/${NAME}/type echo oneshot } +background { redirfd -w 1 ${WORKINGDIR}/${NAME}/up echo ${UPSCRIPT} } +background { redirfd -w 1 ${WORKINGDIR}/${NAME}/down echo ${DOWNSCRIPT} } +background { + if { eltest -v 5 } + if { mkdir -p ${WORKINGDIR}/${NAME}/dependencies.d } + touch ${WORKINGDIR}/${NAME}/dependencies.d/${DEPENDENCIES} +} diff --git a/src/bin/prepare-svscan b/src/bin/prepare-svscan new file mode 100755 index 0000000..9fe7f8d --- /dev/null +++ b/src/bin/prepare-svscan @@ -0,0 +1,37 @@ +#!@shebangdir@/execlineb -Ws4 + +# ISC license. + +multisubstitute { + define WORKINGDIR ${1} + define RUNDIR ${2} + define BUNDLE ${3} + define PROG ${4} +} + +redirfd -r 0 /dev/null +execline-umask 0022 + +if { mkdir -p -m750 -- ${RUNDIR} } +foreground { cp -RfpL -- ${WORKINGDIR}/run-image/. ${RUNDIR}/ } + +if { mkfifo -m700 ${RUNDIR}/service/s6-svscan-log/fifo } +redirfd -wnb 1 ${RUNDIR}/service/s6-svscan-log/fifo + +background { + redirfd -w 2 ${RUNDIR}/service/s6-svscan-log/fifo + if -x0 -n { eltest -d ${RUNDIR}/s6-rc } + foreground { echo "\ninit!\n" } + if { + s6-rc-init + -c ${WORKINGDIR}/compiled + -l ${RUNDIR}/s6-rc + ${RUNDIR}/service + } + foreground { echo "\nStarting bundle ${BUNDLE}...\n" } + s6-rc -l ${RUNDIR}/s6-rc -v2 -b -t@timeout@ -up change ${BUNDLE} +} +fdmove -c 2 1 + +s6-envdir -I ${WORKINGDIR}/env +${PROG} ${@} diff --git a/src/bin/system-db b/src/bin/system-db new file mode 100755 index 0000000..add7d33 --- /dev/null +++ b/src/bin/system-db @@ -0,0 +1,7 @@ +#!@shebangdir@/execlineb -P + +# ISC license. + +compile-db + @sysconfdir@ + @tmpfsdir@/@sysrundir@/s6-rc diff --git a/src/bin/system-ml b/src/bin/system-ml new file mode 100755 index 0000000..1937ac0 --- /dev/null +++ b/src/bin/system-ml @@ -0,0 +1,31 @@ +#!@shebangdir@/execlineb -P + +# ISC license. + +define LOGSCRIPT "#!@shebangdir@/execlineb -P + +# ISC license + +fdmove -c 1 2 + +if { mkdir -p -m750 -- @syslogdir@/${NAME} } +if { chown @loguser@:@loguser@ @syslogdir@/${NAME} } +s6-setuidgid @loguser@ +s6-log -bd3 @logconfig@ @syslogdir@/${NAME}" + +if { rm -Rf @sysconfdir@/src/generated-logger } +if { mkdir -p @sysconfdir@/src/generated-logger } + +elglob LONGRUNS @sysconfdir@/src/*/* +forx -pE LONGRUN { ${LONGRUNS} } + if -x0 { eltest -f ${LONGRUN}/producer-for } + if -x0 -n { eltest -f ${LONGRUN}/no-ml } + if { echo Making the logger of ${LONGRUN} } + pipeline { sed -e s/-log$// -- ${LONGRUN}/producer-for } + withstdinas -E NAME + longrun-make + @sysconfdir@/src/generated-logger + ${NAME} + log + ${LOGSCRIPT} + @logdep@ diff --git a/src/bin/system-rc b/src/bin/system-rc new file mode 100755 index 0000000..61230ab --- /dev/null +++ b/src/bin/system-rc @@ -0,0 +1,5 @@ +#!@shebangdir@/execlineb -s0 + +# ISC license. + +s6-rc -l @tmpfsdir@/@sysrundir@/s6-rc ${@} diff --git a/src/bin/system-run b/src/bin/system-run new file mode 100755 index 0000000..e5b9cec --- /dev/null +++ b/src/bin/system-run @@ -0,0 +1,6 @@ +#!@shebangdir@/execlineb -s0 + +# ISC license. + +s6-sudo @tmpfsdir@/@sysrundir@/service/goetia-runner/s + fdmove -c 1 2 ${@} diff --git a/src/bin/system-shutdown-daemon b/src/bin/system-shutdown-daemon new file mode 100755 index 0000000..6419bfb --- /dev/null +++ b/src/bin/system-shutdown-daemon @@ -0,0 +1,31 @@ +#!@shebangdir@/execlineb -P + +# ISC license. + +tryexec { ./stage3b } + +if -n { + foreground { echo "\nsystem-shutdown!\n" } + foreground { s6-rc -l @tmpfsdir@/@sysrundir@/s6-rc -v2 -b -Da -t@timeout@ change } + foreground { + pipeline { ls -1 @tmpfsdir@/@sysrundir@/service/ } + pipeline { + sed + -e /s6-svscan-log/d + -e /.s6-svscan/d + -e /goetia-shutdown/d + -e /goetia-rescue/d + } + forstdin -pE SERVICE + s6-svc -T @timeout@ -D @tmpfsdir@/@sysrundir@/service/${SERVICE} + } + + foreground { rm -Rf -- @syslogdir@/uncaught-logs } + foreground { cp -Rpf -- @tmpfsdir@/@sysrundir@/log/uncaught-logs @syslogdir@/ } + + foreground { chmod u+x ./stage3b } + foreground { echo "sending all processes the TERM signal..." } + foreground { kill -SIGTERM -- -1 } +} +foreground { touch ./down } +chmod a-x ./stage3b diff --git a/src/bin/user-db b/src/bin/user-db new file mode 100755 index 0000000..8c7fb4f --- /dev/null +++ b/src/bin/user-db @@ -0,0 +1,13 @@ +#!@shebangdir@/execlineb -P + +# ISC license. + +multisubstitute { + importas -Si USER + importas -Si HOME + importas -Si USERTREE +} + +compile-db + ${HOME}/@usrconfdir@/${USERTREE} + @tmpfsdir@/@usrrundir@/${USER}/${USERTREE}/s6-rc diff --git a/src/bin/user-init b/src/bin/user-init new file mode 100755 index 0000000..aa24f9d --- /dev/null +++ b/src/bin/user-init @@ -0,0 +1,26 @@ +#!@shebangdir@/execlineb -P + +# ISC license. + +multisubstitute { + importas -Si USER + importas -Si USERTREE + importas -SD default BUNDLE + importas -SD + /command:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/libexec:/usr/local/libexec + PATH +} + +backtick HOME { homeof ${USER} } +importas -Si HOME + +export PATH ${HOME}/.local/bin:${PATH} + +s6-envuidgid ${USER} + +prepare-svscan + ${HOME}/@usrconfdir@/${USERTREE} + @tmpfsdir@/@usrrundir@/${USER}/${USERTREE} + ${BUNDLE} + +s6-svscan @tmpfsdir@/@usrrundir@/${USER}/${USERTREE}/service diff --git a/src/bin/user-ml b/src/bin/user-ml new file mode 100755 index 0000000..60a01ab --- /dev/null +++ b/src/bin/user-ml @@ -0,0 +1,33 @@ +#!@shebangdir@/execlineb -P + +# ISC license. + +multisubstitute { + importas -Si USER + importas -Si HOME + importas -Si USERTREE +} + +define LOGSCRIPT "#!@shebangdir@/execlineb -P + +fdmove -c 1 2 + +if { mkdir -p -m750 -- ${HOME}/@usrlogdir@/${USERTREE}/${NAME} } +s6-log -bd3 @logconfig@ ${HOME}/@usrlogdir@/${USERTREE}/${NAME}" + +if { rm -Rf ${HOME}/@usrconfdir@/${USERTREE}/src/generated-logger } +if { mkdir -p ${HOME}/@usrconfdir@/${USERTREE}/src/generated-logger } + +elglob LONGRUNS ${HOME}/@usrconfdir@/${USERTREE}/src/*/* +forx -pE LONGRUN { ${LONGRUNS} } + if -x0 { eltest -f ${LONGRUN}/producer-for } + if -x0 -n { eltest -f ${LONGRUN}/no-ml } + if { echo Making the logger of ${LONGRUN} } + pipeline { sed -e s/-log$// -- ${LONGRUN}/producer-for } + withstdinas -E NAME + longrun-make + ${HOME}/@usrconfdir@/${USERTREE}/src/generated-logger + ${NAME} + log + ${LOGSCRIPT} + none diff --git a/src/bin/user-rc b/src/bin/user-rc new file mode 100755 index 0000000..bee9930 --- /dev/null +++ b/src/bin/user-rc @@ -0,0 +1,11 @@ +#!@shebangdir@/execlineb -s0 + +# ISC license. + +multisubstitute { + importas -Si USER + importas -Si USERTREE +} +backtick -Ei HOME { homeof ${USER} } + +s6-rc -l @tmpfsdir@/@usrrundir@/${USER}/${USERTREE}/s6-rc ${@} diff --git a/src/bin/user-run b/src/bin/user-run new file mode 100755 index 0000000..e110115 --- /dev/null +++ b/src/bin/user-run @@ -0,0 +1,12 @@ +#!@shebangdir@/execlineb -s0 + +# ISC license. + +multisubstitute { + importas -Si USER + importas -Si USERTREE +} +backtick -Ei HOME { homeof ${USER} } + +s6-sudo @tmpfsdir@/@usrrundir@/${USER}/${USERTREE}/service/goetia-runner/s + fdmove -c 1 2 ${@} diff --git a/src/bin/user-shutdown b/src/bin/user-shutdown new file mode 100755 index 0000000..9376f5b --- /dev/null +++ b/src/bin/user-shutdown @@ -0,0 +1,23 @@ +#!@shebangdir@/execlineb -P + +# ISC license. + +multisubstitute { + importas -Si USER + importas -Si USERTREE +} +backtick -Ei HOME { homeof ${USER} } + +if -x0 { eltest -d @tmpfsdir@/@usrrundir@/${USER}/${USERTREE} } + +redirfd -wnb 1 @tmpfsdir@/@usrrundir@/${USER}/${USERTREE}/service/s6-svscan-log/fifo +fdmove -c 2 1 + +foreground { + foreground { echo "\nshutdown\n" } + s6-rc -l @tmpfsdir@/@usrrundir@/${USER}/${USERTREE}/s6-rc -v2 -b -da -t@timeout@ change +} + +foreground { s6-svscanctl -t @tmpfsdir@/@usrrundir@/${USER}/${USERTREE}/service } +foreground { s6-svc -h @tmpfsdir@/@usrrundir@/${USER}/${USERTREE}/service/s6-svscan-log } +foreground { rm -Rf @tmpfsdir@/@usrrundir@/${USER}/${USERTREE} } diff --git a/src/bin/user-tmpfs b/src/bin/user-tmpfs new file mode 100755 index 0000000..02deb14 --- /dev/null +++ b/src/bin/user-tmpfs @@ -0,0 +1,17 @@ +#!@shebangdir@/execlineb -P + +# ISC license. + +importas -Si USER +importas -SD 64m USER_TMPFSDIR_SIZE +s6-envuidgid ${USER} +importas -Si UID +importas -Si GID + +if { mkdir -p @tmpfsdir@/@usrrundir@/${USER} } + +mount + -t tmpfs + -o mode=0755,size=${USER_TMPFSDIR_SIZE},uid=${UID},gid=${GID} + ${USER}-tmpfs + @tmpfsdir@/@usrrundir@/${USER} -- cgit v1.2.3