Skip to content

Instantly share code, notes, and snippets.

@nsteinmetz
Created September 5, 2014 13:32
Show Gist options
  • Save nsteinmetz/3e683e1ea6c719b2eccb to your computer and use it in GitHub Desktop.
Save nsteinmetz/3e683e1ea6c719b2eccb to your computer and use it in GitHub Desktop.
Initscript for Nuxeo under RHEL/CentOS
#!/bin/sh
#
# <daemonname> <summary>
#
# chkconfig: 2345 20 80
# description: Manage Nuxeo Platform service
### BEGIN INIT INFO
# Provides: nuxeo
# Required-Start: $local_fs $network $syslog
# Required-Stop: $local_fs $network $syslog
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/Stop Nuxeo and all other nuxeoctl commands
# Description:
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
exec=${NUXEOCTL-"/opt/nuxeo/nuxeo/bin/nuxeoctl"}
prog=${NUXEO-"nuxeo"}
lockfile="/var/lock/subsys/$prog"
config=${NUXEO_CONFIG-"/etc/nuxeo/conf/nuxeo.conf"}
NUXEO_USER=${NUXEO_USER-"root"}
NUXEO_HOME=${NUXEO_HOME-"/opt/nuxeo/nuxeo"}
NUXEO_CONF=$config
export NUXEO_CONF
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
start() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
echo -n $"Starting $prog: "
${exec} startbg
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
${exec} stop
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
rh_status() {
# run checks to determine if the service is running or use generic status
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
$1
;;
stop)
$1
;;
restart)
$1
;;
status)
rh_status
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 2
esac
exit $?
### END SCRIPT ###
### Use it with :
#
# chkconfig --add nuxeo
# chkconfig --list nuxeo
# nuxeo 0:off 1:off 2:on 3:on 4:on 5:on 6:off
###
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment