|
1 | | -if [ -z ${OS+x} ] |
2 | | -then |
3 | | - echo "os is not set" |
4 | | - exit 1 |
5 | | -fi |
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" |
| 4 | +ROOT=$(cd $HERE/../..; pwd) |
| 5 | +READIES=$ROOT/opt/readies |
| 6 | +. $READIES/shibumi/defs |
6 | 7 |
|
7 | | -echo "installing redisgears for :" $OS |
| 8 | +if [[ $1 == --help || $1 == help || $HELP == 1 ]]; then |
| 9 | + cat <<-END |
| 10 | + Obtain RedisGears module binaries |
8 | 11 |
|
9 | | -WORK_DIR=./bin/RedisGears/ |
10 | | -REDISGEARS_ZIP=redisgears.linux-$OS-x64.master.zip |
11 | | -REDISGEARS_DEPS=redisgears-python.linux-$OS-x64.master.tgz |
12 | | -REDISGEARS_S3_PATH=http://redismodules.s3.amazonaws.com/redisgears/snapshots/$REDISGEARS_ZIP |
13 | | -REDISGEARS_DEPS_S3_PATH=http://redismodules.s3.amazonaws.com/redisgears/snapshots/$REDISGEARS_DEPS |
| 12 | + Install_RedisGears.sh [--help|help] |
| 13 | + |
| 14 | + Argument variables: |
| 15 | + GEARS_OSNICK=nick Get binaries for give osnick |
| 16 | + GEARS_PATH=dir Get binaries from given Gears repo |
| 17 | + NOP=1 No operation |
| 18 | + HELP=1 Show help |
| 19 | +
|
| 20 | + END |
| 21 | + exit 0 |
| 22 | +fi |
14 | 23 |
|
15 | | -mkdir -p $WORK_DIR |
| 24 | +OP="" |
| 25 | +[[ $NOP == 1 ]] && OP=echo |
16 | 26 |
|
17 | | -if [ -f "$WORK_DIR$REDISGEARS_ZIP" ]; then |
18 | | - echo "Skiping RedisGears download" |
| 27 | +os=$($READIES/bin/platform --os) |
| 28 | +arch=$($READIES/bin/platform --arch) |
| 29 | + |
| 30 | +if [[ ! -z $GEARS_PATH ]]; then |
| 31 | + platform=$($READIES/bin/platform -t) |
19 | 32 | else |
20 | | - echo "Download RedisGears" |
21 | | - wget -P $WORK_DIR $REDISGEARS_S3_PATH |
22 | | - unzip $WORK_DIR$REDISGEARS_ZIP -d $WORK_DIR |
| 33 | + if [[ $os != linux || $arch != x64 ]]; then |
| 34 | + eprint "Cannot match binary artifacts - build RedisGears and set GEARS_PATH" |
| 35 | + exit 1 |
| 36 | + fi |
| 37 | + |
| 38 | + dist=$($READIES/bin/platform --dist) |
| 39 | + nick=$($READIES/bin/platform --osnick) |
| 40 | + |
| 41 | + if [[ $dist == ubuntu ]]; then |
| 42 | + if [[ $nick != bionic && $nick != xenial && $nick != trusty ]]; then |
| 43 | + nick=bionic |
| 44 | + fi |
| 45 | + elif [[ $dist == debian ]]; then |
| 46 | + nick=bionic |
| 47 | + elif [[ $dist == centos || $dist == redhat || $dist == fedora ]]; then |
| 48 | + nick=centos7 |
| 49 | + elif [[ ! -z $GEARS_OSNICK ]]; then |
| 50 | + nick="$GEARS_OSNICK" |
| 51 | + else |
| 52 | + eprint "Cannot match binary artifacts - build RedisGears and set GEARS_PATH" |
| 53 | + exit 1 |
| 54 | + fi |
| 55 | + platform="${os}-${nick}-${arch}" |
23 | 56 | fi |
24 | 57 |
|
25 | | -if [ -f "$WORK_DIR$REDISGEARS_DEPS" ]; then |
26 | | - echo "Skiping RedisGears download" |
| 58 | +GEARS_S3_URL=http://redismodules.s3.amazonaws.com/redisgears/snapshots |
| 59 | +GEARS_MOD=redisgears.$platform.master.zip |
| 60 | +GEARS_DEPS=redisgears-python.$platform.master.tgz |
| 61 | + |
| 62 | +FINAL_WORK_DIR=$ROOT/bin/$($READIES/bin/platform -t)/RedisGears |
| 63 | + |
| 64 | +if [[ -d $FINAL_WORK_DIR && -f $FINAL_WORK_DIR/redisgears.so ]]; then |
| 65 | + echo "RedisGears is in $FINAL_WORK_DIR" |
| 66 | + exit 0 |
| 67 | +fi |
| 68 | + |
| 69 | +$OP rm -rf ${FINAL_WORK_DIR}.* |
| 70 | +WORK_DIR=$(mktemp -d ${FINAL_WORK_DIR}.XXXXXX) |
| 71 | +$OP mkdir -p $WORK_DIR |
| 72 | + |
| 73 | +if [[ -z $GEARS_PATH ]]; then |
| 74 | + F_GEARS_MOD=$WORK_DIR/$GEARS_MOD |
| 75 | + if [[ ! -f $F_GEARS_MOD ]]; then |
| 76 | + echo "Download RedisGears ..." |
| 77 | + $OP wget -q -P $WORK_DIR $GEARS_S3_URL/$GEARS_MOD |
| 78 | + fi |
| 79 | + |
| 80 | + F_GEARS_DEPS=$WORK_DIR/$GEARS_DEPS |
| 81 | + if [[ ! -f $F_GEARS_DEPS ]]; then |
| 82 | + echo "Download RedisGears deps ..." |
| 83 | + $OP wget -q -P $WORK_DIR $GEARS_S3_URL/$GEARS_DEPS |
| 84 | + fi |
27 | 85 | else |
28 | | - echo "Download RedisGears deps" |
29 | | - wget -P $WORK_DIR $REDISGEARS_DEPS_S3_PATH |
30 | | - tar -C $WORK_DIR -xvf $WORK_DIR$REDISGEARS_DEPS |
| 86 | + F_GEARS_MOD=$GEARS_PATH/artifacts/snapshot/$GEARS_MOD |
| 87 | + F_GEARS_DEPS=$GEARS_PATH/artifacts/snapshot/$GEARS_DEPS |
| 88 | + [[ ! -f $F_GEARS_MOD ]] && { eprint "$F_GEARS_MOD is missing"; exit 1; } |
| 89 | + [[ ! -f $F_GEARS_DEPS ]] && { eprint "$F_GEARS_DEPS is missing"; exit 1; } |
31 | 90 | fi |
| 91 | + |
| 92 | +$OP unzip -q $F_GEARS_MOD -d $WORK_DIR |
| 93 | +$OP tar --no-same-owner -C $WORK_DIR -xzf $F_GEARS_DEPS |
| 94 | +$OP mv $WORK_DIR $FINAL_WORK_DIR |
0 commit comments