aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sync
blob: 72e9010da350b7e36c77262dc9ecf3eeccae71c6 (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
#!/usr/bin/env bash

HELP="Usage: sync [-h]

Sync a source with a Git repository target.

Parameters
    Environmntal variables
        FRIPOST_SYNC_SRC      set source directory
    -h                        help

Set target directory where the repository is found and script
executed. Set source directory to for example a shared folder.  Make
sure that all pahts are absolute."

EXCL="
*~*
*#*
Readme.md
"

trg="$PWD"
src="$FRIPOST_SYNC_SRC"
excl=$XDG_RUNTIME_DIR/${0##*/}-excl

if [ "$1" == "-h" ]; then echo "$HELP"; exit; fi
if [ ! -d "$src" -o ! -d "$trg" ]; then
    echo -n "Suorce '$src' and target '$trg' must be valid directories."
    echo " See help: '${0} -h'."
    exit 1
fi

echo  "${0##*/}: I: Sync '${src}' to '${trg}'" 1>&2

echo "$EXCL" > $excl

rsync -a --delete -P --exclude-from=$excl "${src}"/ "${trg}"/ \
      | grep -iv "^sending"
git -C "${trg}" status --short --branch