#!/bin/bash # # Init file for p3scan POP3 proxy # # chkconfig: 2345 90 05 # description: p3scan proxy server # # processname: p3scan # config: /etc/p3scan/p3scan.conf # pidfile: /var/run/p3scan.pid # source function library . /etc/rc.d/init.d/functions # Source function library. . /etc/init.d/functions test -x /usr/sbin/p3scan || exit 0 RETVAL=0 # # See how we were called. # prog="p3scan" start() { # Check if p3scan is already running if [ ! -f /var/lock/subsys/p3scan ]; then echo -n $"Starting $prog: " daemon /usr/sbin/p3scan RETVAL=$? if [ $RETVAL -eq 0 ] ; then touch /var/lock/subsys/p3scan fi echo fi return $RETVAL } start_fw() { # # Warning !!! # # The following iptables rules may interfere with our firewall settings # Apply them only if you know what you're doing # See p3scan online manual and README file for details # echo -n "Inserting $prog redirect rule into nat PREROUTING chain:" daemon iptables -t nat -I PREROUTING -p tcp -i eth0 --dport 110 -j REDIRECT --to 8110 2> /dev/null echo echo -n "Inserting $prog reditect rule into nat OUTPUT chain:" daemon iptables -t nat -I OUTPUT -p tcp --dport 110 -j REDIRECT --to 8110 2> /dev/null echo echo -n "Inserting $prog accept rule into nat OUTPUT chain:" daemon iptables -t nat -I OUTPUT -p tcp --dport 110 -m owner --uid-owner mail -j ACCEPT 2> /dev/null echo } stop_fw() { # # Warning !!! # # The following iptables rules may interfere with our firewall settings # Apply them only if you know what you're doing # See p3scan online manual and README file for details # echo -n "Deleting $prog redirect rule into nat PREROUTING chain:" daemon iptables -t nat -D PREROUTING -p tcp -i eth0 --dport 110 -j REDIRECT --to 8110 2> /dev/null echo echo -n "Deleting $prog reditect rule into nat OUTPUT chain:" daemon iptables -t nat -D OUTPUT -p tcp --dport 110 -j REDIRECT --to 8110 2> /dev/null echo echo -n "Deleting $prog accept rule into nat OUTPUT chain:" daemon iptables -t nat -D OUTPUT -p tcp --dport 110 -m owner --uid-owner mail -j ACCEPT 2> /dev/null echo } stop() { echo -n $"Stopping $prog: " killproc /usr/sbin/p3scan RETVAL=$? if [ $RETVAL -eq 0 ] ; then rm -f /var/lock/subsys/p3scan fi echo return $RETVAL } restart() { stop start } reload() { restart } status_at() { status /usr/sbin/p3scan } case "$1" in start) start ;; stop) stop ;; start_fw) start_fw ;; stop_fw) stop_fw ;; reload|restart) restart ;; condrestart) if [ -f /var/lock/subsys/p3scan ]; then restart fi ;; status) status_at ;; *) echo $"Usage: $0 {start|stop|restart|condrestart|status|start_fw|stop_fw}" exit 1 esac exit $? exit $RETVAL