#!/bin/dash # Description: Caching web proxy server # jamesbond 2015 PIDFILE=/var/run/polipo.pid DAEMON=polipo start_daemon() { echo "Starting $DAEMON." $DAEMON } stop_daemon() { echo "Stopping $DAEMON." if [ -s $PIDFILE ]; then read pid < $PIDFILE kill $pid rm -f $PIDFILE fi } reload_daemon() { echo "Reloading $DAEMON." if [ -s $PIDFILE ]; then read pid < $PIDFILE kill -USR2 $pid fi } is_up_daemon() { test -s $PIDFILE } case $1 in start) start_daemon ;; stop) stop_daemon ;; restart) stop_daemon sleep 1 start_daemon ;; reload) reload_daemon ;; status) is_up_daemon && echo "$DAEMON is running." || echo "$DAEMON is stopped." ;; esac