Modified carnet.conf. Added debian/config and debian/templates
[apache2-cn.git] / debian / config
1 #!/bin/sh
2
3 set -e
4
5 # Load debconf
6 . /usr/share/debconf/confmodule
7
8 CONFOLD="/etc/apache/httpd.conf"
9 CONFDIR="/etc/apache2"
10 CONF="$CONFDIR/apache2.conf"
11 HOST=$(hostname)
12 DOMAIN=$(hostname -d)
13
14 # Check for existing SSL VirtualHosts.
15 has_listen_ssl=0
16
17 if [ -d "$CONFDIR/conf.d" ] && [ -n "$(ls $CONFDIR/conf.d)" ]; then
18         listen_ssl_mask=$CONFDIR/conf.d/*
19 fi
20 if [ -d "$CONFDIR/sites-enabled" ] && [ -n "$(ls $CONFDIR/sites-enabled)" ]; then
21         listen_ssl_mask=$listen_ssl_mask" "$CONFDIR/sites-enabled/*
22 fi
23
24 for file in $CONF $listen_ssl_mask; do
25     if [ -f "$file" ]; then
26         if egrep -iq '^[[:space:]]*<VirtualHost .*443[[:space:]]*>' $file; then
27             has_listen_ssl=1
28             break
29         fi
30     fi
31 done
32
33 if [ $has_listen_ssl -eq 1 ]; then
34
35         # SSL configuration already exists - no need for SSL certificates.    
36         db_set apache2-cn/sslcf "X" || true
37         db_set apache2-cn/sslckf "X" || true
38         db_set apache2-cn/sslccf "X" || true
39
40 else
41     
42         # SSL certificates?
43         #
44         SSLCF=1
45         while [ $SSLCF -eq 1 ]; do
46
47             # SSL certificate file input.
48             db_input critical apache2-cn/sslcf || true
49             db_go || true
50             
51             db_get apache2-cn/sslcf || true
52             
53             if [ -n "$RET" ]; then
54
55                 if [ -f "$RET" ]; then
56                 
57                     # SSL certificate file exists.
58                     SSLCF=0
59                     
60                     SSLCKF=1
61                     while [ $SSLCKF -eq 1 ]; do
62                     
63                         # SSL certificate key file input.
64                         db_input critical apache2-cn/sslckf || true
65                         db_go || true
66                 
67                         db_get apache2-cn/sslckf || true
68                 
69                         if [ -n "$RET" ]; then
70                         
71                             if [ -f "$RET" ]; then
72                         
73                                 # SSL certificate key file exists.    
74                                 SSLCKF=0
75                                 
76                                 SSLCCF=1
77                                 while [ $SSLCCF -eq 1 ]; do
78                                 
79                                     # SSL certificate chain file input.
80                                     db_input critical apache2-cn/sslccf || true
81                                     db_go || true
82                                     
83                                     db_get apache2-cn/sslccf || true
84                                     
85                                     if [ -n "$RET" ]; then
86                                             
87                                         if [ -f "$RET" ]; then
88                                         
89                                             # SSL certificate chain file exists.
90                                             SSLCCF=0
91                                         fi
92                                     else
93                                         SSLCCF=0
94                                     fi
95                                 done
96                             fi
97                         fi
98                     done
99                 fi
100             else
101             
102                 # No SSL certificates specified.
103                 db_set apache2-cn/sslcf "" || true
104                 db_set apache2-cn/sslckf "" || true
105                 db_set apache2-cn/sslccf "" || true
106                 
107                 SSLCF=0
108             fi
109         done
110 fi
111
112 # Use WWW VirtualHost?
113 db_subst apache2-cn/wwwhost stroj_domena "${HOST}.${DOMAIN}"
114 db_subst apache2-cn/wwwhost www_domena "www.${DOMAIN}"
115 db_input critical apache2-cn/wwwhost || true
116 db_go || true
117
118 exit 0