Skip to content

Commit 66ef6d4

Browse files
author
Alan Kent
committed
First cut of Mac synchronization shell script.
1 parent 2f1fa72 commit 66ef6d4

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

m2devbox-unison-sync.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
3+
if [[ ! -f unison ]]; then
4+
echo "The unison binary could not be found. You can retrieve a"
5+
echo "compatible version from the DevBox web container using:"
6+
echo ""
7+
echo " docker cp proj1-m2web:/mac-osx/unison ."
8+
echo " docker cp proj1-m2web:/mac-osx/unison-fsmonitor ."
9+
echo " chmod +x unison unison-fsmonitor"
10+
echo ""
11+
exit 1
12+
fi
13+
14+
# Fetch the external Docker Unison port number
15+
UNISON_PORT=$(docker-compose port web 5000 | awk -F: '{print $2}')
16+
17+
LOCAL_ROOT=./shared/www
18+
REMOTE_ROOT=socket://localhost:$UNISON_PORT//var/www
19+
20+
IGNORE=
21+
22+
# Magento files not worth pulling locally.
23+
IGNORE="$IGNORE -ignore 'Path magento2/var/cache'"
24+
IGNORE="$IGNORE -ignore 'Path magento2/var/composer_home'"
25+
IGNORE="$IGNORE -ignore 'Path magento2/var/log'"
26+
IGNORE="$IGNORE -ignore 'Path magento2/var/page_cache'"
27+
IGNORE="$IGNORE -ignore 'Path magento2/var/session'"
28+
IGNORE="$IGNORE -ignore 'Path magento2/var/tmp'"
29+
IGNORE="$IGNORE -ignore 'Path magento2/var/.setup_cronjob_status'"
30+
IGNORE="$IGNORE -ignore 'Path magento2/var/.update_cronjob_status'"
31+
IGNORE="$IGNORE -ignore 'Path magento2/pub/media'"
32+
IGNORE="$IGNORE -ignore 'Path magento2/pub/static'"
33+
34+
# Other files not worth pushing to the container.
35+
IGNORE="$IGNORE -ignore 'Path magento2/.git'"
36+
IGNORE="$IGNORE -ignore 'Path magento2/.gitignore'"
37+
IGNORE="$IGNORE -ignore 'Path magento2/.gitattributes'"
38+
IGNORE="$IGNORE -ignore 'Path magento2/.magento'"
39+
IGNORE="$IGNORE -ignore 'Path magento2/.idea'"
40+
IGNORE="$IGNORE -ignore 'Name {.*.swp}'"
41+
IGNORE="$IGNORE -ignore 'Name {.unison.*}'"
42+
43+
UNISONARGS="$LOCAL_ROOT $REMOTE_ROOT -prefer $LOCAL_ROOT -preferpartial 'Path var -> $REMOTE_ROOT' -auto -batch $IGNORE"
44+
45+
if [[ ! -f $LOCAL_ROOT/magento2/vendor ]]; then
46+
echo "**** Pulling files from container (faster quiet mode) ****"
47+
./unison $UNISONARGS -silent 1>/dev/null 2>&1
48+
fi
49+
50+
while true; do
51+
echo "**** Entering file watch mode ****"
52+
./unison $UNISONARGS -repeat watch
53+
sleep 5
54+
done

0 commit comments

Comments
 (0)