5 [ "$1" = "configure" ] || exit 0
6 [ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx
8 # created: 2002-11-15 Bozo Juretic <bjuretic@srce.hr>
9 # last update: 2007-05-14 Zoran Dzelajlija <zoran.dzelajlija@carnet.hr>
10 # last update: 2011-04-24 Dinko Korunic <kreator@carnet.hr>
11 # last update: 2020-08-14 Ivan Rako <Ivan.Rako@CARNET.hr>
14 . /usr/share/carnet-tools/functions.sh
17 #. /usr/share/debconf/confmodule
19 FTP_CONF=/etc/proftpd/proftpd.conf
20 FTP_TMP=`mktemp /etc/proftpd/proftpd.conf.XXXXXX`
21 FTP_OLD=/var/backups/proftpd.conf.bak
22 SSL_CERT=/etc/ssl/certs/ftpd.pem
23 SSL_KEY=/etc/ssl/private/ftpd.pem
25 # Backup stare konfiguracije
26 cp_backup_conffile $FTP_CONF
27 cp -p $FTP_CONF $FTP_TMP
29 # Onemogucavanje Anonymous ftp pristupa
31 if grep -qi "^<Anonymous" $FTP_TMP; then
32 echo "CN: Anonymous access has been disabled in $FTP_CONF."
33 # Brisanje Anonymous linija
34 sed -n -i -e '/<Anonymous /,/\/Anon/!p' $FTP_TMP
38 # Popravi razne stvari u confu
40 if [ -f $FTP_TMP ]; then
42 sed -i -e 's/lsdefaultoptions/ListOptions/i' $FTP_TMP
45 sed -i -e "s/tcpreceivewindow/SocketOptions rcvbuf/i" \
46 -e "s/tcpsendwindow/SocketOptions sndbuf/i" $FTP_TMP
49 sed -i -e "s/\(scoreboardpath.*\)/#\n#ScoreboardPath is deprecated in 1.2.9, use ScoreboardFile instead\n#\1\n#\n#ScoreboardFile\t\/var\/run\/proftpd\/proftpd.scoreboard\n#/i" $FTP_TMP
51 # Ubaci pravi hostname
52 CARNET_HOSTNAME=`hostname`
53 CARNET_DOMAINNAME=`hostname --domain`
54 sed -i -e "s/^ServerName.*\"Debian\"/ServerName \"$CARNET_HOSTNAME.$CARNET_DOMAINNAME\"/i" $FTP_TMP
57 sed -i -e 's/^#.*DelayEngine.*/DelayEngine on/i' $FTP_TMP
59 # Omoguci da bude standalone servis
60 sed -i -e 's/^\(ServerType.*\)inetd/\1standalone/' $FTP_TMP
61 update-inetd --disable ftp || true
62 #db_set shared/proftpd/inetd_or_standalone "standalone"
68 # Dodaj TLS konfiguraciju ako je potrebna
70 if [ -f $FTP_TMP ]; then
71 cp-update proftpd-cn $FTP_TMP <<EOF
74 TLSLog /var/log/proftpd/tls.log
77 # Are clients required to use FTP over TLS when talking to this server?
80 # Server's certificate
81 TLSRSACertificateFile $SSL_CERT
82 TLSRSACertificateKeyFile $SSL_KEY
84 # CA the server trusts
85 #TLSCACertificateFile /etc/ftpd/root.cert.pem
87 # Authenticate clients that want to use FTP over TLS?
90 # Allow SSL/TLS renegotiations when the client requests them, but
91 # do not force the renegotations. Some clients do not support
92 # SSL/TLS renegotiations; when mod_tls forces a renegotiation, these
93 # clients will close the data connection, or there will be a timeout
94 # on an idle data connection.
95 TLSRenegotiate required off
101 # include za slucaj da sistemac nije prihvatio izmjene od Debiana
103 if [ -f $FTP_TMP ] ; then
104 if ! egrep -qi "^[[:space:]]*Include.*/etc/proftpd/modules.conf" $FTP_TMP ; then
105 printf "#\n# Includes required DSO modules. This is mandatory in proftpd 1.3\n#\nInclude\t/etc/proftpd/modules.conf\n\n" >$FTP_TMP.tmp.$$
106 cat $FTP_TMP >>$FTP_TMP.tmp.$$
107 cp_mv $FTP_TMP.tmp.$$ $FTP_TMP
112 # Generiranje SSL certifikata
114 if [ \( ! -f $SSL_CERT \) -o \( ! -f $SSL_KEY \) ] ; then
115 echo "CN: Generating SSL certificate... "
116 HOSTNAME=`hostname -s`
118 MAILNAME=`cat /etc/mailname 2> /dev/null || hostname -f`
119 (openssl req -new -x509 -days 365 -nodes -out $SSL_CERT -keyout $SSL_KEY >/dev/null 2>&1 <<EOF
124 $hostname.$domainname
129 echo "CN: Self-signed SSL certificate generated in $SSL_CERT."
130 echo "CN: Please note that the certificate will expire in one year."
141 echo "CN: Proftpd-cn is configured with disabled anonymous FTP access,"
142 echo "CN: for the security reasons."
145 if ! cmp -s $FTP_TMP $FTP_CONF; then
146 echo "CN: Original configuration file is saved in $FTP_OLD."
147 cp_mv $FTP_TMP $FTP_CONF
152 echo "CN: Restarting proftpd..."
153 service proftpd restart
155 # dh_installdeb will replace this with shell code automatically
156 # generated by other debhelper scripts.