Skip to content

Commit

Permalink
Changes to move telegraf out of /etc/opt
Browse files Browse the repository at this point in the history
Issue influxdata#264: This attempts to fix the /etc/opt and put the binary
linked into /bin

Note: I can't seem to find the right combination of packages for
getting package.sh to run, so I haven't been able to test this.
  • Loading branch information
linsomniac committed Oct 15, 2015
1 parent 181c3cd commit ebc375c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function log_success_msg() {
name=telegraf

# Daemon name, where is the actual executable
daemon=/opt/telegraf/telegraf
daemon=/bin/telegraf

# pid file for the daemon
pidfile=/var/run/telegraf/telegraf.pid
Expand All @@ -107,7 +107,7 @@ if [ ! -d "$piddir" ]; then
fi

# Configuration file
config=/etc/opt/telegraf/telegraf.conf
config=/etc/telegraf/telegraf.conf

# If the daemon is not there, then exit.
[ -x $daemon ] || exit 5
Expand Down
13 changes: 10 additions & 3 deletions scripts/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
AWS_FILE=~/aws.conf

INSTALL_ROOT_DIR=/opt/telegraf
INSTALL_BIN_DIR=/bin
TELEGRAF_LOG_DIR=/var/log/telegraf
CONFIG_ROOT_DIR=/etc/opt/telegraf
CONFIG_ROOT_DIR=/etc/telegraf
LOGROTATE_DIR=/etc/logrotate.d

SAMPLE_CONFIGURATION=etc/config.sample.toml
Expand Down Expand Up @@ -144,7 +145,6 @@ generate_postinstall_script() {
#!/bin/sh
rm -f $INSTALL_ROOT_DIR/telegraf
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
useradd --help 2>&1| grep -- --system > /dev/null 2>&1
Expand All @@ -168,7 +168,8 @@ else
ln -sfn $INSTALL_ROOT_DIR/versions/$version/scripts/init.sh \
$INSTALL_ROOT_DIR/init.sh
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
# update-rc.d sysv service:
if which update-rc.d > /dev/null 2>&1 ; then
Expand Down Expand Up @@ -211,12 +212,18 @@ make_dir_tree $TMP_WORK_DIR $VERSION
###########################################################################
# Copy the assets to the installation directories.

mkdir -p $TMP_WORK_DIR/$INSTALL_BIN_DIR
for b in ${BINS[*]}; do
cp $GOPATH_INSTALL/bin/$b $TMP_WORK_DIR/$INSTALL_ROOT_DIR/versions/$VERSION
if [ $? -ne 0 ]; then
echo "Failed to copy binaries to packaging directory -- aborting."
cleanup_exit 1
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

echo "${BINS[*]} copied to $TMP_WORK_DIR/$INSTALL_ROOT_DIR/versions/$VERSION"
Expand Down

0 comments on commit ebc375c

Please sign in to comment.