opt/pure-ftpd/pure-ftpd
2006-02-23 15:26:10 +00:00

40 lines
699 B
Bash

#!/bin/sh
#
# /etc/rc.d/pure-ftpd: start/stop pure-ftpd daemon
#
CONF=/etc/pure-ftpd.conf
ARGS=$(sed -e '/^\s*$/d' -e '/^#/d' $CONF)
CRT=/etc/ssl/certs/pure-ftpd.pem
make_cert() {
FQDN=$(hostname -f) || FQDN=localhost
echo "Creating SSL certificate $CRT for host $FQDN"
INFO=".\n.\n.\n.\n.\n$FQDN\nroot@$FQDN"
OPTS="req -new -nodes -x509 -days 365 -newkey rsa:1024"
echo -e $INFO | openssl $OPTS -out $CRT -keyout $CRT 2> /dev/null
chmod 0600 $CRT
}
case $1 in
start)
if [ ! -s $CRT ]; then
make_cert
fi
/usr/sbin/pure-ftpd $ARGS
;;
stop)
killall -q /usr/sbin/pure-ftpd
;;
restart)
$0 stop
sleep 2
$0 start
;;
*)
echo "usage: $0 [start|stop|restart]"
;;
esac
# End of file