-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync.sh
executable file
·53 lines (46 loc) · 1.55 KB
/
sync.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
#!/usr/bin/env bash
VMNAME=$(basename $(readlink -f "$(dirname "$(readlink -f "$0")")/../../../../../../../../"))
DOMAIN=$(basename $(readlink -f "$(dirname "$(readlink -f "$0")")/../../../../../../"))
SRC="${PWD}"
DST="vagrant@${VMNAME}.local:/var/www/domains/${DOMAIN}/html/drupal/sites/all/themes"
CMD="${1}"
CLEAR_CACHE="${2}"
function do_full_sync () {
cd ${PWD}/../../../../../../../../
vagrant rsync
ssh "${VMNAME}.local" 'cd /var/www/domains/'"${DOMAIN}"'/html/drupal && source ~/.bash_profile && drush cc css-js && drush cc theme-registry'
}
function do_css_sync () {
rsync --exclude '.git/' --exclude '.sass-cache/' --exclude 'node_modules/' --archive --delete --compress --chmod=ugo=rwX "${SRC}" "${DST}"
if [ "${1}" = "1" ]; then
ssh "${VMNAME}.local" 'cd /var/www/domains/'"${DOMAIN}"'/html/drupal && source ~/.bash_profile && drush cc css-js'
else
echo "Synced CSS and JS files."
fi
}
function do_php_sync () {
rsync --exclude '.git/' --exclude '.sass-cache/' --exclude 'node_modules/' --archive --delete --compress --chmod=ugo=rwX "${SRC}" "${DST}"
if [ "${1}" = "1" ]; then
ssh "${VMNAME}.local" 'cd /var/www/domains/'"${DOMAIN}"'/html/drupal && source ~/.bash_profile && drush cc theme-registry'
else
echo "Synced PHP files."
fi
}
case $CMD in
"full")
do_full_sync
exit 0
;;
"css")
do_css_sync "${CLEAR_CACHE}"
exit 0
;;
"php")
do_php_sync "${CLEAR_CACHE}"
exit 0
;;
*)
echo "Usage: sync.sh [full|css|php]"
exit 1
;;
esac