-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathembark
executable file
·162 lines (138 loc) · 3.76 KB
/
embark
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/bash
VERSION=1.0.0
AUTHOR=luhuadong
EMAIL=luhuadong@163.com
HOME_DIR=`pwd`
BUILD_DIR=${HOME_DIR}/build
WEB_DIR=${HOME_DIR}/modules/WebServer/web_src
DEPLOY_DIR=/opt/openember
PACKAGE=openember-${VERSION}.zip
CONF_DIR=/etc/openember
CheckPermission() {
echo "Check user permission ..."
account=`whoami`
if [ ${account} != "root" ]; then
echo "${account}, you are NOT the supervisor."
echo "The root permission is required to run this installer."
echo "Permission denied."
exit 1
fi
}
RemoveExpiredFiles() {
if [ -d ${BUILD_DIR} ]; then
echo "Delete build/* ..."
rm -r ${BUILD_DIR}/*
else
mkdir ${BUILD_DIR}
fi
}
BuildProject() {
cd ${BUILD_DIR}
cmake ..
make -j8
cp -r ../modules/WebServer/web_root ${BUILD_DIR}/bin/
}
BuildTest() {
cd ${BUILD_DIR}
cmake ..
make -j8
make test
}
RunServer() {
cd ${BUILD_DIR}
./bin/WebServer
}
PackageAll() {
echo "Package all bin ..."
zip -q -r ${PACKAGE} ${BUILD_DIR}/bin
echo "See -> ${PACKAGE}"
}
DeployHost() {
echo "Deploy application ..."
# update web pages
cd ${WEB_DIR}
yarn build
# Apply for root permissions
# CheckPermission
if [ ! -d ${BUILD_DIR} ]; then
echo "You haven't built openember, please run again with `--build` option."
return -1
fi
cd ${BUILD_DIR}
# install dir
if [ ! -d ${DEPLOY_DIR} ]; then
sudo mkdir ${DEPLOY_DIR}
fi
if [ ! -d ${CONF_DIR} ]; then
echo "Create ${CONF_DIR} ..."
sudo mkdir ${CONF_DIR}
fi
# log file
sudo cp ../libs/Log/zlog.conf ${CONF_DIR}
sudo chmod 777 ${CONF_DIR}/zlog.conf
# web root
sudo cp -r ${WEB_DIR}/dist ${DEPLOY_DIR}/web_root
sudo cp -r ${BUILD_DIR}/bin ${DEPLOY_DIR}
}
DeployTarget() {
echo "Deploy application ..."
if [ ! -d ${BUILD_DIR} ]; then
echo "You haven't built project, please run again with `--build` option."
return -1
fi
scp -r ${BUILD_DIR}/bin/ reTerminal:/tmp/
}
if [ -z $1 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
echo "OpenEmber CLI tool v${VERSION}, ${EMAIL}"
echo ""
echo "Usage: $0 [options]"
echo ""
echo "OPTIONS"
echo " -b, build Build executable file from sources."
echo " -t, test Build and run all test cases."
echo " -p, package Package executable files in a tar ball."
echo " -s, server Build executable file and run a local web server."
echo " -d, deploy Deploy openember apps in host/target."
echo " -c, clean Delete all build files."
echo " -a, all Rebuild and pack all executable files"
echo " -h, help Display this help and exit"
echo " -v, version Output version information and exit"
echo ""
exit 0
elif [ "$1" == "-v" ] || [ "$1" == "version" ]; then
echo "Script Version: ${VERSION}"
echo "Author: ${AUTHOR}"
echo "E-mail: ${EMAIL}"
exit 0
elif [ "$1" == "-b" ] || [ "$1" == "build" ]; then
RemoveExpiredFiles
BuildProject
elif [ "$1" == "-t" ] || [ "$1" == "test" ]; then
#RemoveExpiredFiles
BuildTest
elif [ "$1" == "-p" ] || [ "$1" == "package" ]; then
#RemoveExpiredFiles
#BuildProject
PackageAll
elif [ "$1" == "-s" ] || [ "$1" == "server" ]; then
#RemoveExpiredFiles
#BuildProject
RunServer
elif [ "$1" == "-d" ] || [ "$1" == "deploy" ]; then
#RemoveExpiredFiles
#BuildProject
DeployHost
elif [ "$1" == "-c" ] || [ "$1" == "clean" ]; then
RemoveExpiredFiles
elif [ "$1" == "-a" ] || [ "$1" == "all" ]; then
RemoveExpiredFiles
BuildProject
BuildTest
PackageAll
#scp ${PACKAGE} board:/tmp/
else
echo "Invalid parameters ($1)"
exit 1
fi
echo "Done!"
exit 0