Install & update systemd influxdb service

Closes #3989
Closes #4047
pull/4047/merge
Cameron Sparr 2015-09-08 18:14:03 -06:00
parent a7ba677efd
commit a8c7e2ac04
2 changed files with 32 additions and 11 deletions

View File

@ -44,6 +44,7 @@ LOGROTATE_DIR=/etc/logrotate.d
SAMPLE_CONFIGURATION=etc/config.sample.toml
INITD_SCRIPT=scripts/init.sh
SYSTEMD_SCRIPT=scripts/influxdb.service
LOGROTATE=scripts/logrotate
TMP_WORK_DIR=`mktemp -d`
@ -244,19 +245,29 @@ ln -s $INSTALL_ROOT_DIR/versions/$version/influxd $INSTALL_ROOT_DIR/influxd
ln -s $INSTALL_ROOT_DIR/versions/$version/influx $INSTALL_ROOT_DIR/influx
ln -s $INSTALL_ROOT_DIR/versions/$version/scripts/init.sh $INSTALL_ROOT_DIR/init.sh
rm -f /etc/init.d/influxdb
ln -sfn $INSTALL_ROOT_DIR/init.sh /etc/init.d/influxdb
chmod +x /etc/init.d/influxdb
if which update-rc.d > /dev/null 2>&1 ; then
update-rc.d -f influxdb remove
update-rc.d influxdb defaults
else
chkconfig --add influxdb
fi
if ! id influxdb >/dev/null 2>&1; then
useradd --system -U -M influxdb
fi
# Systemd
if which systemctl > /dev/null 2>&1 ; then
cp $INSTALL_ROOT_DIR/versions/$version/scripts/influxdb.service \
/lib/systemd/system/influxdb.service
systemctl enable influxdb
# Sysv
else
rm -f /etc/init.d/influxdb
ln -sfn $INSTALL_ROOT_DIR/init.sh /etc/init.d/influxdb
chmod +x /etc/init.d/influxdb
if which update-rc.d > /dev/null 2>&1 ; then
update-rc.d -f influxdb remove
update-rc.d influxdb defaults
else
chkconfig --add influxdb
fi
fi
chown -R -L influxdb:influxdb $INSTALL_ROOT_DIR
chmod -R a+rX $INSTALL_ROOT_DIR
@ -310,7 +321,7 @@ do
VERSION_UNDERSCORED=`echo "$VERSION" | tr - _`
shift
else
echo "$1 : aborting version already set to $VERSION"
echo "$1 : aborting version already set to $VERSION"
usage 1
fi
;;
@ -376,6 +387,13 @@ if [ $? -ne 0 ]; then
fi
echo "$INITD_SCRIPT copied to $TMP_WORK_DIR/$INSTALL_ROOT_DIR/versions/$VERSION/scripts"
cp $SYSTEMD_SCRIPT $TMP_WORK_DIR/$INSTALL_ROOT_DIR/versions/$VERSION/scripts
if [ $? -ne 0 ]; then
echo "Failed to copy systemd script to packaging directory -- aborting."
cleanup_exit 1
fi
echo "$SYSTEMD_SCRIPT copied to $TMP_WORK_DIR/$INSTALL_ROOT_DIR/versions/$VERSION/scripts"
cp $SAMPLE_CONFIGURATION $TMP_WORK_DIR/$CONFIG_ROOT_DIR/influxdb.conf
if [ $? -ne 0 ]; then
echo "Failed to copy $SAMPLE_CONFIGURATION to packaging directory -- aborting."

View File

@ -2,6 +2,7 @@
[Unit]
Description=InfluxDB is an open-source, distributed, time series database
Documentation=https://influxdb.com/docs/
After=network.target
[Service]
@ -10,7 +11,9 @@ Group=influxdb
LimitNOFILE=65536
EnvironmentFile=-/etc/default/influxdb
ExecStart=/opt/influxdb/influxd -config /etc/opt/influxdb/influxdb.conf $INFLUXD_OPTS
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
Alias=influxd.service