* Tranzicijski paket za buduci prelazak na Debian Lenny.
[xinetd-cn.git] / debian / postinst
index 8c2f033..84b2ca9 100644 (file)
@@ -39,7 +39,12 @@ fi
 # If there are some services enabled in /etc/inetd.conf, convert them to
 # temporary xinetd configuration file.
 #
-[ -f "$DEFAULT" ] && inetd_compat="`grep '^XINETD_OPTS.*=.*\-inetd_compat' "$DEFAULT"`" || true
+if [ -f "$DEFAULT" ]; then
+       inetd_compat="`egrep '^[[:space:]]*XINETD_OPTS[[:space:]]*=.*\-inetd_compat' "$DEFAULT"`" || true
+       if [ -z "$inetd_compat" ]; then
+               inetd_compat="`egrep '^[[:space:]]*INETD_COMPAT[[:space:]]*=[[:space:]]*[Yy][Ee][Ss]' "$DEFAULT"`" || true
+       fi
+fi
 CONFTMP=`mktemp $CONF.tmp.XXXXXX`
 
 if [ -f "$INETDCONF" ] && [ -n "$inetd_compat" ]; then
@@ -94,7 +99,7 @@ cp_check_and_sed "^service " \
 #
 if ! egrep -q '^defaults' "$CONF"; then
 
-       echo -e "defaults\n{\n\n}" | cp-update "$PKG" "$CONF"
+       echo -e "defaults\n{\n\n}" | cp-update -m "$PKG" "$CONF"
        cp_echo "CN: Added defaults block to $CONF"
        
        need_restart=1
@@ -104,35 +109,45 @@ fi
 #
 if ! egrep -q '^includedir /etc/xinetd.d' "$CONF"; then
 
-       echo "includedir /etc/xinetd.d" | cp-update "$PKG" "$CONF"
+       echo "includedir /etc/xinetd.d" | cp-update -m "$PKG" "$CONF"
        cp_echo "CN: Added \"includedir /etc/xinetd.d\" line to $CONF"
        
        need_restart=1
 fi
 
-# Remove -inetd_compat option from /etc/default/xinetd
+# Remove -inetd_compat option and set INETD_COMPAT to 'No' in /etc/default/xinetd
 #
 if [ -f "$DEFAULT" ]; then
        
+       # File exists, set INETD_COMPAT to 'No'
+       cp_check_and_sed "^[[:space:]]*INETD_COMPAT.*[Yy][Ee][Ss]" \
+               "s/^[[:space:]]*INETD_COMPAT.*[Yy][Ee][Ss]/INETD_COMPAT=No/g" \
+               "$DEFAULT" && need_restart=1 || true
+
        # File exists, remove -inetd_compat option
-       cp_check_and_sed "^XINETD_OPTS.*\-inetd_compat" \
+       cp_check_and_sed "^[[:space:]]*XINETD_OPTS.*\-inetd_compat" \
                "s/\-inetd_compat//g" \
                "$DEFAULT" && need_restart=1 || true
 
-       # Just in case there is no active XINETD_OPTS line
-       if ! egrep -q '^XINETD_OPTS' "$DEFAULT"; then
+       # No INETD_COMPAT line?
+       if ! egrep -q '^[[:space:]]*INETD_COMPAT' "$DEFAULT"; then
+               echo 'INETD_COMPAT=No' | cp-update -m "$PKG" "$DEFAULT"
+               cp_echo "CN: Added 'INETD_COMPAT=No' to $DEFAULT."
+               need_restart=1
+       fi
 
-               echo 'XINETD_OPTS="-stayalive"' | cp-update "$PKG" "$DEFAULT"
+       # Just in case there is no active XINETD_OPTS line
+       if ! egrep -q '^[[:space:]]*XINETD_OPTS' "$DEFAULT"; then
+               echo 'XINETD_OPTS="-stayalive"' | cp-update -m "$PKG" "$DEFAULT"
                cp_echo "CN: Added -stayalive option to $DEFAULT."
-
                need_restart=1
        fi
 else
        # File wasn't there at all?
        touch $DEFAULT
-       echo 'XINETD_OPTS="-stayalive"' | cp-update "$PKG" "$DEFAULT"
-       cp_echo "CN: Created $DEFAULT file with -stayalive option."
-       
+       echo -e 'INETD_COMPAT=No\nXINETD_OPTS="-stayalive"' | cp-update "$PKG" "$DEFAULT"
+       cp_echo "CN: Created $DEFAULT file with -stayalive enabled and -inetd_compat disabled."
+
        need_restart=1
 fi