forked from mindoc-org/mindoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync_host.sh
43 lines (37 loc) · 896 Bytes
/
sync_host.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
#!/bin/bash
set -eux
if ! [ -x "$(command -v rclone)" ]; then
apt install rclone -y
else
whereis rclone
fi
export MINDOC_SYNC="${MINDOC_SYNC:=}"
export SYNC_LIST="${SYNC_LIST:=}"
export SYNC_ACTION="${SYNC_ACTION:=sync --dry-run}"
export HOST_DIR=/mindoc-sync-host
export DOCKER_DIR=/mindoc
function doSyncCopy() {
if [ -d "${1}" ]
then
rclone $SYNC_ACTION --progress --exclude .git* --exclude .git/** "${1}" "${2}"
fi
}
function doSync() {
case $MINDOC_SYNC in
"docker2host")
doSyncCopy "${DOCKER_DIR}/${1}" "${HOST_DIR}/${1}"
;;
"host2docker")
doSyncCopy "${HOST_DIR}/${1}" "${DOCKER_DIR}/${1}"
;;
*)
printenv | grep MINDOC_SYNC
;;
esac
}
export IFS=";"
if ! [ -z "${SYNC_LIST}" ]; then
for item in $SYNC_LIST; do
doSync "${item}"
done
fi