Skip to content

Instantly share code, notes, and snippets.

@cornfeedhobo
Created December 1, 2015 16:21
Show Gist options
  • Save cornfeedhobo/d54fb2e1ddbf4d8a4903 to your computer and use it in GitHub Desktop.
Save cornfeedhobo/d54fb2e1ddbf4d8a4903 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Startup / shutdown script for the sync gateway server
#
### BEGIN INIT INFO
# Provides: sync-gateway
# Required-Start: $network $local_fs
# Required-Stop:
# Should-Start: $named
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: sync gateway server
# Description: sync gateway server
### END INIT INFO
# Source functions library
. /etc/init.d/functions
if [ "$(id -u)" != "0" ]; then
echo "Must run as root"
exit 1
fi
RETVAL=0
DAEMON=/usr/bin/sync_gateway
LOCKFILE=/var/lock/subsys/sync_gateway
test -f $DAEMON || exit 0
# Source config
if [ -f /etc/sysconfig/sync_gateway ] ; then
. /etc/sysconfig/sync_gateway
fi
start() {
[ -x $DAEMON ] || exit 5
echo -n $"Starting sync_gateway: "
daemon "$DAEMON" -- $SYNC_GATEWAY_OPTIONS > /var/log/sync_gateway.start.log 2>&1 &
success $"$base startup" || failure $"$base startup"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $LOCKFILE
return $RETVAL
}
stop() {
echo -n $"Shutting down sync_gateway: "
killproc $DAEMON
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE
return $RETVAL
}
restart() {
stop
start
}
status() {
status -l sync_gateway $DAEMON
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 3
esac
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment