forked from yp-engineering/rbd-docker-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
postinstall
executable file
·35 lines (30 loc) · 1.1 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
#!/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
# 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"
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