diff --git a/.gitignore b/.gitignore index 5f1683da631..e84bbac87aa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ .*.swp *.gem +pkg/*.deb +pkg/*.rpm *.class .rbx Gemfile.lock diff --git a/Makefile b/Makefile index 2f3d7de5c7d..e2be3dfaf98 100644 --- a/Makefile +++ b/Makefile @@ -66,6 +66,7 @@ clean: -$(QUIET)rm -rf .bundle -$(QUIET)rm -rf build -$(QUIET)rm -rf vendor + -$(QUIET)rm -f pkg/*.deb .PHONY: compile compile: compile-grammar compile-runner | build/ruby diff --git a/pkg/build.sh b/pkg/build.sh index 9f971616ff8..42b83d574ab 100755 --- a/pkg/build.sh +++ b/pkg/build.sh @@ -49,21 +49,26 @@ case $os@$release in install -m755 logstash.sysv.redhat $destdir/etc/init.d/logstash ;; ubuntu@*) + mkdir -p $destdir/etc/logstash/conf.d mkdir -p $destdir/etc/logrotate.d mkdir -p $destdir/etc/init mkdir -p $destdir/var/log/logstash - mkdir -p $destdir/etc/sysconfig - touch $destdir/etc/sysconfig/logstash - install -m644 logrotate.conf $destdir/etc/logrotate.d/ + mkdir -p $destdir/etc/default + touch $destdir/etc/default/logstash + install -m644 logrotate.conf $destdir/etc/logrotate.d/logstash + install -m644 logstash.default $destdir/etc/default/logstash install -m755 logstash.upstart.ubuntu $destdir/etc/init/logstash.conf ;; debian@*) + mkdir -p $destdir/etc/logstash/conf.d mkdir -p $destdir/etc/logrotate.d mkdir -p $destdir/etc/init.d mkdir -p $destdir/var/lib/logstash - mkdir -p $destdir/var/run/logstash mkdir -p $destdir/var/log/logstash - install -m644 logrotate.conf $destdir/etc/logrotate.d/ + mkdir -p $destdir/etc/default + touch $destdir/etc/default/logstash + install -m644 logrotate.conf $destdir/etc/logrotate.d/logstash + install -m644 logstash.default $destdir/etc/default/logstash install -m755 logstash.sysv.debian $destdir/etc/init.d/logstash ;; *) @@ -87,9 +92,10 @@ case $os in fpm -s dir -t deb -n logstash -v "$VERSION" \ -a all --iteration 1-$os \ -d "java6-runtime" \ - --before-install ubuntu/before-install.sh \ - --before-remove ubuntu/before-remove.sh \ - --after-install ubuntu/after-install.sh \ + --deb-user root --deb-group root \ + --before-install $os/before-install.sh \ + --before-remove $os/before-remove.sh \ + --after-install $os/after-install.sh \ -f -C $destdir . ;; esac diff --git a/pkg/debian/after-install.sh b/pkg/debian/after-install.sh index 10b9b67e555..5e0fc08f830 100644 --- a/pkg/debian/after-install.sh +++ b/pkg/debian/after-install.sh @@ -1,4 +1,5 @@ #!/bin/sh -mkdir -p /home/logstash -chown logstash:logstash /home/logstash +chown -R logstash:logstash /opt/logstash +chown logstash /var/log/logstash +chown logstash:logstash /var/lib/logstash diff --git a/pkg/debian/before-install.sh b/pkg/debian/before-install.sh index 21393258d6b..6cdfae974e5 100644 --- a/pkg/debian/before-install.sh +++ b/pkg/debian/before-install.sh @@ -7,6 +7,7 @@ fi # create logstash user if ! getent passwd logstash >/dev/null; then - useradd -r -g logstash -d /home/logstash \ - -s /sbin/nologin -c "logstash" logstash + useradd -M -r -g logstash -d /var/lib/logstash \ + -s /sbin/nologin -c "LogStash Service User" logstash fi + diff --git a/pkg/debian/before-remove.sh b/pkg/debian/before-remove.sh index 66187a914fc..8a92e482558 100644 --- a/pkg/debian/before-remove.sh +++ b/pkg/debian/before-remove.sh @@ -1,17 +1,13 @@ #!/bin/sh if [ $1 == "remove" ]; then - /etc/init.d/logstash > /dev/null 2>&1 || true + /etc/init.d/logstash stop >/dev/null 2>&1 || true if getent passwd logstash >/dev/null ; then userdel logstash fi - if getent group logstash > /dev/null ; then + if getent group logstash >/dev/null ; then groupdel logstash fi - - if [ -d "/home/logstash" ] ; then - rm -rf /home/logstash - fi fi diff --git a/pkg/logstash.default b/pkg/logstash.default new file mode 100644 index 00000000000..c82970d67dd --- /dev/null +++ b/pkg/logstash.default @@ -0,0 +1,45 @@ +# defaults for logstash + +# Start logstash on boot? +START=no + +# pulled in from the init script; makes things easier. +NAME=logstash + +# location of java +JAVA=/usr/bin/java + +# arguments to pass to java +LS_JAVA_OPTS="-Xmx256m -Djava.io.tmpdir=/var/lib/logstash/" + +PIDFILE=/var/run/logstash.pid + +# user id to be invoked as +LS_USER=logstash + +# location of the logstas jar file +LS_JAR=/opt/logstash/logstash.jar + +# logstash home location +LS_HOME=/var/lib/logstash + +# logstash log directory +LOG_DIR=/var/log/logstash + +# logstash log file +LOG_FILE=$LOG_DIR/$NAME.log + +# logstash configuration directory +CONF_DIR=/etc/logstash/conf.d + +# Open file limit +OPEN_FILES=2048 + +# Nice level +NICE=19 + +# Set LogStash options +LS_OPTS="--log ${LOG_FILE}" + +# Set a home directory +HOME=/var/lib/logstash diff --git a/pkg/logstash.sysv.debian b/pkg/logstash.sysv.debian index abcd09f6c44..7442e802868 100644 --- a/pkg/logstash.sysv.debian +++ b/pkg/logstash.sysv.debian @@ -56,7 +56,8 @@ LOG_FILE=$LOG_DIR/$NAME.log # Open File limit OPEN_FILES=2048 - +# LogStash options +LS_OPTS="--log ${LOG_DIR}/${NAME}.log" # Nice level NICE=19 @@ -71,7 +72,7 @@ fi # Define other required variables PID_FILE=/var/run/$NAME.pid DAEMON=$LS_JAR -DAEMON_OPTS="agent -f ${CONF_DIR} --log ${LOG_FILE}" +DAEMON_OPTS="agent -f ${CONF_DIR} ${LS_OPTS}" is_true() { if [ "x$1" = "xtrue" -o "x$1" = "xyes" -o "x$1" = "x1" ] ; then diff --git a/pkg/logstash.upstart.ubuntu b/pkg/logstash.upstart.ubuntu index 166c487a8ce..8866f0f01a7 100644 --- a/pkg/logstash.upstart.ubuntu +++ b/pkg/logstash.upstart.ubuntu @@ -15,6 +15,6 @@ setgid logstash # You need to chdir somewhere writable because logstash needs to unpack a few # temporary files on startup. -chdir /home/logstash +chdir /var/lib/logstash console log -exec /usr/bin/java -jar logstash.jar agent -f /etc/logstash/agent.conf +exec /usr/bin/java -jar /opt/logstash/logstash.jar agent -f /etc/logstash/conf.d diff --git a/pkg/ubuntu/after-install.sh b/pkg/ubuntu/after-install.sh index 10b9b67e555..5e0fc08f830 100644 --- a/pkg/ubuntu/after-install.sh +++ b/pkg/ubuntu/after-install.sh @@ -1,4 +1,5 @@ #!/bin/sh -mkdir -p /home/logstash -chown logstash:logstash /home/logstash +chown -R logstash:logstash /opt/logstash +chown logstash /var/log/logstash +chown logstash:logstash /var/lib/logstash diff --git a/pkg/ubuntu/before-install.sh b/pkg/ubuntu/before-install.sh index 21393258d6b..dfbde2020a9 100644 --- a/pkg/ubuntu/before-install.sh +++ b/pkg/ubuntu/before-install.sh @@ -7,6 +7,6 @@ fi # create logstash user if ! getent passwd logstash >/dev/null; then - useradd -r -g logstash -d /home/logstash \ - -s /sbin/nologin -c "logstash" logstash + useradd -M -r -g logstash -d /var/lib/logstash \ + -s /sbin/nologin -c "LogStash Service User" logstash fi diff --git a/pkg/ubuntu/before-remove.sh b/pkg/ubuntu/before-remove.sh index 9c7602aa338..a5001585d9c 100644 --- a/pkg/ubuntu/before-remove.sh +++ b/pkg/ubuntu/before-remove.sh @@ -1,17 +1,13 @@ #!/bin/sh if [ $1 == "remove" ]; then - stop logstash > /dev/null 2>&1 || true + stop logstash >/dev/null 2>&1 || true if getent passwd logstash >/dev/null ; then userdel logstash fi - if getent group logstash > /dev/null ; then + if getent group logstash >/dev/null ; then groupdel logstash fi - - if [ -d "/home/logstash" ] ; then - rm -rf /home/logstash - fi fi