-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathuninstall
executable file
·62 lines (53 loc) · 1.7 KB
/
uninstall
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
#!/bin/sh
### BEGIN ###
# Author: idevz
# Since: 2018/03/12
# Description: Motan OpenResty uninstallation
### END ###
set -x -e
# base conf
MOTAN_SRC_ROOT=$(dirname $(cd $(dirname "$0") && pwd -P)/$(basename "$0"))
BUILD=${MOTAN_SRC_ROOT}/build
mkdir -p ${BUILD}
# OpenResty ROOT
OR=openresty
TMP=${BUILD}/tmp
OR_ROOT=$(${OR} -V &>${TMP} && cat ${TMP} |
grep prefix | grep -Eo 'prefix=(.*?)/nginx' | grep -Eo '/.*/')
SITE_LUALIB_ROOT=${OR_ROOT}/site/lualib
rm ${TMP}
doRequire() {
DEPENDENCES='
https://github.com/pintsized/lua-resty-http/archive/v0.12.tar.gz
https://github.com/idevz/lua-resty-timer/archive/v0.0.1.tar.gz
https://github.com/hamishforbes/lua-resty-consul/archive/v0.2.tar.gz
'
REQUIRE=${MOTAN_SRC_ROOT}/build/require
mkdir -p $REQUIRE/src
mkdir -p $REQUIRE/resty
for dep in ${DEPENDENCES}; do
if echo $dep | grep -q "\.git"; then
cd $REQUIRE/src
git clone $dep
cp -fR lua-resty-timer/lib/resty/* $REQUIRE/resty/
else
cd $REQUIRE/src
FILE_NAME=$(echo $dep | sed 's/.*\(lua-resty[^\/]*\)\/.*/\1/g')
wget --no-check-certificate $dep -O $FILE_NAME
tar zxf $FILE_NAME
cp -fR $FILE_NAME*/lib/resty/* $REQUIRE/resty/
fi
done
}
# dependence:
echo "start uninstall motan dependences libs."
echo "get motan dependences libs."
doRequire
for lua_file in $(ls ${MOTAN_SRC_ROOT}/build/require/resty); do
[[ $(cat ${SITE_LUALIB_ROOT}/resty/${lua_file} | sha1sum) == $(cat ${MOTAN_SRC_ROOT}/build/require/resty/${lua_file} | sha1sum) ]] && $(rm ${SITE_LUALIB_ROOT}/resty/${lua_file})
done
echo "uninstall motan dependences libs get done."
echo "start uninstall motan dependences libs."
rm -rf ${BUILD}
rm -rf ${SITE_LUALIB_ROOT}/motan
echo "uninstall motan success."