#!/bin/sh
#
#
#
 case "$1" in
 'start')
 MODE=memory
 . /etc/polipo/polipo.conf
 if [ $MODE = tor ]; then
   tor 1>/dev/null &
 fi
 CONFIG=/etc/polipo/data/$MODE
 polipo -c $CONFIG pidFile=/var/run/polipo.pid 2>/dev/null &
 ;;
 'stop')
 killall polipo 2>/dev/null
 killall tor 2>/dev/null
 ;;
 'restart')
 proxyd stop
 sleep 1
 proxyd start
 ;;
 'test')
 if [ ! -e /var/run/polipo.pid ]; then
   echo "Your Proxy Server seems to be down."
   read -p "Do you wish to start it now (y/n)?: " CHOICE
   CHOICE=y$CHOICE
   if [ $CHOICE = yy ]; then
     proxyd start
   fi
 fi
 links2 http://localhost:1001
 ;;
 'help')
 echo "proxyd start --> start proxy server"
 echo "proxyd stop --> stop proxy server"
 echo "proxyd restart --> restart proxy server"
 echo "proxyd test --> test proxy server"
 ;;
 *)
 echo "Usage:"
 proxyd help
 ;;
 esac