Skip to content

Instantly share code, notes, and snippets.

@Moose0621
Last active June 10, 2019 13:21
Show Gist options
  • Select an option

  • Save Moose0621/d3b7212b6f06f78e186c5e92c51b533d to your computer and use it in GitHub Desktop.

Select an option

Save Moose0621/d3b7212b6f06f78e186c5e92c51b533d to your computer and use it in GitHub Desktop.
#!/bin/sh
# The following comment lines are used by the init setup script like the
# chkconfig command for RedHat based distributions. Change as
# appropriate for your installation.
### BEGIN INIT INFO
# Provides: nexus-iq-server
# Required-Start: $local_fs $remote_fs $network $time $named
# Required-Stop: $local_fs $remote_fs $network $time $named
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: nexus-iq-server service
# Description: Start the nexus-iq-server service
### END INIT INFO
NEXUS_IQ_SERVER_HOME=<SETME>
VERSION=*
JAVA_OPTIONS="-Xmx1024m -XX:MaxPermSize=128m"
# The user ID which should be used to run the IQ Server
# # IMPORTANT - Make sure that the user has the required privileges to write into the IQ Server work directory.
RUN_AS_USER=<SETME>
do_start()
{
cd $NEXUS_IQ_SERVER_HOME
su -m $RUN_AS_USER -c "java $JAVA_OPTIONS -jar nexus-iq-server-$VERSION.jar server config.yml > /dev/null 2>&1 &"
echo "Started nexus-iq-server"
}
do_run()
{
cd $NEXUS_IQ_SERVER_HOME
java $JAVA_OPTIONS -jar nexus-iq-server-$VERSION.jar server config.yml > /dev/null 2>&1 &
echo "Started nexus-iq-server"
}
do_console()
{
cd $NEXUS_IQ_SERVER_HOME
java $JAVA_OPTIONS -jar nexus-iq-server-$VERSION.jar server config.yml
}
do_stop()
{
pid=`ps aux | grep nexus-iq-server | grep -vE '(stop|grep)' | awk '{print $2}'`
kill $pid
echo "Killed nexus-iq-server - PID $pid"
}
do_usage()
{
echo "Usage: nexus-iq-server [console|start (root required)|stop|run]"
}
case $1 in
console) do_console
;;
run) do_run
;;
start) do_start
;;
stop) do_stop
;;
*) do_usage
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment