-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompbackup
More file actions
executable file
·30 lines (24 loc) · 891 Bytes
/
Copy pathcompbackup
File metadata and controls
executable file
·30 lines (24 loc) · 891 Bytes
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
#!/bin/sh
unset CONFIG_PATH
[ -f "~/.compbackup.config" ] && CONFIG_PATH="~/.compbackup.config"
[ -f "./.compbackup.config" ] && CONFIG_PATH="./.compbackup.config"
if [ -z "$CONFIG_PATH" ]; then
printf "No config found!\n" 1>&2
exit 1
fi
unset DIR DATE IPADDR PORT config
DATE="$(date +'companion-backup-%Y%m%d.companionconfig')"
DIR="$(grep "backupdir=" $CONFIG_PATH | cut -d'=' -f2)"
IPADDR="$(grep "ip" $CONFIG_PATH | cut -d'=' -f2)"
PORT="$(grep "port" $CONFIG_PATH | cut -d'=' -f2)"
if [ -z "$DATE" -o -z "$DIR" -o -z "$IPADDR" ]; then
printf "Something isn't right!\n" 1>&2
printf "Variables:\n"
printf "file name = %s\n" "$DATE"
printf "dropbox dir = %s\n" "$DIR"
printf "ip address = %s\n" "$IPADDR"
printf "port = %d\n" "${PORT:-8888}"
exit 1
fi
config="$(curl http://$IPADDR:"${PORT:-8888}"/int/full_export)"
test "$config" && echo "$config" > "$DIR/$DATE"