Skip to content

Instantly share code, notes, and snippets.

@afbobak
Created March 10, 2014 05:57
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 afbobak/9460132 to your computer and use it in GitHub Desktop.
Save afbobak/9460132 to your computer and use it in GitHub Desktop.
Linux init.d script for NOPAR / https://github.com/afbobak/nopar
#!/bin/bash
#
# chkconfig: 35 90 12
# description: NOPAR Node Package Registry
#
# Configuration Variables:
# NOPAR_HOSTNAME=localhost
# NOPAR_PORT=5984
# NOPAR_AUTO_FORWARD=
# NOPAR_FORWARDER_URL=
# NOPAR_PROXY_URL=
# NOPAR_USER_AGENT=
# NOPAR_LOGFILE=
# NOPAR_LOGLEVEL=info
# NOPAR_REGISTRY_PATH=
# NOPAR_HOME=
# NOPAR_RUN_PATH=
# NOPAR_RUNAS_USER=
. /etc/init.d/functions
CONFIG=/etc/default/nopar
LOCK_FILE=/var/lock/subsys/nopar
if test -f ${CONFIG}; then
. ${CONFIG}
else
echo "Config not found: ${CONFIG}"
exit 5
fi
if [ "${NOPAR_RUNAS_USER}" = "" ]; then
NOPAR_RUNAS_USER=root
fi
start () {
echo -n "Starting NOPAR Server ${NOPAR_HOSTNAME}:${NOPAR_PORT}"
cd ${NOPAR_HOME} && node lib/server.js >> $NOPAR_LOGFILE 2>&1 &
pid=`jobs -p`
touch $LOCK_FILE
echo $pid > $NOPAR_RUN_PATH/nopar.pid
echo $pid > $LOCK_FILE
success $"NOPAR start"
echo
}
stop () {
echo -n "Stopping NOPAR Server:"
pid=`cat $LOCK_FILE`
kill $pid
rm -f $LOCK_FILE $NOPAR_RUN_PATH/nopar.pid
success $"NOPAR stop"
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status nopar
;;
restart|reload|condrestart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment