--- isinst.orig	2005-07-09 20:16:03.115889632 +0200
+++ isinst	2005-07-09 21:23:25.216396952 +0200
@@ -212,7 +212,7 @@
 
 V_INSTALL_PROGRESS="Installation Progress: "
 V_UNINSTALL_PROGRESS="Uninstallation Progress: "
-V_NEED_THIS_LIBRARY="Unable to find libstdc++-libc6.2-2.so.3\nPlease install the required RPM package and try again. For example, install compat-libstdc++-7.3-2.96.*.i386.rpm for RedHat Linux, or compat-2003.5.12-*.i586.rpm for Suse Linux."  
+V_NEED_THIS_LIBRARY="Unable to find libstdc++-libc6.2-2.so.3\nPlease install the required package and try again. For example, install compat-libstdc++-7.3-2.96.*.i386.rpm for RedHat Linux, compat-2003.5.12-*.i586.rpm for Suse Linux, or libstdc++2.10-glibc2.2*.deb for Debian Systems."  
 
 V_CHECK_INCOMING="\n\t\t${V_BOLD}Please modify incoming mail delivery IP.${V_OFFBOLD}\n"
 
@@ -276,8 +276,10 @@
 
 G_DETECT_POSTFIX="no"
 G_DETECT_SENDMAIL="no"
+G_DETECT_EXIM="no"
 G_ADDED_POSTFIX="no"
 G_ADDED_SENDMAIL="no"
+G_ADDED_EXIM="no"
 C_IN_MTA_IP="<Please modify>"
 C_IN_MTA_PORT="25"
 C_OUT_MTA_IP="0"
@@ -297,6 +299,13 @@
 ISVW_GROUP=isvw
 INSTALL_MIN_SPACE=500
 
+# support for Debian GNU/Linux systems
+G_OS_IS_DEBIAN="no"
+
+if [ -f /etc/debian_version ]; then
+  G_OS_IS_DEBIAN="yes"
+fi
+
 
 D_INSTALLED_DIR=`cat /etc/passwd | grep ${ISVW_USER} | cut -d: -f6`
 G_ASK_INDENT_P="\t"
@@ -316,11 +325,18 @@
 	
 
 	if [ "$G_ADDED_POSTFIX" = "yes" ] ; then
-		chkconfig --del postfix  > /dev/null 2>&1
-	
+		if [ "$G_OS_IS_DEBIAN" = "yes" ] ; then
+		  update-rc.d -f postfix remove > /dev/null 2>&1
+		else
+		  chkconfig --del postfix  > /dev/null 2>&1
+		fi
 	fi
 	if [ "$G_ADDED_SENDMAIL" = "yes" ] ; then
-		chkconfig --del sendmail > /dev/null 2>&1
+		if [ "$G_OS_IS_DEBIAN" = "yes" ] ; then
+		  update-rc.d -f sendmail remove > /dev/null 2>&1 
+		else
+		  chkconfig --del sendmail > /dev/null 2>&1
+		fi
 	fi
 	echo
 	exit 4
@@ -1963,21 +1979,32 @@
 	done
 }
 F_detect_postfix() {
-	chkconfig --list postfix 2> /dev/null | grep postfix  > /dev/null 2>&1
+	if [ "$G_OS_IS_DEBIAN" = "yes" ] ; then
+	  dpkg --get-selections | grep -q postfix
+	else
+	  chkconfig --list postfix 2> /dev/null | grep postfix  > /dev/null 2>&1
+	fi
+	
 	if [ "$?" = "0" ] ; then
 		G_DETECT_POSTFIX="yes"
 		return
 	fi
 
-	chkconfig --add  postfix > /dev/null 2>&1
-	chkconfig --list postfix 2> /dev/null | grep postfix  > /dev/null 2>&1
-	if [ "$?" = "0" ] ; then
+	if [ "$G_OS_IS_DEBIAN" = "no" ] ; then
+	  chkconfig --add  postfix > /dev/null 2>&1
+	  chkconfig --list postfix 2> /dev/null | grep postfix  > /dev/null 2>&1
+	  if [ "$?" = "0" ] ; then
 		G_DETECT_POSTFIX="yes"
 		G_ADDED_POSTFIX="yes"
+	  fi
 	fi
 }
 F_detect_sendmail() {
-	chkconfig --list sendmail 2> /dev/null | grep sendmail > /dev/null 2>&1
+	if [ "$G_OS_IS_DEBIAN" = "yes" ] ; then
+	  dpkg --get-selections | grep -q sendmail
+	else
+	  chkconfig --list sendmail 2> /dev/null | grep sendmail > /dev/null 2>&1
+	fi
 	if [ "$?" = "0" ] ; then
 		G_DETECT_SENDMAIL="yes"
 		return
@@ -1990,11 +2017,22 @@
 	#	G_DETECT_SENDMAIL="yes"
 	#	G_ADDED_SENDMAIL="yes"
 	#fi
-	
 }
