2 # postinst script for proftpd-cn
4 # see: dh_installdeb(1)
8 # summary of how this script can be called:
9 # * <postinst> `configure' <most-recently-configured-version>
10 # * <old-postinst> `abort-upgrade' <new version>
11 # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
13 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
14 # <failed-install-package> <version> `removing'
15 # <conflicting-package> <version>
16 # for details, see http://www.debian.org/doc/debian-policy/ or
17 # the debian-policy package
21 configure|reconfigure)
30 # created: 2002-11-15 Bozo Juretic <bjuretic@srce.hr>
31 # last update: 2007-05-14 Zoran Dzelajlija <zoran.dzelajlija@carnet.hr>
32 # last update: 2007-10-27 Dinko Korunic <kreator@carnet.hr>
34 # Source debconf library.
35 . /usr/share/debconf/confmodule
38 . /usr/share/carnet-tools/functions.sh
40 FTP_CONF=/etc/proftpd/proftpd.conf
41 FTP_TMP=`mktemp /etc/proftpd/proftpd.conf.XXXXXX`
42 FTP_OLD=/var/backups/proftpd.conf.bak
43 SSL_CERT=/etc/ssl/certs/ftpd-rsa.pem
44 SSL_KEY=/etc/ssl/certs/ftpd-rsa-key.pem
46 # Backup stare konfiguracije
47 cp_backup_conffile $FTP_CONF
48 cp -p $FTP_CONF $FTP_TMP
50 # Onemogucavanje Anonymous ftp pristupa
53 if grep -qi "^<Anonymous" $FTP_TMP; then
54 echo "CN: Anonymous access has been disabled in $FTP_CONF."
55 # Brisanje Anonymous linija
56 sed -n -i -e '/<Anonymous /,/\/Anon/!p' $FTP_TMP
60 # Popravi razne stvari u confu
63 if [ -f $FTP_TMP ]; then
65 sed -i -e 's/lsdefaultoptions/ListOptions/i' $FTP_TMP
68 sed -i -e "s/tcpreceivewindow/SocketOptions rcvbuf/i" \
69 -e "s/tcpsendwindow/SocketOptions sndbuf/i" $FTP_TMP
72 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
74 # Ubaci pravi hostname
75 CARNET_HOSTNAME=`hostname`
76 CARNET_DOMAINNAME=`hostname --domain`
77 sed -i -e "s/^ServerName.*\"Debian\"/ServerName \"$CARNET_HOSTNAME.$CARNET_DOMAINNAME\"/i" $FTP_TMP
80 sed -i -e 's/^#.*DelayEngine.*/DelayEngine on/i' $FTP_TMP
82 # Omoguci da bude standalone servis
83 sed -i -e 's/^\(ServerType.*\)inetd/\1standalone/' $FTP_TMP
84 update-inetd --disable ftp || true
85 db_set shared/proftpd/inetd_or_standalone "standalone"
91 # Dodaj TLS konfiguraciju ako je potrebna
94 if [ -f $FTP_TMP ]; then
95 cp-update proftpd-cn $FTP_TMP <<EOF
99 # Are clients required to use FTP over TLS when talking to this server?
102 # Server's certificate
103 TLSRSACertificateFile $SSL_CERT
104 TLSRSACertificateKeyFile $SSL_KEY
106 # CA the server trusts
107 #TLSCACertificateFile /etc/ftpd/root.cert.pem
109 # Authenticate clients that want to use FTP over TLS?
112 # Allow SSL/TLS renegotiations when the client requests them, but
113 # do not force the renegotations. Some clients do not support
114 # SSL/TLS renegotiations; when mod_tls forces a renegotiation, these
115 # clients will close the data connection, or there will be a timeout
116 # on an idle data connection.
117 TLSRenegotiate required off
123 # include za slucaj da sistemac nije prihvatio izmjene od Debiana
126 if [ -f $FTP_TMP ] ; then
127 if ! egrep -qi "^[[:space:]]*Include.*/etc/proftpd/modules.conf" $FTP_TMP ; then
128 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.$$
129 cat $FTP_TMP >>$FTP_TMP.tmp.$$
130 mv -f $FTP_TMP.tmp.$$ $FTP_TMP
135 # Generiranje SSL certifikata
138 if [ ! -f $SSL_CERT ] ; then
139 cd $(dirname $SSL_CERT)
140 echo "CN: Generating SSL certificate ... "
141 openssl req -new -x509 -days 365 -nodes -out $(basename $SSL_CERT) -keyout $(basename $SSL_KEY)
142 echo "CN: Self-signed SSL certificate generated in $SSL_CERT."
143 echo "CN: Please note that the certificate will expire in one year."
147 # purge starog proftpd-common paketa bi napravio rusvaj
150 if [ -f /var/lib/dpkg/info/proftpd-common.postrm ]; then
151 cp_check_and_sed '^[^#]*(update-rc.d|update-inetd|/var/run/proftpd)' \
152 '/update-rc.d/d; /update-inetd/d; /var\/run\/proftpd/d' \
153 /var/lib/dpkg/info/proftpd-common.postrm || true
165 echo "CN: Proftpd-cn is configured with disabled anonymous FTP access,"
166 echo "CN: for the security reasons."
169 if ! cmp -s $FTP_TMP $FTP_CONF; then
170 echo "CN: Original configuration file is saved in $FTP_OLD."
171 cp_mv $FTP_TMP $FTP_CONF
176 echo "CN: Restarting proftpd ..."
178 if [ -x /usr/sbin/invoke-rc.d ]; then
179 invoke-rc.d proftpd restart
181 /etc/init.d/proftpd restart
184 # dh_installdeb will replace this with shell code automatically
185 # generated by other debhelper scripts.