#!/bin/sh
#
# chkconfig:	2345 55 55
#
# description:	This shell script takes care of starting and stopping \
#               socks5.


# Source function library
. /etc/rc.d/init.d/functions

# Get network config
. /etc/sysconfig/network

# Get service config
[ -f /etc/sysconfig/socks5 ] && . /etc/sysconfig/socks5

# Check that networking is up.
if [ "${NETWORKING}" = "no" ]; then
	echo "WARNING: Networking is down. Socks5 can't be runed."
	exit 1
fi


# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/socks5 ]; then
		show Starting socks5
		daemon socks5
	else
		echo "socks5 already is running"
	fi
        touch /var/lock/subsys/socks5
        ;;
  stop)
        show Shutting down socks5
	busy
	stopsocks &>/dev/null
        rm -f /var/lock/subsys/socks5
	deltext;ok
        ;;
  status)
	status socks5
	;;
  restart|reload)
	$0 stop
	$0 start
	;;
  *)
        echo "Usage: $0 {start|stop|status|restart|reload}"
        exit 1
esac

exit 0
