blob: 17a810718d7c2a5abf8505ef390b65093def0f3e (
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#! /bin/sh
set -efu
self=$(readlink -f "$0")
prefix=${self%/bin/*}
libdir=$prefix/lib
debug=false
force=false
origin_host=${HOSTNAME-cat /proc/sys/kernel/hostname}
origin_user=$LOGNAME
target_spec=
fail=true
error() {
echo "error: $1" >&2
fail=false
}
for arg; do
case $arg in
--debug)
debug=true
;;
--force)
force=true
;;
-*)
error "bad argument: $arg"
;;
*)
if test -n "$target_spec"; then
error "bad argument: $arg"
else
target_spec=$arg
fi
;;
esac
done
if test -z "$target_spec"; then
error 'no target specified'
fi
if test "$fail" != true; then
exit 1
fi
script=$(jq -e -r \
--argjson use_force "$force" \
--arg target_spec "$target_spec" \
--arg origin_host "$origin_host" \
--arg origin_user "$origin_user" \
-f "$libdir/populate.jq")
if test "$debug" = true; then
echo "$script"
else
eval "$script"
fi
|