Merge "Jenkis job for apigateway and discovery dockers"
[ci-management.git] / packer / provision / redis.sh
1 #!/bin/bash
2 # This particular environment was created specifically for vfc-nfvo-lcm
3
4 # vim: ts=4 sw=4 sts=4 et tw=72 :
5
6 # force any errors to cause the script and job to end in failure
7 set -xeu -o pipefail
8
9 rh_systems() {
10     # redis
11     yum install -y redis
12     systemctl enable redis.service
13 }
14
15 ubuntu_systems() {
16     # redis
17
18     # 1. download and install redis
19     cd /tmp
20     wget http://download.redis.io/releases/redis-4.0.1.tar.gz
21     tar -zxf redis-4.0.1.tar.gz
22     cd /tmp/redis-4.0.1
23     make
24     make install
25
26     # 2. set conf file and init script
27     cp /tmp/redis-4.0.1/src/redis-server /etc/init.d/redis-server
28     chmod +x /etc/init.d/redis-server
29     cp /tmp/redis-4.0.1/redis.conf /etc/redis.conf
30
31     # 3. set auto start when start system
32     update-rc.d redis-server defaults
33 }
34
35 all_systems() {
36     echo 'No common distribution configuration to perform'
37 }
38
39 echo "---> Detecting OS"
40 ORIGIN=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
41
42 case "${ORIGIN}" in
43     fedora|centos|redhat)
44         echo "---> RH type system detected"
45         rh_systems
46     ;;
47     ubuntu)
48         echo "---> Ubuntu system detected"
49         ubuntu_systems
50     ;;
51     *)
52         echo "---> Unknown operating system"
53     ;;
54 esac
55
56 # execute steps for all systems
57 all_systems