* Program:	pure-config

* Description:	Main configuration file's parser/converter for pure-ftpd
	 	server written in C, on the top of libcfg+ - see:
		http://platon.sk/projects/libcfg+/.

* Copyright:	Tomasz Wittner, 2004 under terms of GNU GPL v.2 license.


1. Building this software on Linux:

 a). Special prerequisites.
   At first you have to have libcfg+ library installed in your system. For
   futher informations about building and instalation of libcfg+ library
   see at http://platon.sk/projects/libcfg+/.

 b). Compilation and instalation.
   Run `make CFLAGS='-O2' ' in source directory. After successul compilation
   copy pure-config binary wherever you need.
   
2. Usage.
 
 a). From commandline.
   [root@pdp11 6:66 ~]# pure-fptd $( pure-config -f /etc/pure-ftpd.conf [-d|--debug] [-l|--long] ) \
				[--put_here_additional_pure-ftpd\'s_options|...]
   f.e.:
   [root@pdp11 6:66 ~]# pure-fptd $( pure-config -f /etc/pure-ftpd.conf -l ) --daemonize
 
 b). From PLD Linux Distribution's initscript.

#!/bin/sh
#
# pureftpd	PureFTPD server
#
# chkconfig:	345 85 15
# description:	PureFTPD is fast, production-quality, standard-conformant FTP server
#

# Source function library
. /etc/rc.d/init.d/functions

# Get network config
. /etc/sysconfig/network

# Get service config
[ -f /etc/sysconfig/pure-ftpd ] && . /etc/sysconfig/pure-ftpd

# Check that networking is up.
if is_yes "${NETWORKING}"; then
	if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
		# nls "ERROR: Networking is down. %s can't be run." <service>
		msg_network_down pure-ftpd
		exit 1
	fi
else
	exit 0
fi

RETVAL=0
# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/pure-ftpd ]; then
		msg_starting pure-ftpd
		rm -f /var/run/pure-ftpd/client*
		daemon pure-ftpd $(pure-config -f /etc/ftpd/pureftpd.conf -l) --daemonize
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/pure-ftpd
	else
		msg_already_running pure-ftpd
	fi
	;;
  stop)
	# Stop daemons.
	if [ -f /var/lock/subsys/pure-ftpd ]; then
		msg_stopping pure-ftpd
		killproc pure-ftpd
		rm -f /var/lock/subsys/pure-ftpd > /dev/null 2>&1
	else
		msg_not_running pure-ftpd
	fi
	;;
  status)
	status pure-ftpd
	RETVAL=$?
	if [ $RETVAL -eq 0 ]; then
		pure-ftpwho
	fi
	;;
  restart|force-reload)
	$0 stop
	$0 start
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
	;;
esac

exit $RETVAL

