Skip to content

Instantly share code, notes, and snippets.

@gerard-kanters
Created October 15, 2014 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gerard-kanters/f8f860b22189f46c7874 to your computer and use it in GitHub Desktop.
Save gerard-kanters/f8f860b22189f46c7874 to your computer and use it in GitHub Desktop.
/etc/init.d/solr
#!/bin/bash
# Script for running solr as a service under initd.
#
# Requires solr.conf and solr.start
# Usage: service solr {start|stop|restart|status}"
#
#-----------------------------------------------------
### BEGIN INIT INFO
# Provides: solr
# Required-Start:
# Required-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
### END INIT INFO
if [ ! -e /etc/redhat-release ]; then
echo "This is built for RHEL/Fedora/CentOS, you may need to alter it to fit your distribution"
exit 1
fi
if [ ! -f /etc/solr.conf ]; then
echo "Missing config file /etc/solr.conf"
exit 1
fi
. /etc/rc.d/init.d/functions
. /etc/solr.conf
case $1 in
start)
action "Starting ${NAME}: " daemon --pidfile $PIDFILE $SOLR_START
;;
stop)
action "Stopping ${NAME}: " killproc -p $PIDFILE
sleep 2
;;
restart)
$0 stop
$0 start
;;
status)
status -p $PIDFILE solr
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 3
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment