summaryrefslogtreecommitdiffstats
path: root/packer/provision/redis.sh
blob: c940c0ac816056d74ae73ba85f1bfe6b53f9ef58 (plain)
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
#!/bin/bash
# This particular environment was created specifically for vfc-nfvo-lcm

# vim: ts=4 sw=4 sts=4 et tw=72 :

# force any errors to cause the script and job to end in failure
set -xeu -o pipefail

rh_systems() {
    # redis
    yum install -y redis
    systemctl enable redis.service
}

ubuntu_systems() {
    # redis

    # 1. download and install redis
    cd /tmp
    wget http://download.redis.io/releases/redis-4.0.1.tar.gz
    tar -zxf redis-4.0.1.tar.gz
    cd /tmp/redis-4.0.1
    make
    make install

    # 2. set conf file and init script
    cp /tmp/redis-4.0.1/src/redis-server /etc/init.d/redis-server
    chmod +x /etc/init.d/redis-server
    cp /tmp/redis-4.0.1/redis.conf /etc/redis.conf

    # 3. set auto start when start system
    update-rc.d redis-server defaults
}

all_systems() {
    echo 'No common distribution configuration to perform'
}

echo "---> Detecting OS"
ORIGIN=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')

case "${ORIGIN}" in
    fedora|centos|redhat)
        echo "---> RH type system detected"
        rh_systems
    ;;
    ubuntu)
        echo "---> Ubuntu system detected"
        ubuntu_systems
    ;;
    *)
        echo "---> Unknown operating system"
    ;;
esac

# execute steps for all systems
all_systems