This commit is contained in:
Sean Reifschneider 2015-10-21 18:11:32 +00:00
commit 3fe94ea033
4 changed files with 15 additions and 8 deletions

View File

@ -36,8 +36,8 @@ Latest:
##### Package instructions: ##### Package instructions:
* Telegraf binary is installed in `/opt/telegraf/telegraf` * Telegraf binary is installed in `/usr/bin/telegraf`
* Telegraf daemon configuration file is in `/etc/opt/telegraf/telegraf.conf` * Telegraf daemon configuration file is in `/etc/telegraf/telegraf.conf`
* On sysv systems, the telegraf daemon can be controlled via * On sysv systems, the telegraf daemon can be controlled via
`service telegraf [action]` `service telegraf [action]`
* On systemd systems (such as Ubuntu 15+), the telegraf daemon can be * On systemd systems (such as Ubuntu 15+), the telegraf daemon can be

View File

@ -98,7 +98,7 @@ function log_success_msg() {
name=telegraf name=telegraf
# Daemon name, where is the actual executable # Daemon name, where is the actual executable
daemon=/opt/telegraf/telegraf daemon=/usr/bin/telegraf
# pid file for the daemon # pid file for the daemon
pidfile=/var/run/telegraf/telegraf.pid pidfile=/var/run/telegraf/telegraf.pid
@ -110,7 +110,7 @@ if [ ! -d "$piddir" ]; then
fi fi
# Configuration file # Configuration file
config=/etc/opt/telegraf/telegraf.conf config=/etc/telegraf/telegraf.conf
# If the daemon is not there, then exit. # If the daemon is not there, then exit.
[ -x $daemon ] || exit 5 [ -x $daemon ] || exit 5

View File

@ -32,8 +32,9 @@
AWS_FILE=~/aws.conf AWS_FILE=~/aws.conf
INSTALL_ROOT_DIR=/opt/telegraf INSTALL_ROOT_DIR=/opt/telegraf
INSTALL_BIN_DIR=/usr/bin
TELEGRAF_LOG_DIR=/var/log/telegraf TELEGRAF_LOG_DIR=/var/log/telegraf
CONFIG_ROOT_DIR=/etc/opt/telegraf CONFIG_ROOT_DIR=/etc/telegraf
LOGROTATE_DIR=/etc/logrotate.d LOGROTATE_DIR=/etc/logrotate.d
SAMPLE_CONFIGURATION=etc/config.sample.toml SAMPLE_CONFIGURATION=etc/config.sample.toml
@ -144,7 +145,6 @@ generate_postinstall_script() {
#!/bin/sh #!/bin/sh
rm -f $INSTALL_ROOT_DIR/telegraf rm -f $INSTALL_ROOT_DIR/telegraf
rm -f $INSTALL_ROOT_DIR/init.sh rm -f $INSTALL_ROOT_DIR/init.sh
ln -sfn $INSTALL_ROOT_DIR/versions/$version/telegraf $INSTALL_ROOT_DIR/telegraf
if ! id telegraf >/dev/null 2>&1; then if ! id telegraf >/dev/null 2>&1; then
useradd --help 2>&1| grep -- --system > /dev/null 2>&1 useradd --help 2>&1| grep -- --system > /dev/null 2>&1
@ -168,7 +168,8 @@ else
ln -sfn $INSTALL_ROOT_DIR/versions/$version/scripts/init.sh \ ln -sfn $INSTALL_ROOT_DIR/versions/$version/scripts/init.sh \
$INSTALL_ROOT_DIR/init.sh $INSTALL_ROOT_DIR/init.sh
rm -f /etc/init.d/telegraf rm -f /etc/init.d/telegraf
ln -sfn $INSTALL_ROOT_DIR/init.sh /etc/init.d/telegraf ln -sfn $INSTALL_ROOT_DIR/versions/$version/scripts/init.sh \
/etc/init.d/telegraf
chmod +x /etc/init.d/telegraf chmod +x /etc/init.d/telegraf
# update-rc.d sysv service: # update-rc.d sysv service:
if which update-rc.d > /dev/null 2>&1 ; then if which update-rc.d > /dev/null 2>&1 ; then
@ -211,12 +212,18 @@ make_dir_tree $TMP_WORK_DIR $VERSION
########################################################################### ###########################################################################
# Copy the assets to the installation directories. # Copy the assets to the installation directories.
mkdir -p $TMP_WORK_DIR/$INSTALL_BIN_DIR
for b in ${BINS[*]}; do for b in ${BINS[*]}; do
cp $GOPATH_INSTALL/bin/$b $TMP_WORK_DIR/$INSTALL_ROOT_DIR/versions/$VERSION cp $GOPATH_INSTALL/bin/$b $TMP_WORK_DIR/$INSTALL_ROOT_DIR/versions/$VERSION
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to copy binaries to packaging directory -- aborting." echo "Failed to copy binaries to packaging directory -- aborting."
cleanup_exit 1 cleanup_exit 1
fi fi
ln -s /$INSTALL_ROOT_DIR/versions/$VERSION $TMP_WORK_DIR/$INSTALL_BIN_DIR
if [ $? -ne 0 ]; then
echo "Failed to link binaries to packaging directory -- aborting."
cleanup_exit 1
fi
done done
echo "${BINS[*]} copied to $TMP_WORK_DIR/$INSTALL_ROOT_DIR/versions/$VERSION" echo "${BINS[*]} copied to $TMP_WORK_DIR/$INSTALL_ROOT_DIR/versions/$VERSION"

View File

@ -6,7 +6,7 @@ After=network.target
[Service] [Service]
EnvironmentFile=-/etc/default/telegraf EnvironmentFile=-/etc/default/telegraf
User=telegraf User=telegraf
ExecStart=/opt/telegraf/telegraf -config /etc/opt/telegraf/telegraf.conf $TELEGRAF_OPTS ExecStart=/usr/bin/telegraf -config /etc/telegraf/telegraf.conf $TELEGRAF_OPTS
Restart=on-failure Restart=on-failure
KillMode=process KillMode=process