-
Notifications
You must be signed in to change notification settings - Fork 6
/
push.sh
executable file
·108 lines (90 loc) · 2.11 KB
/
push.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env bash
set -e;
ROOT=$(cd $(dirname $0) && pwd)
if [ ! -e "`which jq`" ]; then
echo "jq is not installed"
exit 0;
fi
if [ ! -e "`which wp`" ]; then
echo "WP-CLI is not installed"
exit 0;
fi
while getopts awdtpue:f:l: opt
do
case $opt in
a) a=1
;;
w) w=1
;;
d) d=1
;;
t) t=1
;;
p) p=1
;;
u) u=1
;;
e) e=1
ENVIRONMENT=$OPTARG
;;
f) f=1
CONFIG_FILE=$OPTARG
;;
l) l=1
LOCAL=$OPTARG
;;
esac
done
if [ "$f" = 1 ]; then
CONFIG_PATH=${CONFIG_FILE}
else
CONFIG_PATH=${ROOT}/config.json
fi
if [ ! -e ${CONFIG_PATH} ]; then
echo "config.json is not found"
exit 0;
fi
if [ ! -n "${ENVIRONMENT}" ]; then
echo "Please specify -e option"
exit 0;
fi
if [ "$l" != 1 ]; then
LOCAL=local
fi
if [ $(cat ${CONFIG_PATH} | jq ".${LOCAL} | length") -eq 0 ]; then
echo "'${LOCAL}' configuration is not found"
exit 0;
fi
. ${ROOT}/bin/variables.sh
MYSQLADMIN_PING="mysqladmin ping -u ${LOCAL_DB_USER}";
if [ -n "${LOCAL_DB_PASSWORD}" ]; then
MYSQLADMIN_PING+=" -p${LOCAL_DB_PASSWORD}"
fi
if [ ! -e "`which mysqladmin`" ] || [ "`${MYSQLADMIN_PING}`" != "mysqld is alive" ]; then
echo "MySQL not started."
exit 0
fi
if [ "$a" = 1 ] ; then
bash ${ROOT}/bin/push.sh ${ENVIRONMENT} ${CONFIG_PATH} ${LOCAL} /
bash ${ROOT}/bin/db-push.sh ${ENVIRONMENT} ${CONFIG_PATH} ${LOCAL}
fi
if [ "${w}" = 1 ] ; then
echo "===== Uploading WordPress Core ====="
EXCLUDES=(wp-content)
bash ${ROOT}/bin/push.sh ${ENVIRONMENT} ${CONFIG_PATH} ${LOCAL} / ${EXCLUDES}
fi
if [ "${d}" = 1 ] ; then
bash ${ROOT}/bin/db-push.sh ${ENVIRONMENT} ${CONFIG_PATH} ${LOCAL}
fi
if [ "${t}" = 1 ] ; then
echo "===== Uploading themes ====="
bash ${ROOT}/bin/push.sh ${ENVIRONMENT} ${CONFIG_PATH} ${LOCAL} /wp-content/themes/
fi
if [ "${p}" = 1 ] ; then
echo "===== Uploading plugins ====="
bash ${ROOT}/bin/push.sh ${ENVIRONMENT} ${CONFIG_PATH} ${LOCAL} /wp-content/plugins/
fi
if [ "${u}" = 1 ] ; then
echo "===== Uploading uploads ====="
bash ${ROOT}/bin/push.sh ${ENVIRONMENT} ${CONFIG_PATH} ${LOCAL} /wp-content/uploads/
fi