+
+F_detect_exim() {
+  if [ "$G_OS_IS_DEBIAN" = "yes" ] ; then
+    dpkg --get-selections | grep -q exim
+    if [ "$?" = "0" ] ; then
+      G_DETECT_EXIM="yes"
+      return
+    fi
+  fi
+}
+
 F_detect_mta() {
 	F_detect_postfix
 	F_detect_sendmail
+	F_detect_exim
 }
 G_MTA_LIST=""
 G_MTA_NUM=0
@@ -2051,6 +2089,20 @@
 			G_MTA_NUM=2
 		fi
 	fi
+	if [ "$G_DETECT_EXIM" = "yes" ] ; then
+		printf "`tput bold` Exim `tput sgr0`"
+		if [ -z "$G_MTA_LIST" ] ; then
+		 	G_MTA_LIST="exim"
+			G_MTA_NUM=1
+		else
+			G_MTA_LIST="$G_MTA_LIST exim"
+			if [ "$G_DETECT_POSTFIX" = "yes" ] && [ "$G_DETECT_SENDMAIL"  = "yes" ] ; then
+			  G_MTA_NUM=3
+			else
+			  G_MTA_NUM=2
+			fi
+		fi
+	fi
 	printf "\n"
 	sleep 0.2	
 	while : ; do
@@ -2064,7 +2116,13 @@
 			F_get_mta_from_list 1
 			printf " 2="
 			F_get_mta_from_list 2
-			printf " [1|2] "
+			if [ $G_MTA_NUM = 3 ] ; then
+				printf "3="
+				F_get_mta_from_list 3
+				printf " [1|2|3] "
+			else
+				printf " [1|2] "
+			fi
 		fi
 		if [ "$C_CHOOSE_MTA" != "<Please modify>"  ] ; then
 			MY_CHOSEN_MTA=`F_get_mta_no "$C_CHOOSE_MTA"`
@@ -2121,7 +2179,7 @@
 	
 	while : ; do
 		V_header ""
-		if [ "$G_DETECT_SENDMAIL" = "no" -a "$G_DETECT_POSTFIX" = "no" ] ; then
+		if [ "$G_DETECT_SENDMAIL" = "no" -a "$G_DETECT_POSTFIX" = "no" -a "$G_DETECT_EXIM" = "no" ] ; then
 			printf "$V_ASK_INSTALL_MTA"
 			F_display_other_choice "no_next" "no_modify"
 			read MY_CHOICE
@@ -2601,22 +2659,43 @@
 	which wu.ftpd > /dev/null 2>&1
 	if [ "$?" = "0" ] ; then
 		/etc/init.d/wu-ftpd stop > /dev/null 2>&1
-		chkconfig --list wu-ftpd 2> /dev/null | grep on  > /dev/null 2>&1
+		if [ "$G_OS_IS_DEBIAN" = "yes" ] ; then
+		  dpkg --get-selections | grep -q wu-ftpd
+		else
+		  chkconfig --list wu-ftpd 2> /dev/null | grep on  > /dev/null 2>&1
+		fi
 		if [ "$?" = "0" ] ; then
 			#echo "Shutting down wu-ftpd ..."
-			chkconfig --level 2345 wu-ftpd off > /dev/null 2>&1
-			#wu-ftpd use only xinetd, but just in case
-			/etc/init.d/xinetd restart > /dev/null 2>&1
+			if [ "$G_OS_IS_DEBIAN" = "yes" ] ; then
+			  update-rc.d -f wu-ftpd remove > /dev/null 2>&1
+			else
+			  chkconfig --level 2345 wu-ftpd off > /dev/null 2>&1
+			fi
+
+			# check if any kind of inetd daemon is running and
+			# restart it then, this handles inetd as well as xinetd
+			L_INETD_TEMP=$(ps ax | awk "-F " '$5~/inetd/ { print $5;exit 1 }')
+			if [ "$?" = "1" ] ; then
+			  /etc/init.d/$(basename $L_INETD_TEMP) restart > /dev/null 2>&1
+			fi
 		fi
 	fi
 
 	which proftpd > /dev/null 2>&1
 	if [ "$?" = "0" ] ; then
 		/etc/init.d/proftpd stop > /dev/null 2>&1
