blob: f12ae2aae65a959fdd194d24d2ee17358cc436f3 (
plain)
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
32
33
34
35
36
37
38
39
40
41
42
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 "$@"
|