#!/bin/sh
#
# Synology DSM init script for CouchPotato
# Requires: couchpotato
#           python
#           wget
#
# Configured Variables:
#
PYTHON_EXEC="/opt/bin/python2.6"
COUCHPOTATO_EXEC="/opt/share/couchpotato/CouchPotato.py"
COUCHPOTATO_PORT="9203"

# Begin script
#
case "$1" in
start)
  printf "%-30s" "Starting CouchPotato"
  ${PYTHON_EXEC} ${COUCHPOTATO_EXEC} -d &
  printf "[%4s]\n" "done"
  ;;
stop)
  printf "%-30s" "Stopping CouchPotato"
  /opt/bin/wget -q --delete-after "http://127.0.0.1:${COUCHPOTATO_PORT}/config/exit/"
  printf "[%4s]\n" "done"
  ;;
*)
  echo "Usage: $0 {start|stop}"
  exit 1
esac
            
exit 0

