forked from porcupie/rbd-docker-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
postinstall
executable file
·45 lines (36 loc) · 1.32 KB
/
postinstall
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
#!/bin/bash
set -e
set -u
# rbd-docker-plugin postinstall
SYSTEMD_SERVICE=rbd-docker-plugin.service
SYSTEMD_CONF=$TPKG_HOME/etc/systemd/system/$SYSTEMD_SERVICE
UPSTART_CONF=$TPKG_HOME/etc/init/rbd-docker-plugin.conf
LOGROTATE_CONF=$TPKG_HOME/etc/logrotate.d/rbd-docker-plugin_logrotate
CRON_JOB=$TPKG_HOME/etc/cron.d/rbd-docker-plugin-checks
# do some replacements to make this tpkg more relocatable
if [ "$TPKG_HOME" != "/home/ops" ]; then
sed -i.orig -e "s|/home/ops|$TPKG_HOME|g" "$SYSTEMD_CONF"
sed -i.orig -e "s|/home/ops|$TPKG_HOME|g" "$UPSTART_CONF"
sed -i.orig -e "s|/home/ops|$TPKG_HOME|g" "$CRON_JOB"
fi
# centos 7.x / systemd
if UNIT_DIR=$(pkg-config systemd --variable=systemdsystemunitdir); then
# copy the systemd .service (symlink won't work here)
install -m 0644 -v "$SYSTEMD_CONF" "${UNIT_DIR}/${SYSTEMD_SERVICE}"
# enable and start it
systemctl enable ${SYSTEMD_SERVICE}
systemctl start ${SYSTEMD_SERVICE}
else
# centos 6 / upstart
# link the /etc/init configuration file
ln -s "$UPSTART_CONF" /etc/init/rbd-docker-plugin.conf
start rbd-docker-plugin
fi
# logrotate config
if test -d /etc/logrotate.d ; then
install -m 0644 -v "$LOGROTATE_CONF" /etc/logrotate.d/.
fi
# cron job for checks
if [ -f "$CRON_JOB" ]; then
install -m 0644 -v "$CRON_JOB" /etc/cron.d/.
fi