39 lines
1.2 KiB
Bash
Executable File
39 lines
1.2 KiB
Bash
Executable File
#!/bin/rc -e
|
|
#
|
|
# Usage: /etc/slew/lib/build.rc main
|
|
#
|
|
# This script copies `/etc/slew/main' to `/etc/slew/build.main/prep',
|
|
# preprocesses it, and compiles it to `/etc/slew/db/main'; the previous
|
|
# `/etc/slew/db/main' will be moved to `/etc/slew/build.main/old' if existent.
|
|
# On a live system, this script would also update `/run/s6/compiled' if
|
|
# necessary, and finally run `s6-rc-update -n /etc/slew/db/compiled'.
|
|
#
|
|
# This script does not delete anything or trigger any real state transition,
|
|
# and the user is responsible for finally invoking `s6-rc-update' as well as
|
|
# deleting `/etc/slew/build.main'.
|
|
|
|
dbdir=/etc/slew/db
|
|
rcompiled=/run/s6-rc/compiled
|
|
builddir=/etc/slew/build.$1
|
|
~ $#* 1 || exit 1
|
|
[ -d /run/s6-rc ] && live=1 || live=0
|
|
if (~ $live 1 && ! [ -L $rcompiled ]) exit 1
|
|
|
|
mkdir $builddir
|
|
cp -rL /etc/slew/$1 $builddir/prep
|
|
/etc/slew/lib/prep.rc /etc/slew/lib/prep $builddir/prep
|
|
s6-rc-compile -h _fdholder $builddir/new $builddir/prep
|
|
|
|
if ([ -d $dbdir/$1 ]) {
|
|
if (
|
|
~ $live 1 &&
|
|
~ `{realpath $rcompiled} `{realpath $dbdir/$1}
|
|
) ln -snf $builddir/old $rcompiled
|
|
mv $dbdir/$1 $builddir/old
|
|
} else mkdir -p $dbdir
|
|
|
|
mv $builddir/new $dbdir/$1
|
|
ln -snf $1 $dbdir/compiled
|
|
if (~ $live 1) s6-rc-update -n $dbdir/compiled
|
|
|