Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added RHEL init script, modified Makefile to detect if RHEL5/6 #76

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ MAKE?=make
CFLAGS+=-Ibuild/include
LDFLAGS+=-Lbuild/lib -Wl,-rpath,'$$ORIGIN/../lib'

# Conditional for RHEL based init script
INIT_SCRIPT := lumberjack.init
IS_RHEL ?= $(shell if grep -q 6.[0-9] /etc/redhat-release; then echo true; \
elif grep -q 5.[0-9] /etc/redhat-release;then echo true;else false; fi)
ifneq "$(IS_RHEL)" ""
INIT_SCRIPT := lumberjack.rhel.init
endif

default: build-all
build-all: build/bin/lumberjack build/bin/lumberjack.sh
#build-all: build/bin/keygen
Expand Down Expand Up @@ -45,7 +53,7 @@ rpm deb: | build-all
--description "a log shipping tool" \
--url "https://github.com/jordansissel/lumberjack" \
build/bin/lumberjack=$(PREFIX)/bin/ build/bin/lumberjack.sh=$(PREFIX)/bin/ \
lumberjack.init=/etc/init.d/lumberjack
$(INIT_SCRIPT)=/etc/init.d/lumberjack
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I build all packages from a single system, so I think it makes more sense to simply have multiple make targets; one for each package target.


# Vendor'd dependencies
# If VENDOR contains 'zeromq' download and build it.
Expand Down Expand Up @@ -104,3 +112,4 @@ build:

build/include build/bin build/test: | build
mkdir $@

84 changes: 84 additions & 0 deletions lumberjack.rhel.init
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/bin/sh
#
# lumberjack - this script starts and stops the lumberjack daemon
#
# chkconfig: - 85 16
# description: Lumberjack log service
# processname: lumberjack
# config: /etc/lumberjack/lumberjack.conf
# pidfile: /var/run/lumberjack.pid

# Source function library.
. /etc/rc.d/init.d/functions

LUMBERJACK_BIN="/opt/lumberjack/bin/lumberjack"
LUMBERJACK_CONF="/etc/lumberjack/lumberjack.conf"
LUMBERJACK_OPTIONS="-config ${LUMBERJACK_CONF}"
LUMBERJACK_LOG="/var/log/lumberjack.log"
PROG="$(basename ${LUMBERJACK_BIN})"

[ -f /etc/sysconfig/lumberjack ] && . /etc/sysconfig/lumberjack

LOCKFILE=/var/lock/subsys/${PROG}

start() {
[ -x ${LUMBERJACK_BIN} ] || exit 5
[ -f ${LUMBERJACK_CONF} ] || exit 6
echo -n $"Starting ${PROG}: "
export LD_LIBRARY_PATH=$(dirname ${LUMBERJACK_BIN})/../lib
daemon ${LUMBERJACK_BIN} ${LUMBERJACK_OPTIONS} &> ${LUMBERJACK_LOG} &
RETVAL=$?
echo
[ ${RETVAL} -eq 0 ] && touch ${LOCKFILE}
return ${RETVAL}
}

stop() {
echo -n $"Stopping ${PROG}: "
killproc ${PROG}
RETVAL=$?
echo
[ ${RETVAL} -eq 0 ] && rm -f ${LOCKFILE}
return ${RETVAL}
}

restart() {
#configtest_q || configtest || return 6
stop
start
}

reload() {
configtest_q || configtest || return 6
echo -n $"Reloading ${PROG}: "
killproc ${PROG} -HUP
echo
}

rh_status() {
status ${PROG}
}

rh_status_q() {
rh_status >/dev/null 2>&1
}

case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
status|status_q)
rh_$1
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 2
esac