forked from influxdata/kapacitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost-install.sh
76 lines (66 loc) · 1.84 KB
/
post-install.sh
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
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
BIN_DIR=/usr/bin
DATA_DIR=/var/lib/kapacitor
LOG_DIR=/var/log/kapacitor
SCRIPT_DIR=/usr/lib/kapacitor/scripts
function install_init {
cp -f $SCRIPT_DIR/init.sh /etc/init.d/kapacitor
chmod +x /etc/init.d/kapacitor
}
function install_systemd {
cp -f $SCRIPT_DIR/kapacitor.service /lib/systemd/system/kapacitor.service
}
function enable_systemd {
systemctl enable kapacitor
}
function enable_update_rcd {
update-rc.d kapacitor defaults
}
function enable_chkconfig {
chkconfig --add kapacitor
}
if ! id kapacitor >/dev/null 2>&1; then
useradd --system -U -M kapacitor -s /bin/false -d $DATA_DIR
fi
chmod a+rX $BIN_DIR/kapacitor*
test -f /etc/default/kapacitor || touch /etc/default/kapacitor
# Distribution-specific logic
if [[ -f /etc/redhat-release ]]; then
# RHEL-variant logic
if [[ "$(readlink /proc/1/exe)" == */systemd ]]; then
install_systemd
# Do not enable service
else
# Assuming SysV
install_init
# Do not enable service
fi
else
mkdir -p $LOG_DIR
chown -R -L kapacitor:kapacitor $LOG_DIR
mkdir -p $DATA_DIR
chown -R -L kapacitor:kapacitor $DATA_DIR
if [[ -f /etc/debian_version ]]; then
# Debian/Ubuntu logic
if [[ "$(readlink /proc/1/exe)" == */systemd ]]; then
install_systemd
enable_systemd
else
# Assuming SysV
install_init
# Run update-rc.d or fallback to chkconfig if not available
if which update-rc.d &>/dev/null; then
enable_update_rcd
else
enable_chkconfig
fi
fi
elif [[ -f /etc/os-release ]]; then
source /etc/os-release
if [[ $ID = "amzn" ]]; then
# Amazon Linux logic
install_init
# Do not enable service
fi
fi
fi