forked from RedisJSON/RedisJSON
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-redisearch
executable file
·118 lines (100 loc) · 2.98 KB
/
get-redisearch
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
#!/bin/bash
PROGNAME="${BASH_SOURCE[0]}"
HERE="$(cd "$(dirname "$PROGNAME")" &>/dev/null && pwd)"
ROOT=$(cd $HERE/.. && pwd)
READIES=$ROOT/deps/readies
. $READIES/shibumi/defs
if [[ $1 == --help || $1 == help || $HELP == 1 ]]; then
cat <<-END
Get RediSearch module binaries
get-redisearch [--help|help]
Argument variables:
OSNICK=nick Get binaries for given osnick
BRANCH=name Use given branch
REPO_PATH=dir Get binaries from given repo path
FORCE=1 Download module even if already present
NOP=1 No operation
HELP=1 Show help
END
exit 0
fi
BRANCH=${BRANCH:-master}
if [[ $BRANCH == edge ]]; then
BRANCH=master
fi
OP=""
[[ $NOP == 1 ]] && OP=echo
os="$($READIES/bin/platform --os)"
arch="$($READIES/bin/platform --arch)"
if [[ ! -z $REPO_PATH ]]; then
platform="$($READIES/bin/platform -t)"
else
if [[ $os != linux && $os != macos || $arch != x64 ]]; then
eprint "Cannot match binary artifacts - build RediSearch and set REPO_PATH"
exit 1
fi
dist="$($READIES/bin/platform --dist)"
nick="$($READIES/bin/platform --osnick)"
[[ $os == linux ]] && os=Linux
[[ $arch == x64 ]] && arch=x86_64
if [[ $dist == ubuntu ]]; then
if [[ $nick == focal ]]; then
nick="ubuntu20.04"
elif [[ $nick == bionic ]]; then
nick="ubuntu18.04"
elif [[ $nick == xenial ]]; then
nick="ubuntu16.04"
elif [[ $nick == trusty ]]; then
nick="ubuntu14.04"
fi
elif [[ $dist == debian ]]; then
if [[ $nick != bullseye ]]; then
nick=ubuntu18.04
fi
elif [[ $dist == centos || $dist == redhat || $dist == fedora || $dist == ol ]]; then
if [[ $nick == centos8 || $nick == ol8 || $nick == rocky8 ]]; then
nick="rhel8"
else
nick="rhel7"
fi
else
nick="$($READIES/bin/platform --osnick)"
fi
platform="${os}-${nick}-${arch}"
fi
MOD_S3_URL="https://redismodules.s3.amazonaws.com/redisearch-oss/snapshots"
MOD_RAMP="redisearch-oss.${platform}.${BRANCH}.zip"
DEST_DIR="$ROOT/bin/$($READIES/bin/platform -t)/RediSearch"
if [[ $FORCE != 1 && -d $DEST_DIR && -f $DEST_DIR/redisearch.so ]]; then
echo "RediSearch is in ${DEST_DIR}:"
$OP du -ah --apparent-size $DEST_DIR
exit 0
fi
$OP mkdir -p $(dirname ${DEST_DIR})
WORK_DIR=$(mktemp -d /tmp/redisearch.XXXXXX)
if [[ -z $REPO_PATH ]]; then
F_MOD_RAMP="${WORK_DIR}/${MOD_RAMP}"
if [[ $FORCE == 1 || ! -f $F_MOD_RAMP ]]; then
echo "Download RediSearch [${MOD_S3_URL}/${MOD_RAMP}] ..."
runn wget -P ${WORK_DIR} ${MOD_S3_URL}/${MOD_RAMP}
fi
else
F_MOD_RAMP="${REPO_PATH}/artifacts/snapshots/${MOD_RAMP}"
if [[ ! -f $F_MOD_RAMP ]]; then
eprint "$F_MOD_RAMP is missing - build RediSearch and set REPO_PATH"
exit 1
fi
fi
runn unzip $F_MOD_RAMP -d $WORK_DIR
if [[ -e ${DEST_DIR} ]]; then
echo "Removing existing ${DEST_DIR}"
$OP rm -rf ${DEST_DIR}
fi
# $OP mv $WORK_DIR $DEST_DIR
runn rsync -a --no-owner --no-group --remove-source-files $WORK_DIR/* $DEST_DIR
echo "RediSearch installed into ${DEST_DIR}:"
if [[ $os == linux ]]; then
$OP du -ah --apparent-size $DEST_DIR
else
$OP du -ah $DEST_DIR
fi