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>
13 . /usr/share/carnet-tools/functions.sh
16 #. /usr/share/debconf/confmodule
18 FTP_CONF=/etc/proftpd/proftpd.conf
19 FTP_TMP=`mktemp /etc/proftpd/proftpd.conf.XXXXXX`
20 FTP_OLD=/var/backups/proftpd.conf.bak
21 SSL_CERT=/etc/ssl/certs/ftpd.pem
22 SSL_KEY=/etc/ssl/private/ftpd.pem
24 # Backup stare konfiguracije
25 cp_backup_conffile $FTP_CONF
26 cp -p $FTP_CONF $FTP_TMP
28 # Onemogucavanje Anonymous ftp pristupa
30 if grep -qi "^<Anonymous" $FTP_TMP; then
31 echo "CN: Anonymous access has been disabled in $FTP_CONF."
32 # Brisanje Anonymous linija
33 sed -n -i -e '/<Anonymous /,/\/Anon/!p' $FTP_TMP
37 # Popravi razne stvari u confu
39 if [ -f $FTP_TMP ]; then
41 sed -i -e 's/lsdefaultoptions/ListOptions/i' $FTP_TMP
44 sed -i -e "s/tcpreceivewindow/SocketOptions rcvbuf/i" \
45 -e "s/tcpsendwindow/SocketOptions sndbuf/i" $FTP_TMP
48 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
50 # Ubaci pravi hostname
51 CARNET_HOSTNAME=`hostname`
52 CARNET_DOMAINNAME=`hostname --domain`
53 sed -i -e "s/^ServerName.*\"Debian\"/ServerName \"$CARNET_HOSTNAME.$CARNET_DOMAINNAME\"/i" $FTP_TMP
56 sed -i -e 's/^#.*DelayEngine.*/DelayEngine on/i' $FTP_TMP
58 # Omoguci da bude standalone servis
59 sed -i -e 's/^\(ServerType.*\)inetd/\1standalone/' $FTP_TMP
60 update-inetd --disable ftp || true
61 #db_set shared/proftpd/inetd_or_standalone "standalone"
67 # Dodaj TLS konfiguraciju ako je potrebna
69 if [ -f $FTP_TMP ]; then
70 cp-update proftpd-cn $FTP_TMP <<EOF
73 TLSLog /var/log/proftpd/tls.log
76 # Are clients required to use FTP over TLS when talking to this server?
79 # Server's certificate
80 TLSRSACertificateFile $SSL_CERT
81 TLSRSACertificateKeyFile $SSL_KEY
83 # CA the server trusts
84 #TLSCACertificateFile /etc/ftpd/root.cert.pem
86 # Authenticate clients that want to use FTP over TLS?
89 # Allow SSL/TLS renegotiations when the client requests them, but
90 # do not force the renegotations. Some clients do not support
91 # SSL/TLS renegotiations; when mod_tls forces a renegotiation, these
92 # clients will close the data connection, or there will be a timeout
93 # on an idle data connection.
94 TLSRenegotiate required off
100 # include za slucaj da sistemac nije prihvatio izmjene od Debiana
102 if [ -f $FTP_TMP ] ; then
103 if ! egrep -qi "^[[:space:]]*Include.*/etc/proftpd/modules.conf" $FTP_TMP ; then
104 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.$$
105 cat $FTP_TMP >>$FTP_TMP.tmp.$$
106 cp_mv $FTP_TMP.tmp.$$ $FTP_TMP
111 # Generiranje SSL certifikata
113 if [ \( ! -f $SSL_CERT \) -o \( ! -f $SSL_KEY \) ] ; then
114 echo "CN: Generating SSL certificate... "
115 HOSTNAME=`hostname -s`
117 MAILNAME=`cat /etc/mailname 2> /dev/null || hostname -f`
118 (openssl req -new -x509 -days 365 -nodes -out $SSL_CERT -keyout $SSL_KEY >/dev/null 2>&1 <<EOF
123 $hostname.$domainname
128 echo "CN: Self-signed SSL certificate generated in $SSL_CERT."
129 echo "CN: Please note that the certificate will expire in one year."
133 # purge starog proftpd-common paketa bi napravio rusvaj
134 defuse_old_postrm() {
135 if [ -f /var/lib/dpkg/info/proftpd-common.postrm ]; then
136 cp_check_and_sed '^[^#]*(update-rc.d|update-inetd|/var/run/proftpd)' \
137 '/update-rc.d/d; /update-inetd/d; /var\/run\/proftpd/d' \
138 /var/lib/dpkg/info/proftpd-common.postrm || true
150 echo "CN: Proftpd-cn is configured with disabled anonymous FTP access,"
151 echo "CN: for the security reasons."
154 if ! cmp -s $FTP_TMP $FTP_CONF; then
155 echo "CN: Original configuration file is saved in $FTP_OLD."
156 cp_mv $FTP_TMP $FTP_CONF
161 echo "CN: Restarting proftpd..."
162 service proftpd restart
164 # dh_installdeb will replace this with shell code automatically
165 # generated by other debhelper scripts.