-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshared.sh
48 lines (40 loc) · 1.05 KB
/
shared.sh
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
#!/bin/bash
# Copyright (C) 2018 by Tomas Herceg <[email protected]>
# Released under GNU GPL 3 or later
if tty -s; then
Blue='\e[01;34m'
White='\e[01;37m'
Red='\e[01;31m'
Green='\e[01;32m'
Orange='\e[01;33m'
Reset='\e[00m'
DEBUG_RSYNC=1
fi
debug() {
[ $DEBUG == 1 ] && echo -e "`date` ${Blue}${1}:${Reset} $2${Reset}"
}
error() {
echo -e "`date` ${Red}${1}:${Reset} $2${Reset}"
}
if [ -r $SCRIPTPATH/config.sh ]; then
source $SCRIPTPATH/config.sh
else
error "config.sh not found" "you can copy default config.sh.def"
exit 1
fi
# overwrite hosts from config if commandline parameter is used
if [ "$#" -ne 0 ]; then
if [ "$@" == "-all" ] || [ "$@" == "--all" ]; then
HOSTS=`zfs list |awk -F'[ /]+' -v pool="$POOL/" -v ORS=" " '$0 ~ pool {print $2}'`
debug "Overwriting HOSTS by all actual backuped servers" "$HOSTS"
else
HOSTS=("$@")
debug "Overwriting HOSTS from commandline parameter" "$HOSTS"
fi
fi
if [ "$HOSTS" == "" ]; then
error "HOSTS is empty" "Nothing to do"
exit 1
fi
mkdir -p $LOCK_DIR
# vim: noexpandtab tabstop=2 shiftwidth=2 nowrap