blob: 1519e48977d5e33fb5cfd4e49492c1ddcf9d5b53 (
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
65
66
67
68
69
70
71
72
73
|
#!/bin/sh
set -e
ARGS=""
LOCAL=false
SYSLOG=false
# TODO email notifications
while [ $# -gt 0 ]; do
case "$1" in
-h|--help)
echo "Multiconfig system call script"
echo "Usage: multiconfig.sh [OPTION]..."
echo
echo "Options:"
echo "--local - Use current working directory as multiconfig source."
echo "--syslog - pipe output to syslog"
echo "Passed options:"
echo "--verbose - Make output more verbose"
echo "--quiet - Make output more quiet"
echo "--operation OPT - run only given operation"
exit 0
;;
--verbose|-v|--quiet|-q)
ARGS="$ARGS $1"
;;
--operation|-o)
ARGS="$ARGS $1 $2"
shift
;;
--local)
LOCAL=true
;;
--syslog)
SYSLOG=true
;;
esac
shift
done
[ "$(id -u)" == 0 ] || {
echo "Please run this script only as root."
exit 1
}
PREFIX="/root/.multiconfig"
# Check if we have key
if [ ! -f "$PREFIX/key" ]; then
echo "Key is not in expected path. Please setup this host for multiconfig."
exit 1
fi
# TODO check key access rights
if ! $LOCAL; then
if [ -d "$PREFIX/repo" ]; then
true
# TODO git clone
fi
cd "$PREFIX/repo"
# Pull git repository
git fetch
git reset --hard origin/master
git clean -xdf
fi
# TODO check repository signature
CMD="./run.sh --key $PREFIX/key $ARGS"
# Run command
$CMD
|