blob: 1b2d0d0b7fb81e54544c3037d2174c5e7a1f7123 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/bin/sh
set -eu
LIVE_DIR=${LIVE_DIR:-/run/s6-rc}
STATE_DIR=${STATE_DIR:-/etc/s6-rc}
SOURCE_DIR=${SOURCE_DIR:-/etc/s6-rc/src}
GENERATED_DIR=${SOURCE_DIR:-/run/svtree-generated}
new_dir="$STATE_DIR"/"_$(date +%s)"
main() {
local old
old="$(find "$STATE_DIR" -maxdepth 1 -name '_[0-9]*' -print)"
# compile new db
s6-rc-compile -v2 "$new_dir" "$SOURCE_DIR" "$GENERATED_DIR"
# switch to new db (if there's an active tree)
test -e "$LIVE_DIR" && s6-rc-update -v2 -l "$LIVE_DIR" -b "$new_dir"
# swap current db
s6-ln -snf "$new_dir" "$STATE_DIR"/compiled
# cleanup old db
# NOTE: needs to be unquoted for expansion to work
rm -rf -- $old
}
command -v s6-ln >/dev/null 2>&1 || exit 1
main || rm -rf "$new_dir"
|