-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathredis.bits
More file actions
69 lines (51 loc) · 1.26 KB
/
redis.bits
File metadata and controls
69 lines (51 loc) · 1.26 KB
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
#!/bin/bash
#-----------
# VARIABLES
#-----------
REDIS_VERSION=${REDIS_VERSION-stable}
#-----------
# HELPERS
#-----------
set_env()
{
KEY=$1
VAL=$2
echo "export $KEY=$VAL" >> $HOME/.bash_aliases
}
#-----------
# INSTALLER
#-----------
RC=$(echo "$REDIS_VERSION" | sed "s/^.*-\(.*\)[0-9]\+$/\1/")
if [[ "$RC" == "rc" || $REDIS_VERSION == "unstable" ]]; then
FILENAME=${REDIS_VERSION}.tar.gz
URL=https://github.com/antirez/redis/archive/${FILENAME}
else
FILENAME=redis-${REDIS_VERSION}.tar.gz
URL=http://download.redis.io/releases/${FILENAME}
fi
(mkdir -p /opt/redis && \
cd /opt/redis && \
apt-get update && \
apt-get install -f -y && \
apt-get install -y wget g++ make && \
wget $URL
tar xvzf ${FILENAME}
cd redis-${REDIS_VERSION}
make)
printf "%b" "
[Unit]
Description=redis-server
[Service]
WorkingDirectory=/opt/redis/redis-${REDIS_VERSION}
ExecStart=/opt/redis/redis-${REDIS_VERSION}/src/redis-server
TimeoutSec=600
StandardOutput=file:/var/log/redis-${REDIS_VERSION}.log
StandardError=file:/var/log/redis-${REDIS_VERSION}.log
User=root
Restart=always
[Install]
WantedBy=multi-user.target
" > /etc/systemd/system/redis-server.service
set_env PATH "/opt/redis/redis-${REDIS_VERSION}/src:\$PATH"
source $HOME/.bash_aliases
touch /opt/redis.bits