#! /bin/sh set -e set -a appname="pwfilter" script="pwfilter.py" user="mail" prodir="/usr/local/pwmail" logdir="/var/log/pwmail" piddir="/var/run/pwmail" mydomain="oakiki.jp,xxxx1.jp,xxxx2.jp" hnameip="192.168.200.110" pwadmin="pwadmin@oakiki.jp" [ -x $prodir/$appname.sh ] || exit 0 [ -x $prodir/$script ] || exit 0 check_start() { if [ -e $piddir/$appname.pid ]; then echo "${appname} server run)" exit 0 fi } check_privsep_dir() { if [ ! -d $piddir ]; then mkdir $piddir chmod 755 $piddir chown $user:$user $piddir fi if [ ! -d $logdir ]; then mkdir $logdir chmod 755 $logdir chown $user:$user $logdir fi } case "$1" in start) check_privsep_dir check_start echo -n "Starting ${appname} server" start-stop-daemon --start --oknodo --user $user --name $script --chuid $user:$user --pidfile $piddir/$appname.pid --exec $prodir/$appname.sh echo "." ;; stop) echo -n "Stopping ${appname} server" start-stop-daemon --stop --quiet --oknodo --pidfile $piddir/$appname.pid rm -f $piddir/$appname.pid echo "." ;; reload|force-reload|restart) echo -n "Restarting ${appname} server" start-stop-daemon --stop --quiet --oknodo --retry 30 --user $user --name $script sleep 5s check_privsep_dir start-stop-daemon --start --oknodo --user $user --name $script --chuid $user:$user --pidfile $piddir/$appname.pid --exec $prodir/$appname.sh echo "." ;; *) echo "Usage: /etc/init.d/ssh {start|stop|reload|force-reload|restart}" exit 1 esac exit 0