-
Notifications
You must be signed in to change notification settings - Fork 0
/
01-install
executable file
·61 lines (52 loc) · 1.56 KB
/
01-install
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
#!/bin/sh
# source common functions; exit if missing
if [[ -f ${UKWACOMMONDIR}/common.sh ]]; then source ${UKWACOMMONDIR}/common.sh; else echo "ERROR: ${UKWACOMMONDIR}/common.sh missing"; exit 1; fi
NOPREFIX=1
DEBUG=
SERVICE=redis
USER=$(id --user --name)
BASEDIR=/opt
REDISDATADIR=${BASEDIR}/${SERVICE}
REDISCFGDIR=/etc/${SERVICE}
REDISLOGDIR=/var/log/${SERVICE}
# functions ----------
function install_redis {
log DEBUG "install_redis"
if ! [[ $(which redis-server 2> /dev/null) ]]; then
log INFO "Installing redis"
sudo dnf install -y redis
sudo usermod -aG redis ${USER}
else
log WARNING "redis already installed"
fi
# directories, permissions
[[ -d ${REDISDATADIR} ]] || sudo mkdir -p ${REDISDATADIR}
[[ -d ${REDISCFGDIR} ]] || sudo mkdir -p ${REDISCFGDIR}
[[ -d ${REDISLOGDIR} ]] || sudo mkdir -p ${REDISLOGDIR}
if ! [[ -d /etc/redis/_original/ ]]; then
log INFO "Removing redis defaults"
sudo mkdir /etc/redis/_original
sudo mv /etc/redis/* /etc/redis/_original/ 2> /dev/null
fi
}
function amend_permissions {
log DEBUG "amend_permissions"
sudo chown -R redis:redis ${REDISDATADIR} ${REDISCFGDIR} ${REDISLOGDIR}
}
function configure_selinux {
log DEBUG "configure_selinux"
log INFO "Add redis ${REDISDATADIR} policy"
sudo semanage fcontext -a -t redis_var_lib_t ${REDISDATADIR}'(/.*)?'
echo
log DEBUG "restore_redis_selinux"
sudo restorecon -R ${REDISDATADIR}
sudo restorecon -R ${REDISCFGDIR}
sudo restorecon -R ${REDISLOGDIR}
}
# script -------------
ensure_not_root
install_redis
copy_directory fs
amend_permissions
configure_selinux
log_stop