#!/bin/sh

PATH=/opt/sbin:/opt/bin:/opt/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

start() {
	shadowvpn \
		-c /opt/etc/shadowvpn/client.conf \
		-s start
}

stop() {
	shadowvpn \
		-c /opt/etc/shadowvpn/client.conf \
		-s stop
}

restart() {
	shadowvpn \
		-c /opt/etc/shadowvpn/client.conf \
		-s restart
}

status() {
	pid=$(pidof shadowvpn)
	if [ -z "$pid" ] ; then
		echo 'shadowvpn is not running'
	else
		echo "shadowvpn pid is $pid"
	fi
}

case "$1" in
	start)
		start
	;;
	stop)
		stop
	;;
	restart)
		restart
	;;
	status)
		status
	;;
	*)
		echo "Usage: $0 (start|stop|restart|status)"
		exit 1
	;;
esac

exit 0