Modified carnet.conf. Added debian/config and debian/templates
[apache2-cn.git] / debian / config
diff --git a/debian/config b/debian/config
new file mode 100755 (executable)
index 0000000..24d86fc
--- /dev/null
@@ -0,0 +1,118 @@
+#!/bin/sh
+
+set -e
+
+# Load debconf
+. /usr/share/debconf/confmodule
+
+CONFOLD="/etc/apache/httpd.conf"
+CONFDIR="/etc/apache2"
+CONF="$CONFDIR/apache2.conf"
+HOST=$(hostname)
+DOMAIN=$(hostname -d)
+
+# Check for existing SSL VirtualHosts.
+has_listen_ssl=0
+
+if [ -d "$CONFDIR/conf.d" ] && [ -n "$(ls $CONFDIR/conf.d)" ]; then
+        listen_ssl_mask=$CONFDIR/conf.d/*
+fi
+if [ -d "$CONFDIR/sites-enabled" ] && [ -n "$(ls $CONFDIR/sites-enabled)" ]; then
+        listen_ssl_mask=$listen_ssl_mask" "$CONFDIR/sites-enabled/*
+fi
+
+for file in $CONF $listen_ssl_mask; do
+    if [ -f "$file" ]; then
+        if egrep -iq '^[[:space:]]*<VirtualHost .*443[[:space:]]*>' $file; then
+           has_listen_ssl=1
+           break
+       fi
+    fi
+done
+
+if [ $has_listen_ssl -eq 1 ]; then
+
+       # SSL configuration already exists - no need for SSL certificates.    
+       db_set apache2-cn/sslcf "X" || true
+       db_set apache2-cn/sslckf "X" || true
+       db_set apache2-cn/sslccf "X" || true
+
+else
+    
+       # SSL certificates?
+       #
+       SSLCF=1
+       while [ $SSLCF -eq 1 ]; do
+
+           # SSL certificate file input.
+           db_input critical apache2-cn/sslcf || true
+           db_go || true
+           
+           db_get apache2-cn/sslcf || true
+           
+           if [ -n "$RET" ]; then
+
+               if [ -f "$RET" ]; then
+               
+                   # SSL certificate file exists.
+                   SSLCF=0
+                   
+                   SSLCKF=1
+                   while [ $SSLCKF -eq 1 ]; do
+                   
+                       # SSL certificate key file input.
+                       db_input critical apache2-cn/sslckf || true
+                       db_go || true
+               
+                       db_get apache2-cn/sslckf || true
+               
+                       if [ -n "$RET" ]; then
+                       
+                           if [ -f "$RET" ]; then
+                       
+                               # SSL certificate key file exists.    
+                               SSLCKF=0
+                               
+                               SSLCCF=1
+                               while [ $SSLCCF -eq 1 ]; do
+                               
+                                   # SSL certificate chain file input.
+                                   db_input critical apache2-cn/sslccf || true
+                                   db_go || true
+                                   
+                                   db_get apache2-cn/sslccf || true
+                                   
+                                   if [ -n "$RET" ]; then
+                                           
+                                       if [ -f "$RET" ]; then
+                                       
+                                           # SSL certificate chain file exists.
+                                           SSLCCF=0
+                                       fi
+                                   else
+                                       SSLCCF=0
+                                   fi
+                               done
+                           fi
+                       fi
+                   done
+               fi
+           else
+           
+               # No SSL certificates specified.
+               db_set apache2-cn/sslcf "" || true
+               db_set apache2-cn/sslckf "" || true
+               db_set apache2-cn/sslccf "" || true
+               
+               SSLCF=0
+           fi
+       done
+fi
+
+# Use WWW VirtualHost?
+db_subst apache2-cn/wwwhost stroj_domena "${HOST}.${DOMAIN}"
+db_subst apache2-cn/wwwhost www_domena "www.${DOMAIN}"
+db_input critical apache2-cn/wwwhost || true
+db_go || true
+
+exit 0