+rm -f /etc/apache2/sites-enabled/000-default.conf
+
+mkdir -p $root
+vhost_file=/etc/apache2/sites-enabled/$h.conf
+redir_file=/etc/apache2/sites-enabled/httpsredir.conf
+
+# note, we exepct ServerRoot of /etc/apache2
+cd /etc/apache2
+conf_files=(apache2.conf)
+
+# apache requires exactly 1 listen directive per port (when no ip is also given),
+# so we have to parse the config to do it programatically.
+listen_80=false
+listen_port=false
+while (( i=0; i < ${#conf_files[@]}; i++ )); do
+ f="${conf_files[i]}"
+ # note: globs are expanded here:
+ conf_files+=( $(sed -rn "s,^\s*Include(Optional)?\s+(\S+).*,\2,p" "$f") )
+ case $(readlink -f "$f") in
+ $vhost_file|$redir_file) continue ;;
+ esac
+ for p in $(sed -rn "s,^\s*Listen\s+(\S+).*,\1,p" "$f"); do
+ case $p in
+ 80) listen_80=true ;;
+ $port) listen_port=true ;;
+ esac
+ done
+done
+
+if $ssl; then
+ https_arg=" https"
+fi
+