summaryrefslogtreecommitdiffstats
path: root/polipo/build/rc.polipo
blob: 46e5c476391890836a60cb5b6ca65cd39ef85667 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh

#
# Slackware init script for polipo, a small and fast caching web proxy.
#

# Protect polipo with credentials (format: username:password on a single line)
CRED="/etc/polipo/auth/credentials"

# Polipo configuration file:
CFG="/etc/polipo/config"

# Store the PID:
PIDFILE="/var/run/polipo/polipo.pid"

# Do not run as root:
RUNAS="apache"

start() {
  echo "Starting polipo..."
  if [ ! -r "$CFG" ]; then
    echo "Polipo configuration '${CFG}' not found! Exiting"
    exit 1
  fi
  if [ -r "$CRED" ]; then
    AUTH="authCredentials=$(cat $CRED) "
  else
    AUTH=" "
  fi
  su - $RUNAS -c "polipo -c ${CFG} daemonise=true pidFile=$PIDFILE $AUTH"
}

stop() {
  echo "Stopping polipo..."
  kill $(cat $PIDFILE)
}

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