-
Notifications
You must be signed in to change notification settings - Fork 441
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
fix SystemV init script template for rpm packaging #541
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,62 +28,48 @@ | |
# Source function library. | ||
. /etc/rc.d/init.d/functions | ||
|
||
# adding bashScriptEnvConfigLocation | ||
[[ -f ${{env_config}} ]] && . ${{env_config}} | ||
|
||
# $JAVA_OPTS used in $RUN_CMD wrapper | ||
export JAVA_OPTS | ||
|
||
# FIXME The pid file should be handled by the executed script | ||
# The pid can be filled in in this script | ||
PIDFILE=/var/run/${{app_name}}/running.pid | ||
|
||
if [ -z "$DAEMON_USER" ]; then | ||
DAEMON_USER=${{daemon_user}} | ||
fi | ||
|
||
if [ -z "$DAEMON_GROUP" ]; then | ||
DAEMON_GROUP=${{daemon_group}} | ||
fi | ||
|
||
|
||
# smb could define some additional options in $RUN_OPTS | ||
RUN_CMD="${{chdir}}/bin/${{exec}}" | ||
# Source from package defined config. Defaults to, | ||
# bashScriptEnvConfigLocation := Some("/etc/default/" + (packageName in Linux).value) | ||
[ -e ${{env_config}} ] && . ${{env_config}} | ||
|
||
# Source from sysconfig | ||
# This order means system config appends/overrides package config | ||
[ -e /etc/sysconfig/${{app_name}} ] && . /etc/sysconfig/${{app_name}} | ||
|
||
lockfile=/var/lock/subsys/${{app_name}} | ||
|
||
start() { | ||
[ -x $RUN_CMD ] || exit 5 | ||
echo -n $"Starting ${{app_name}}: " | ||
cd ${{chdir}} | ||
exec="${{chdir}}/bin/${{exec}}" | ||
prog="${{app_name}}" | ||
lockfile=/var/lock/subsys/$prog | ||
|
||
# FIXME figure out how to use daemon correctly | ||
nohup runuser $DAEMON_USER ${RUN_CMD} >> /var/log/${{app_name}}/daemon.log 2>&1 & | ||
RUN_CMD="$exec >> /var/log/${{app_name}}/daemon.log 2>&1 &" | ||
|
||
# The way to go, but doesn't work properly | ||
# If the app creates the pid file this gets messy | ||
# daemon --user $DAEMON_USER --pidfile $PIDFILE $RUN_CMD & | ||
# $JAVA_OPTS used in $exec wrapper | ||
export JAVA_OPTS | ||
|
||
[ -z "${DAEMON_USER:-}" ] && DAEMON_USER=${{daemon_user}} | ||
|
||
retval=$? # last error code | ||
PID=$! # pid of last backgrounded process | ||
[ $retval -eq 0 ] && touch ${lockfile} && success || failure | ||
# If program manages its own PID file then it | ||
# should declare its location in PIDFILE | ||
if [ -z "${PIDFILE:-}" ]; then | ||
PIDFILE=/var/run/${{app_name}}/running.pid | ||
# echo $! must run in the shell started by `runuser` in `daemon` | ||
RUN_CMD="$RUN_CMD echo \$! > $PIDFILE" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like extending the |
||
fi | ||
|
||
# Insert pid into pid file for CentOS killproc function | ||
[ -d "/var/run/${{app_name}}" ] || install -d -o "$DAEMON_USER" -g "$DAEMON_GROUP" -m755 "/var/run/${{app_name}}" | ||
start() { | ||
[ -x $exec ] || exit 5 | ||
echo -n $"Starting $prog: " | ||
daemon --check $prog --user $DAEMON_USER --pidfile $PIDFILE "$RUN_CMD" | ||
retval=$? | ||
echo | ||
echo $PID > ${PIDFILE} | ||
return $retval | ||
[ $retval -eq 0 ] && touch $lockfile | ||
} | ||
|
||
stop() { | ||
echo -n $"Stopping ${{app_name}}: " | ||
killproc -p $PIDFILE ${{app_name}} | ||
echo -n $"Stopping $prog: " | ||
killproc -p $PIDFILE $prog | ||
retval=$? | ||
echo | ||
[ $retval -eq 0 ] && rm -f $lockfile | ||
return $retval | ||
} | ||
|
||
restart() { | ||
|
@@ -101,7 +87,7 @@ force_reload() { | |
|
||
rh_status() { | ||
# run checks to determine if the service is running or use generic status | ||
status -p $PIDFILE -l $lockfile ${{app_name}} | ||
status -p $PIDFILE -l $lockfile $prog | ||
} | ||
|
||
rh_status_q() { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getting the config stuff right already paid off. Sweet!