-		chkconfig --list proftpd 2> /dev/null | grep on  > /dev/null 2>&1
+		if [ "$G_OS_IS_DEBIAN" = "yes" ] ; then
+		  dpkg --get-selections | grep -q proftpd
+		else
+		  chkconfig --list proftpd 2> /dev/null | grep on  > /dev/null 2>&1
+		fi
 		if [ "$?" = "0" ] ; then
 			#echo "Shutting down proftpd ..."
-			chkconfig --level 2345 proftpd off > /dev/null 2>&1
+			if [ "$G_OS_IS_DEBIAN" = "yes" ] ; then
+			  update-rc.d -f proftpd remove > /dev/null 2>&1
+			else
+			  chkconfig --level 2345 proftpd off > /dev/null 2>&1
+			fi
 			#proftpd doesn't use xinetd, but just in case
 			#/etc/init.d/xinetd restart > /dev/null 2>&1
 		fi
@@ -2624,10 +2703,24 @@
 	which vsftpd > /dev/null 2>&1
 	if [ "$?" = "0" ] ; then
 		/etc/init.d/vsftpd stop > /dev/null 2>&1
-		chkconfig --list vsftpd 2> /dev/null | grep on  > /dev/null 2>&1
+		if [ "$G_OS_IS_DEBIAN" = "yes" ] ; then
+		  dpkg --get-selections | grep -q vsftpd
+		else
+		  chkconfig --list vsftpd 2> /dev/null | grep on  > /dev/null 2>&1
+		fi
 		if [ "$?" = "0" ] ; then
-			chkconfig --level 2345 vsftpd off > /dev/null 2>&1
-			/etc/init.d/xinetd restart > /dev/null 2>&1
+			if [ "$G_OS_IS_DEBIAN" = "yes" ] ; then
+			  update-rc.d -f vsftpd remove > /dev/null 2>&1
+			else
+			  chkconfig --level 2345 vsftpd off > /dev/null 2>&1
+			fi
+			
+			# check if any kind of inetd daemon is running and
+			# restart it then, this handles inetd as well as xinetd
+			L_INETD_TEMP=$(ps ax | awk "-F " '$5~/inetd/ { print $5;exit 1 }')
+			if [ "$?" = "1" ] ; then
+			  /etc/init.d/$(basename $L_INETD_TEMP) restart > /dev/null 2>&1
+			fi
 		fi
 	fi
 
@@ -2645,13 +2738,25 @@
 	
 	# if do nothing then, it's on
 	if [ "${C_SMTP_ON}" = "off" -a "${C_POP3_ON}" = "off" ] ; then
-		chkconfig ISmss off	
+	        if [ "$G_OS_IS_DEBIAN" = "yes" ] ; then
+		  update-rc.d -f ISmss remove
+		else
+		  chkconfig ISmss off	
+		fi
 	fi
 	if [ "${C_HTTP_ON}" = "off" ] ; then
-		chkconfig ISproxy off
+	        if [ "$G_OS_IS_DEBIAN" = "yes" ] ; then
+		  update-rc.d -f ISproxy remove
+		else
+		  chkconfig ISproxy off
+		fi  
 	fi
 	if [ "${C_FTP_ON}" = "off" ] ; then
-		chkconfig ISftp off
+		if [ "$G_OS_IS_DEBIAN" = "yes" ] ; then
+		  update-rc.d -f ISftp remove
+		else
+		  chkconfig ISftp off
+		fi
 	fi
 
 	#manipulation because POP3 depends on SMTP service
@@ -2880,13 +2985,21 @@
 	if [ "${C_CHOOSE_MTA}" = "postfix" ] ; then
 		if [ "${C_SMTP_ON}" = "off" ] ; then
 			/etc/init.d/postfix stop > /dev/null 2>&1
-			chkconfig postfix off > /dev/null 2>&1
+			if [ "$G_OS_IS_DEBIAN" = "yes" ] ; then
+			  update-rc.d -f postfix remove > /dev/null 2>&1
+			else
+			  chkconfig postfix off > /dev/null 2>&1
+			fi
 		fi
 	
 	elif [ "${C_CHOOSE_MTA}" = "sendmail" ] ; then
 		if [ "${C_SMTP_ON}" = "off" ] ; then
 			/etc/init.d/sendmail-isvw stop > /dev/null 2>&1
-			chkconfig --levels 2345 sendmail-isvw off > /dev/null 2>&1
+			if [ "$G_OS_IS_DEBIAN" = "yes" ] ; then
+			  update-rc.d -f sendmail-isvw remove > /dev/null 2>&1
+			else
+			  chkconfig --levels 2345 sendmail-isvw off > /dev/null 2>&1
+			fi
 		fi
 	fi
 

