Skip to content

Commit

Permalink
Added beatname.sh in /usr/bin (#1446)
Browse files Browse the repository at this point in the history
For Deb and Rpm installations. This makes it easy to run the Beat in foreground, while still being executed with the write paths.

* Fix postinst script
* Added beatname.sh in /usr/bin

Part of #1371.
  • Loading branch information
tsg authored and ruflin committed Apr 21, 2016
1 parent eb4bd44 commit 0a0294a
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 3 deletions.
11 changes: 11 additions & 0 deletions dev-tools/packer/platforms/centos/beatname.sh.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Script to run {.beat_name} in foreground with the same path settings that
# the init script / systemd unit file would do.

/usr/share/{{.beat_name}}/bin/{{.beat_name}} -e \
-c /etc/{{.beat_name}}/{{.beat_name}}.yml \
-path.home /usr/share/{{.beat_name}} \
-path.config /etc/{{.beat_name}} \
-path.data /var/lib/{{.beat_name}} \
$@
4 changes: 3 additions & 1 deletion dev-tools/packer/platforms/centos/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ runid=centos-$BEAT-$ARCH

cat beats/$BEAT.yml ${ARCHDIR}/archs/$ARCH.yml version.yml > build/settings-$runid.yml
gotpl ${BASEDIR}/run.sh.j2 < build/settings-$runid.yml > build/run-$runid.sh
chmod +x build/run-$runid.sh
gotpl ${BASEDIR}/init.j2 < build/settings-$runid.yml > build/$runid.init
gotpl ${BASEDIR}/systemd.j2 < build/settings-$runid.yml > build/$runid.service
chmod +x build/run-$runid.sh
gotpl ${BASEDIR}/beatname.sh.j2 < build/settings-$runid.yml > build/beatname-$runid.sh
chmod +x build/beatname-$runid.sh

docker run --rm -v `pwd`/build:/build \
-e BUILDID=$BUILDID -e SNAPSHOT=$SNAPSHOT -e RUNID=$runid \
Expand Down
1 change: 1 addition & 0 deletions dev-tools/packer/platforms/centos/run.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ fpm --force -s dir -t rpm \
--after-install /tmp/systemd-daemon-reload.sh \
--config-files /etc/{{.beat_name}}/{{.beat_name}}.yml \
homedirs/{{.beat_name}}=/usr/share/ \
beatname-${RUNID}.sh=/usr/bin/{{.beat_name}}.sh \
{{.beat_name}}-linux-{{.arch}}=/usr/share/{{.beat_name}}/bin/{{.beat_name}} \
{{.beat_name}}-linux.yml=/etc/{{.beat_name}}/{{.beat_name}}.yml \
{{.beat_name}}.template.json=/etc/{{.beat_name}}/{{.beat_name}}.template.json \
Expand Down
11 changes: 11 additions & 0 deletions dev-tools/packer/platforms/debian/beatname.sh.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Script to run {.beat_name} in foreground with the same path settings that
# the init script / systemd unit file would do.

/usr/share/{{.beat_name}}/bin/{{.beat_name}} -e \
-c /etc/{{.beat_name}}/{{.beat_name}}.yml \
-path.home /usr/share/{{.beat_name}} \
-path.config /etc/{{.beat_name}} \
-path.data /var/lib/{{.beat_name}} \
$@
4 changes: 3 additions & 1 deletion dev-tools/packer/platforms/debian/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ runid=debian-$BEAT-$ARCH

cat beats/$BEAT.yml ${ARCHDIR}/archs/$ARCH.yml version.yml > build/settings-$runid.yml
gotpl ${BASEDIR}/run.sh.j2 < build/settings-$runid.yml > build/run-$runid.sh
chmod +x build/run-$runid.sh
gotpl ${BASEDIR}/init.j2 < build/settings-$runid.yml > build/$runid.init
gotpl ${BASEDIR}/systemd.j2 < build/settings-$runid.yml > build/$runid.service
chmod +x build/run-$runid.sh
gotpl ${BASEDIR}/beatname.sh.j2 < build/settings-$runid.yml > build/beatname-$runid.sh
chmod +x build/beatname-$runid.sh

docker run --rm -v `pwd`/build:/build \
-e BUILDID=$BUILDID -e SNAPSHOT=$SNAPSHOT -e RUNID=$runid \
Expand Down
3 changes: 2 additions & 1 deletion dev-tools/packer/platforms/debian/run.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ fpm --force -s dir -t deb \
--after-install /tmp/systemd-daemon-reload.sh \
--config-files /etc/{{.beat_name}}/{{.beat_name}}.yml \
homedirs/{{.beat_name}}=/usr/share/ \
beatname-${RUNID}.sh=/usr/bin/{{.beat_name}}.sh \
{{.beat_name}}-linux-{{.arch}}=/usr/share/{{.beat_name}}/bin/{{.beat_name}} \
{{.beat_name}}-linux.yml=/etc/{{.beat_name}}/{{.beat_name}}.yml \
{{.beat_name}}.template.json=/etc/{{.beat_name}}/{{.beat_name}}.template.json \
${RUNID}.service=/lib/systemd/system/{{.beat_name}}.service \
god-linux-{{.arch}}=/usr/share/{{.beat_name}}/bin/{{.beat_name}}-god
god-linux-{{.arch}}=/usr/share/{{.beat_name}}/bin/{{.beat_name}}-god

# move and rename so that the filename respects semver rules
mkdir -p upload/{{.beat_name}}
Expand Down

0 comments on commit 0a0294a

Please sign in to comment.