summaryrefslogtreecommitdiff
path: root/fill
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-12-30 17:06:08 -0700
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-12-30 17:06:08 -0700
commit9539d82e07a22550b9a6d9ecbef47be6250e5d90 (patch)
treea7b1dcb9047550c79f27da281d194477842db7cf /fill
parent2b57a4cf95d2a4ea4acdba010ad71b41f67135f9 (diff)
Refactor to be friendlier with OpenRC; expand README.
Diffstat (limited to 'fill')
-rwxr-xr-xfill43
1 files changed, 43 insertions, 0 deletions
diff --git a/fill b/fill
new file mode 100755
index 0000000..f12ae2a
--- /dev/null
+++ b/fill
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+# Copyright 2016 Luke Shumaker
+# This work is free. You can redistribute it and/or modify it under the
+# terms of the Do What The Fuck You Want To Public License, Version 2,
+# as published by Sam Hocevar. See the COPYING file for more details.
+
+declare -r workdir=/var/lib/pristine-etc
+
+lock() {
+ local fd=$1
+ local file=$2
+ eval "exec $fd>"'"$file"'
+ flock "${@:3}" "$fd"
+}
+
+unlock() {
+ local fd=$1
+ exec {fd}>&-
+}
+
+drain() {
+ if [[ -d /run/systemd/system ]]; then
+ systemctl reset-failed pristine-etc-keeper.service &>/dev/null || true
+ systemctl start pristine-etc-keeper.service
+ else
+ /etc/etckeeper/pristine/drain &
+ fi
+}
+
+main() {
+ set -e
+ umask 0022
+
+ if [[ $# -gt 0 ]]; then
+ lock 8 "${workdir}/spool.spool"
+ printf '%s\n' "$*" >> "${workdir}/spool"
+ unlock 8
+ fi
+
+ drain
+}
+
+main "$@"