-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync-config.sh
executable file
·54 lines (44 loc) · 1.3 KB
/
sync-config.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
49
50
51
52
53
54
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
set -euo pipefail
dest="/mnt/temp1"
device="/dev/sdb1"
function print_help() {
echo "Usage: $0 [options]"
echo ""
echo "Options:"
echo " -d, --device=DEV flysight device ($device)"
echo " --dest=PATH destination directory ($dest)"
echo " -n, --dry-run dry run"
echo " -h, --help display this help info"
}
TEMP=$( \
getopt \
-n $(basename "$0") \
-o hnd: \
--long help,dry-run,device: \
-- "$@"
)
if [ $? != 0 ]; then echo "Terminating..." >&2; exit 1; fi
eval set -- "$TEMP"
dry_run=
while true; do
case "$1" in
-d|--device) device="$2" ; shift 2 ;;
-n|--dry-run) dry_run="--dry-run" ; shift ;;
-h|--help) print_help ; exit 0 ;;
--) shift ; break ;;
*) echo "Internal error!" ; exit 1 ;;
esac
done
num_req=0
if [[ $# -ne $num_req ]]; then
print_help
echo "ERROR: Script requires $num_req arguments, but got $#"
exit 1
fi
set -x
cd "${DIR}"
sudo mount -o umask=000 "$device" "$dest"
sudo rsync -iva $dry_run --progress --stats --no-o --no-g --no-p CONFIG.TXT config "$dest/"
sudo umount "$dest"