#!/bin/bash

home_ftp=/usr/local/pack/pureftpd
home_ldap=/usr/local/pack/pureftpd/etc/pureftpd-ldap.conf
pid_file="/var/run/pure-ftpd.pid"

#  Configguration du oath

#options_ftp="-d -g $pid_file -c20 -B -A -l puredb:$home_ldap -Y 2"
options_ftp="-4 -d -B -A -c20 -E -l ldap:$home_ldap -Y 2"

if test -d $home_ftp
then

     case $1 in
    
     start)
            $home_ftp/sbin/pure-ftpd $options_ftp 
            echo "Start deamon pure-ftpd"
            ;;
     stop)
            if  test -a $pid_file 
            then 
                 pkill pure-ftpd 
                 echo "Stop deamon pure-ftpd"
            else
                 echo "Pure-ftpd is stopping"
            fi
            ;;
     
     restart)
    
            pkill pure-ftpd 
            echo "Stop deamon pure-ftpd"
            $home_ftp/sbin/pure-ftpd $options_ftp 
            echo "Start deamon pure-ftpd"
            ;;
     
    status)
            if  test -a $pid_file 
             then              
                 pid=`pidof pure-ftpd` 
                 echo "Pure-ftpd is runnning ( pid= $pid )"
             else
                 echo "Pure-ftpd is stopping"
             fi
             ;;
     
       esac

else
    echo "Le répertoire d'installation $home_ftp n'existe pas"
fi
