DOWNLOAD THIS SCRIPT
Do not use cut and paste - there are some TABs in the script...
#! /bin/sh

#
# Kianusch Sayah Karadji
# kianusch@sk-tech.net
# Sun Feb 15 18:08:16 CET 2004 ... initial release
# Tue Feb 17 10:00:55 CET 2004 ... cpqimlview should work in X11 now
#
# This script will download 
#
#  hpasm
#  cmastor
#  cpqacuxe
#
# RPMs for RedHat 2.1 from Compaq/HP and convert them to Debian
# packages for installation on a Debian System.
#
# The script does mor than simply calling "alien" - as it generates
# install/uninstall scripts and such.
#
# Make sure wget and alien is installed
# Make sure you have enough disk space for this script (ca. 50M) 
# You can start this script on any Debian-Installation - it does
# not have to be a Compaq Server
#

##
## HPASM:
## 
##   Forllowing programms work (for me):
##   
##      hplog
##      hpuid
##      
##      bootcfg -?
##   
##   If tkl8.3 is installed:
##   
##      cpqimlview
##      hpimlview
##   
##   The start with an error regarding db3, but work still fine.
##   
##   For some reason, casmd/cevtd do send status mails to the address "e."
##   So I aliased "e." to root in /etc/aliases
## 
##   Also have a look at /proc/cpq* ...
##   
## CMASTOR:
## 
##   Can be configured in the file
## 
##      /opt/compaq/cma.conf
## 
## CPQACUXE:
## 
##   To use it you have to start it with:
## 
##      # cpqacuxe -R
## 
##   Then use a web-browser to connect to 
## 
##       http://:2301
## 
##   Make sure that popup is allowed for this address.
## 
##   To stop the server use:
## 
##       # cpqacuxe -stop
## 
## HAVE FUN!
## 
## kianusch@sk-tech.net
##

FTPSITE=ftp://ftp.compaq.com/pub/products/servers/supportsoftware/linux/
CMASTOR=cmastor-7.0.0
CMASTOR_SV=-16.linux.i386.rpm
CPQACUXE=cpqacuxe-7.0
CPQACUXE_SV=-1.linux.i386.rpm
HPASM=hpasm-7.0.0
HPASM_SV=-21.rhel21.i386.rpm

HPASM_DEB_SV=2
CMASTOR_DEB_SV=1
CPQACUXE_DEB_SV=1

#
# Check for required Packages
#

missing=0


which wget > /dev/null

if [ $? -ne 0 ]; then
   echo "# Please install wget package..."
   echo "apt-get install wget"
   missing=1
fi

which alien > /dev/null

if [ $? -ne 0 ]; then
   echo "# Please install alien package..."
   echo "apt-get install alien"
   missing=1
fi

test ${missing} -ne 0 && exit 127


#
# Download required Packes from Compaq/HP FTP Site
# And convert them to TGZ Files
#

for f in ${CMASTOR}${CMASTOR_SV} ${CPQACUXE}${CPQACUXE_SV} ${HPASM}${HPASM_SV}
do
   wget -nc ${FTPSITE}/${f}
   alien -t ${f}
   # rm ${f}
done

#
# Let's Start with HPASM as this ist the main package
#

rm -rf debian
mkdir debian
cd debian
tar -xzf ../${HPASM}.tgz

cd opt/compaq/cpqhealth

patch -p1 << _EOT_ > /dev/null
diff -Nur cpqhealth.orig/cpqasm/cpqimlview.tcl cpqhealth/cpqasm/cpqimlview.tcl
--- cpqhealth.orig/cpqasm/cpqimlview.tcl        Tue Feb 17 10:20:11 2004
+++ cpqhealth/cpqasm/cpqimlview.tcl     Tue Feb 17 10:25:38 2004
@@ -1495,7 +1495,7 @@
 		set newTitle "- "
 	}
 	append newTitle "\$FileName"
-	set DriverInfo [exec rpm -q hpasm]
+	set DriverInfo ""
 	wm title \$form "\$IML_GUI_MSGS(MSG_APP_TITLE) \$DriverInfo \$newTitle"
 	}
 
@@ -1534,7 +1534,7 @@
 catch {destroy \$form}
 toplevel \$form
 bind .app   exit 
-set DriverInfo [exec rpm -q hpasm]
+set DriverInfo ""
 wm title \$form "\$IML_GUI_MSGS(MSG_APP_TITLE) - \$DriverInfo"
 wm iconname \$form "menu"
 wm geometry \$form 800x500+100+100
_EOT_

cd ../../..

for d in foundation hpasm server webagent
do
   rm -rf opt/compaq/${d}
done

chmod 700 sbin/bootcfg

cat << _EOT_ > etc/init.d/hpasm
#!/bin/sh
#
# kianusch@sk-tech.net
# Tue Aug 12 14:22:06 CEST 2003
#

case "\$1" in

start)
   /opt/compaq/cpqhealth/cpqevt/cevtd
   /opt/compaq/cpqhealth/cpqasm/casmd
   ;;
stop )
   /opt/compaq/cpqhealth/cpqasm/casmd -t
   /opt/compaq/cpqhealth/cpqevt/cevtd -t
   ;;
esac

exit 0
_EOT_

chmod 755 etc/init.d/hpasm

mkdir DEBIAN
chmod 755 DEBIAN

cat << _EOT_ > DEBIAN/control
Package: hpasm
Section: util
Maintainer: Kianusch Sayah Karadji 
Architecture: i386
Version: 7.0.0-${HPASM_DEB_SV}
Provides: hpasm
Description: hpasm
Suggests: tcl8.3, tix41, tclx8.3
_EOT_

cat << _EOT_ > DEBIAN/postinst
#! /bin/sh
# postinst script for hpasm
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        *  'configure' 
#        *  'abort-upgrade' 
#        *  'abort-remove' 'in-favour' 
#          
#        *  'abort-deconfigure' 'in-favour'
#            'removing'
#           
# for details, see /usr/share/doc/packaging-manual/
#
# quoting from the policy:
#     Any necessary prompting should almost always be confined to the
#     post-installation script, and should be protected with a conditional
#     so that unnecessary prompting doesn't happen if a package's
#     installation fails and the 'postinst' is called with 'abort-upgrade',
#     'abort-remove' or 'abort-deconfigure'.

case "\$1" in
    configure)
	cd /opt/compaq/cpqhealth
        make -f cpqhealth.mk

        mkdir -p /lib/modules/\$(uname -r)/misc/cpq

        cp cpqevt/cpqevt.o -p /lib/modules/\$(uname -r)/misc/cpq
        cp cpqasm/cpqasm.o -p /lib/modules/\$(uname -r)/misc/cpq

        depmod -a

        modprobe cpqevt
        modprobe cpqasm
	cpqasm/cpqasm_mknod.sh

        grep -q ^cpqevt\$ /etc/modules || echo cpqevt >> /etc/modules
        grep -q ^cpqasm\$ /etc/modules || echo cpqasm >> /etc/modules

        test -f /bin/mail || ln -s  /usr/bin/mail /bin/mail
        grep -q ^e\\. /etc/aliases || echo "e.: root" >> /etc/aliases
        /usr/bin/newaliases

        update-rc.d hpasm start 27 S . stop 81 1 .
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)

    ;;

    *)
        echo "postinst called with unknown argument '\$1'" >&2
        exit 0
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
_EOT_


cat << _EOT_ > DEBIAN/prerm
#! /bin/sh

TMP=/tmp/$$

set -e

if [ "\$1" = "upgrade" -o "\$1" = "remove" ]; then
   ## /etc/init.d/hpasm stop
   rmmod cpqasm > /dev/null 2>&1
   rmmod cpqevt > /dev/null 2>&1

   rm /opt/compaq/cpqhealth/cpqevt/cpqevt.o         
   rm /opt/compaq/cpqhealth/cpqevt/cpqevtw_linux.o
   rm /opt/compaq/cpqhealth/cpqasm/casmw_linux.o
   rm /opt/compaq/cpqhealth/cpqasm/cpqasm.o
   rm /lib/modules/\$(uname -r)/misc/cpq/cpqevt.o
   rm /lib/modules/\$(uname -r)/misc/cpq/cpqasm.o
   rm /bin/mail
   
   rmdir --ignore-fail-on-non-empty /lib/modules/\$(uname -r)/misc/cpq

   if [ -f /etc/modules ]; then 
      grep -v ^cpqevt\$ /etc/modules | grep -v ^cpqasm\$ > \${TMP}
      cat \${TMP} > /etc/modules
      rm \${TMP}
   fi

   if [ -f /etc/aliases ]; then 
      grep -v ^e\\.: /etc/aliases | grep -v ^e\\.: > \${TMP}
      cat \${TMP} > /etc/aliases
      newaliases
      rm \${TMP}
   fi
fi
_EOT_

chmod 555 DEBIAN/postinst
chmod 555 DEBIAN/prerm

cd ..

dpkg-deb --build debian
mv debian.deb ${HPASM}-${HPASM_DEB_SV}.deb


#
# Next CMASTOR
#

rm -rf debian
mkdir debian
cd debian
tar -xzf ../${CMASTOR}.tgz ./opt/compaq/storage

cd opt/compaq/storage

patch -p1 << _EOT_ > /dev/null
diff -Nur storage.orig/etc/cmaeventd storage/etc/cmaeventd
--- storage.orig/etc/cmaeventd	Wed Nov 19 16:59:37 2003
+++ storage/etc/cmaeventd	Fri Feb 13 16:21:18 2004
@@ -145,13 +145,19 @@
     eval \$2="2.0"
     return 0
   fi
+  test -f /etc/debian_version
+  if [ "\$?" = 0 ]; then
+    eval \$1="Debian"
+    eval \$2=""
+    return 0
+  fi
   return 9
 }
 
 # Identify OS Vendor
 VENDOR="Unknown"
 vendorversion "VENDOR" "VERSION"
-if [ "\$VENDOR" != "RedHat" -a "\$VENDOR" != "SuSE" -a "\$VENDOR" != "UnitedLinux" -a "\$VENDOR" != "VMware" ]; then
+if [ "\$VENDOR" != "RedHat" -a "\$VENDOR" != "SuSE" -a "\$VENDOR" != "UnitedLinux" -a "\$VENDOR" != "VMware" -a "\$VENDOR" != "Debian" ]; then
   echo "ERROR: the Linux OS running on your system is not supported!"
   exit 1
 fi
@@ -265,6 +271,44 @@
           status)
                 echo -n "Checking for \$PNAME: "
                 /sbin/checkproc \$PKGBIN/\$PNAME && echo OK || echo No process
+        	RETVAL=\$?
+                ;;
+          *)
+        	cmaecho "Usage: \$PNAME {start|stop|restart|status}"
+        	exit 1
+        esac
+
+        exit \$RETVAL
+        ;;
+  Debian)
+        RETVAL=0
+        PATH=\$PKGBIN:\$PATH
+        case "\$1" in
+          start)
+        	cmaechon "Starting \$NAME (\$PNAME): "
+                pidlist=\`pidof -o \$\$ \$PNAME\`
+                if [ -z "\$pidlist" ]; then
+                  \$PNAME \$PFLAGS >> \$LOGFILE 2>&1 &
+        	  RETVAL=\$?
+                else
+                  RETVAL=1
+                fi
+        	cmaecho
+        	;;
+          stop)
+        	cmaechon "Shutting down \$NAME (\$PNAME): "
+        	killall \$PKGBIN/\$PNAME 2>/dev/null
+        	RETVAL=\$?
+        	cmaecho
+        	;;
+          restart)
+                \$0 stop
+                \$0 start
+        	RETVAL=\$?
+                ;;
+          status)
+                echo -n "Checking for \$PNAME: "
+                status \$PNAME
         	RETVAL=\$?
                 ;;
           *)
diff -Nur storage.orig/etc/cmafcad storage/etc/cmafcad
--- storage.orig/etc/cmafcad	Wed Nov 19 16:59:37 2003
+++ storage/etc/cmafcad	Fri Feb 13 16:21:25 2004
@@ -145,13 +145,19 @@
     eval \$2="2.0"
     return 0
   fi
+  test -f /etc/debian_version
+  if [ "\$?" = 0 ]; then
+    eval \$1="Debian"
+    eval \$2=""
+    return 0
+  fi
   return 9
 }
 
 # Identify OS Vendor
 VENDOR="Unknown"
 vendorversion "VENDOR" "VERSION"
-if [ "\$VENDOR" != "RedHat" -a "\$VENDOR" != "SuSE" -a "\$VENDOR" != "UnitedLinux" -a "\$VENDOR" != "VMware" ]; then
+if [ "\$VENDOR" != "RedHat" -a "\$VENDOR" != "SuSE" -a "\$VENDOR" != "UnitedLinux" -a "\$VENDOR" != "VMware" -a "\$VENDOR" != "Debian" ]; then
   echo "ERROR: the Linux OS running on your system is not supported!"
   exit 1
 fi
@@ -271,6 +277,44 @@
         	cmaecho "Usage: \$PNAME {start|stop|restart|status}"
         	exit 1
         esac
+
+        exit \$RETVAL
+        ;;
+  Debian)
+        RETVAL=0
+        PATH=\$PKGBIN:\$PATH
+        case "\$1" in
+          start)
+                cmaechon "Starting \$NAME (\$PNAME): "
+                pidlist=\`pidof -o \$\$ \$PNAME\`
+                if [ -z "\$pidlist" ]; then
+                  \$PNAME \$PFLAGS >> \$LOGFILE 2>&1 &
+                  RETVAL=\$?
+                else  
+                  RETVAL=1
+                fi
+                cmaecho
+                ;;
+          stop)
+                cmaechon "Shutting down \$NAME (\$PNAME): "
+                killall \$PKGBIN/\$PNAME 2>/dev/null
+                RETVAL=\$?
+                cmaecho
+                ;;
+          restart)
+                \$0 stop
+                \$0 start
+                RETVAL=\$?
+                ;;
+          status)
+                echo -n "Checking for \$PNAME: "
+                status \$PNAME
+                RETVAL=\$?
+                ;;
+          *)
+                cmaecho "Usage: \$PNAME {start|stop|restart|status}"
+                exit 1
+        esac 
 
         exit \$RETVAL
         ;;
diff -Nur storage.orig/etc/cmaidad storage/etc/cmaidad
--- storage.orig/etc/cmaidad	Wed Nov 19 16:59:37 2003
+++ storage/etc/cmaidad	Fri Feb 13 16:21:05 2004
@@ -144,6 +144,12 @@
     eval \$2="2.0"
     return 0
   fi
+  test -f /etc/debian_version
+  if [ "\$?" = 0 ]; then
+    eval \$1="Debian"
+    eval \$2=""
+    return 0
+  fi
   return 9
 }
 
@@ -151,7 +157,7 @@
 # Identify OS Vendor
 VENDOR="Unknown"
 vendorversion "VENDOR" "VERSION"
-if [ "\$VENDOR" != "RedHat" -a "\$VENDOR" != "SuSE" -a "\$VENDOR" != "UnitedLinux" -a "\$VENDOR" != "VMware" ]; then
+if [ "\$VENDOR" != "RedHat" -a "\$VENDOR" != "SuSE" -a "\$VENDOR" != "UnitedLinux" -a "\$VENDOR" != "VMware" -a "\$VENDOR" != "Debian" ]; then
   echo "ERROR: the Linux OS running on your system is not supported!"
   exit 1
 fi
@@ -231,6 +237,44 @@
           *)
         	cmaecho "Usage: \$PNAME {start|stop|restart|status}"
         	exit 1
+        esac
+
+        exit \$RETVAL
+        ;;
+  Debian)
+        RETVAL=0
+        PATH=\$PKGBIN:\$PATH
+        case "\$1" in
+          start)
+                cmaechon "Starting \$NAME (\$PNAME): "
+                pidlist=\`pidof -o \$\$ \$PNAME\`
+                if [ -z "\$pidlist" ]; then
+                  \$PNAME \$PFLAGS >> \$LOGFILE 2>&1 &
+                  RETVAL=\$?
+                else
+                  RETVAL=1
+                fi
+                cmaecho
+                ;;
+          stop)
+                cmaechon "Shutting down \$NAME (\$PNAME): "
+                killall \$PKGBIN/\$PNAME 2>/dev/null
+                RETVAL=\$?
+                cmaecho
+                ;;
+          restart)
+                \$0 stop
+                \$0 start
+                RETVAL=\$?
+                ;;
+          status)
+                echo -n "Checking for \$PNAME: "
+                status \$PNAME
+                RETVAL=\$?
+                ;;
+          *)
+                cmaecho "Usage: \$PNAME {start|stop|restart|status}"
+                exit 1
         esac
 
         exit \$RETVAL
diff -Nur storage.orig/etc/cmaided storage/etc/cmaided
--- storage.orig/etc/cmaided	Wed Nov 19 16:59:37 2003
+++ storage/etc/cmaided	Fri Feb 13 16:21:34 2004
@@ -139,13 +139,19 @@
     eval \$2="2.0"
     return 0
   fi
+  test -f /etc/debian_version
+  if [ "\$?" = 0 ]; then
+    eval \$1="Debian"
+    eval \$2=""
+    return 0
+  fi
   return 9
 }
 
 # Identify OS Vendor
 VENDOR="Unknown"
 vendorversion "VENDOR" "VERSION"
-if [ "\$VENDOR" != "RedHat" -a "\$VENDOR" != "SuSE" -a "\$VENDOR" != "UnitedLinux" -a "\$VENDOR" != "VMware" ]; then
+if [ "\$VENDOR" != "RedHat" -a "\$VENDOR" != "SuSE" -a "\$VENDOR" != "UnitedLinux" -a "\$VENDOR" != "VMware" -a "\$VENDOR" != "Debian" ]; then
   echo "ERROR: the Linux OS running on your system is not supported!"
   exit 1
 fi
@@ -264,6 +270,44 @@
           *)
         	cmaecho "Usage: \$PNAME {start|stop|restart|status}"
         	exit 1
+        esac
+
+        exit \$RETVAL
+        ;;
+  Debian)
+        RETVAL=0
+        PATH=\$PKGBIN:\$PATH
+        case "\$1" in
+          start)
+                cmaechon "Starting \$NAME (\$PNAME): "
+                pidlist=\`pidof -o \$\$ \$PNAME\`
+                if [ -z "\$pidlist" ]; then
+                  \$PNAME \$PFLAGS >> \$LOGFILE 2>&1 &
+                  RETVAL=\$?
+                else
+                  RETVAL=1
+                fi
+                cmaecho
+                ;;
+          stop)
+                cmaechon "Shutting down \$NAME (\$PNAME): "
+                killall \$PKGBIN/\$PNAME 2>/dev/null
+                RETVAL=\$?
+                cmaecho
+                ;;
+          restart)
+                \$0 stop
+                \$0 start
+                RETVAL=\$?
+                ;;
+          status)
+                echo -n "Checking for \$PNAME: "
+                status \$PNAME
+                RETVAL=\$?
+                ;;
+          *)
+                cmaecho "Usage: \$PNAME {start|stop|restart|status}"
+                exit 1
         esac
 
         exit \$RETVAL
diff -Nur storage.orig/etc/cmascsid storage/etc/cmascsid
--- storage.orig/etc/cmascsid	Wed Nov 19 16:59:37 2003
+++ storage/etc/cmascsid	Fri Feb 13 16:21:39 2004
@@ -140,13 +140,19 @@
     eval \$2="2.0"
     return 0
   fi
+  test -f /etc/debian_version
+  if [ "\$?" = 0 ]; then
+    eval \$1="Debian"
+    eval \$2=""
+    return 0
+  fi
   return 9
 }
 
 # Identify OS Vendor
 VENDOR="Unknown"
 vendorversion "VENDOR" "VERSION"
-if [ "\$VENDOR" != "RedHat" -a "\$VENDOR" != "SuSE" -a "\$VENDOR" != "UnitedLinux" -a "\$VENDOR" != "VMware" ]; then
+if [ "\$VENDOR" != "RedHat" -a "\$VENDOR" != "SuSE" -a "\$VENDOR" != "UnitedLinux" -a "\$VENDOR" != "VMware" -a "\$VENDOR" != "Debian" ]; then
   echo "ERROR: the Linux OS running on your system is not supported!"
   exit 1
 fi
@@ -265,6 +271,44 @@
           *)
         	cmaecho "Usage: \$PNAME {start|stop|restart|status}"
         	exit 1
+        esac
+
+        exit \$RETVAL
+        ;;
+  Debian)
+        RETVAL=0
+        PATH=\$PKGBIN:\$PATH
+        case "\$1" in
+          start)
+                cmaechon "Starting \$NAME (\$PNAME): "
+                pidlist=\`pidof -o \$\$ \$PNAME\`
+                if [ -z "\$pidlist" ]; then
+                  \$PNAME \$PFLAGS >> \$LOGFILE 2>&1 &
+                  RETVAL=\$?
+                else
+                  RETVAL=1
+                fi
+                cmaecho
+                ;;  
+          stop)  
+                cmaechon "Shutting down \$NAME (\$PNAME): "
+                killall \$PKGBIN/\$PNAME 2>/dev/null
+                RETVAL=\$?
+                cmaecho
+                ;;  
+          restart)
+                \$0 stop
+                \$0 start
+                RETVAL=\$?
+                ;;
+          status)
+                echo -n "Checking for \$PNAME: "
+                status \$PNAME
+                RETVAL=\$?
+                ;;
+          *)
+                cmaecho "Usage: \$PNAME {start|stop|restart|status}"
+                exit 1
         esac
 
         exit \$RETVAL
diff -Nur storage.orig/etc/cmastor storage/etc/cmastor
--- storage.orig/etc/cmastor	Wed Nov 19 16:59:37 2003
+++ storage/etc/cmastor	Fri Feb 13 16:12:23 2004
@@ -157,6 +157,12 @@
     eval \$2="2.0"
     return 0
   fi
+  grep "Debian" /etc/issue >/dev/null 2>&1
+  if [ "\$?" = 0 ]; then
+    eval \$1="Debian"
+    eval \$2=""
+    return 0
+  fi
   return 9
 }
 
@@ -187,7 +193,9 @@
 
 if [ ! -f /etc/init.d/hpasm ]; then
     if [ ! -f /etc/init.d/cmafdtn ]; then
+    	if [ ! -f /etc/init.d/cpqhealth ]; then
             echo "Either cmafdtn or hpasm rpm should be installed"
+	fi
     fi
 fi
 
@@ -195,7 +203,7 @@
 # Identify OS Vendor
 VENDOR="Unknown"
 vendorversion "VENDOR" "VERSION"
-if [ "\$VENDOR" != "RedHat" -a "\$VENDOR" != "SuSE" -a "\$VENDOR" != "UnitedLinux" -a "\$VENDOR" != "VMware" ]; then
+if [ "\$VENDOR" != "RedHat" -a "\$VENDOR" != "SuSE" -a "\$VENDOR" != "UnitedLinux" -a "\$VENDOR" != "VMware" -a "\$VENDOR" != "Debian" ]; then
   echo "ERROR: the Linux OS running on your system is not supported!"
   exit 1
 fi
@@ -403,6 +411,84 @@
         case "\$OPCODE" in
           start)
                   if [ -z "\$AGENTS" ]; then # start all agents
+        	    cmaecho "Starting \$NAME (\$PNAME): All agents"
+                    for AGENT in \$PNAMES; do
+                      [ -x \$ETCROOT/\$AGENT ] && \$ETCROOT/\$AGENT start
+                    done
+                  else
+        	    cmaecho "Starting \$NAME (\$PNAME): \$AGENTS"
+                    for AGENT in \$AGENTS; do
+                      [ -x \$ETCROOT/\$AGENT ] && \$ETCROOT/\$AGENT start
+                    done
+                  fi
+        	  [ "\$VARLOCKSUBSYS" = "1" ] && touch /var/lock/subsys/\$PNAME
+        	cmaecho
+        	;;
+          stop)
+                if [ -z "\$AGENTS" ]; then #stop all agents
+        	  cmaecho "Shutting down \$NAME (\$PNAME): All agents"
+                  for AGENT in \$PNAMES; do
+                    [ -x \$ETCROOT/\$AGENT ] && \$ETCROOT/\$AGENT stop
+                  done
+                else
+        	  cmaecho "Shutting down \$NAME (\$PNAME): \$AGENTS"
+                  for AGENT in \$AGENTS; do
+                    [ -x \$ETCROOT/\$AGENT ] && \$ETCROOT/\$AGENT stop
+                  done
+                fi
+        	if  [ "\$VARLOCKSUBSYS" = "1" ]; then
+                  REMOVELOCK=1
+                  for AGENT in \$PNAMES; do
+                    pidlist=\`pidof -o \$\$ \$AGENT\`
+                    if [ ! -z "\$pidlist" ]; then
+                      REMOVELOCK=0
+                      break;
+                    fi
+                  done
+        	  [ \$REMOVELOCK = "1" ] && rm -f /var/lock/subsys/\$PNAME
+                fi
+        	cmaecho
+        	;;
+          restart)
+                if [ -z "\$AGENTS" ]; then #restart all agents
+        	  cmaecho "Re-starting \$NAME (\$PNAME): All agents"
+                  for AGENT in \$PNAMES; do
+                    [ -x \$ETCROOT/\$AGENT ] && \$ETCROOT/\$AGENT restart
+                  done
+                else
+        	  cmaecho "Re-starting \$NAME (\$PNAME): \$AGENTS"
+                  for AGENT in \$AGENTS; do
+                    [ -x \$ETCROOT/\$AGENT ] && \$ETCROOT/\$AGENT restart
+                  done
+                fi
+        	cmaecho
+                ;;
+          status)
+                if [ -z "\$AGENTS" ]; then #status all agents
+                  for AGENT in \$PNAMES; do
+                    [ -x \$ETCROOT/\$AGENT ] && \$ETCROOT/\$AGENT status
+                  done
+                else
+                  for AGENT in \$AGENTS; do
+                    [ -x \$ETCROOT/\$AGENT ] && \$ETCROOT/\$AGENT status
+                  done
+                fi
+        	RETVAL=\$?
+                ;;
+          *)
+        	cmausage
+        	exit 1
+        esac
+
+        exit \$RETVAL
+        ;;
+  Debian )
+        RETVAL=0
+        # source function library
+        PATH=/opt/compaq/storage/bin:\$PATH
+        case "\$OPCODE" in
+          start)
+                  if [ -z "\$AGENTS" ]; then #start all agents
         	    cmaecho "Starting \$NAME (\$PNAME): All agents"
                     for AGENT in \$PNAMES; do
                       [ -x \$ETCROOT/\$AGENT ] && \$ETCROOT/\$AGENT start
diff -Nur storage.orig/etc/cmastorpeerd storage/etc/cmastorpeerd
--- storage.orig/etc/cmastorpeerd	Wed Nov 19 16:59:37 2003
+++ storage/etc/cmastorpeerd	Fri Feb 13 16:21:45 2004
@@ -140,13 +140,19 @@
     eval \$2="2.0"
     return 0
   fi
+  test -f /etc/debian_version
+  if [ "\$?" = 0 ]; then
+    eval \$1="Debian"
+    eval \$2=""
+    return 0
+  fi
   return 9
 }
 
 # Identify OS Vendor
 VENDOR="Unknown"
 vendorversion "VENDOR" "VERSION"
-if [ "\$VENDOR" != "RedHat" -a "\$VENDOR" != "SuSE" -a "\$VENDOR" != "UnitedLinux" -a "\$VENDOR" != "VMware" ]; then
+if [ "\$VENDOR" != "RedHat" -a "\$VENDOR" != "SuSE" -a "\$VENDOR" != "UnitedLinux" -a "\$VENDOR" != "VMware" -a "\$VENDOR" != "Debian" ]; then
   echo "ERROR: the Linux OS running on your system is not supported!"
   exit 1
 fi
@@ -271,6 +277,44 @@
           *)
         	cmaecho "Usage: \$PNAME {start|stop|restart|status}"
         	exit 1
+        esac
+
+        exit \$RETVAL
+        ;;
+  Debian)   
+        RETVAL=0
+        PATH=\$PKGBIN:\$PATH
+        case "\$1" in
+          start)  
+                cmaechon "Starting \$NAME (\$PNAME): "
+                pidlist=\`pidof -o \$\$ \$PNAME\`
+                if [ -z "\$pidlist" ]; then
+                  \$PNAME \$PFLAGS >> \$LOGFILE 2>&1 &
+                  RETVAL=\$?
+                else
+                  RETVAL=1
+                fi
+                cmaecho
+                ;;
+          stop)
+                cmaechon "Shutting down \$NAME (\$PNAME): "
+                killall \$PKGBIN/\$PNAME 2>/dev/null
+                RETVAL=\$?
+                cmaecho
+                ;;
+          restart)
+                \$0 stop
+                \$0 start
+                RETVAL=\$?
+                ;;
+          status)
+                echo -n "Checking for \$PNAME: "
+                status \$PNAME
+                RETVAL=\$?
+                ;;
+          *)
+                cmaecho "Usage: \$PNAME {start|stop|restart|status}"
+                exit 1
         esac
 
         exit \$RETVAL
_EOT_

cd ../../..

mkdir -p etc/init.d
ln -s /opt/compaq/storage/etc/cmastor etc/init.d/cmastor

mkdir DEBIAN
chmod 755 DEBIAN

cat << _EOT_ > DEBIAN/control
Package: cmastor
Section: util
Maintainer: Kianusch Sayah Karadji 
Architecture: i386
Version: 7.0.0-${CMASTOR_DEB_SV}
Provides: cmastor
Description: cmastor
Pre-Depends: hpasm, libstdc++2.9-glibc2.1, snmpd
_EOT_

cat << _EOT_ > DEBIAN/postinst
#! /bin/sh
# postinst script for cmastor
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        *  'configure' 
#        *  'abort-upgrade' 
#        *  'abort-remove' 'in-favour' 
#          
#        *  'abort-deconfigure' 'in-favour'
#            'removing'
#           
# for details, see /usr/share/doc/packaging-manual/
#
# quoting from the policy:
#     Any necessary prompting should almost always be confined to the
#     post-installation script, and should be protected with a conditional
#     so that unnecessary prompting doesn't happen if a package's
#     installation fails and the 'postinst' is called with 'abort-upgrade',
#     'abort-remove' or 'abort-deconfigure'.

case "\$1" in
    configure)

    # /var/spool/compaq should be created by cpqhealth
    if [ ! -d /var/spool/compaq ]; then
      mkdir -p /var/spool/compaq
      chmod 700 /var/spool/compaq
    fi

    if [ ! -d /var/spool/compaq/storage/registry ]; then
       mkdir -p /var/spool/compaq/storage/registry
       chmod 700 /var/spool/compaq
       chmod 700 /var/spool/compaq/storage
       chmod 700 /var/spool/compaq/storage/registry
    fi

    # Create /opt/compaq/cma.conf if it does not exist
    CMACONF=/opt/compaq/cma.conf
    if [ ! -f \$CMACONF ]; then
      cat <\$CMACONF
#trapemail command. Multiple trapemail lines are allowed
trapemail /usr/bin/mail -s 'HP Insight Management Agents Trap Alarm' root
EOF
      chmod 700 \$CMACONF
    fi

    # Create /opt/compaq/storage/.version if it does not exist
    VERSIONFILE=/opt/compaq/storage/.version
    if [ ! -f \$VERSIONFILE ]; then
      echo "cmastor|6.50.0-1|Linux Storage Agents"  >\$VERSIONFILE
    fi
 
    #Add cmastorobjects.conf to cmaobjects.conf
    CONFFILE=/opt/compaq/cmaobjects.conf
    OBJSFILE="/opt/compaq/storage/etc/cmastorobjects.conf"
    if [ ! -f \$CONFFILE ]; then
      echo \$OBJSFILE  >>\$CONFFILE
    else
      #check if the entry is already there
      grep \$OBJSFILE \$CONFFILE >/dev/null
      if [ "\$?" != 0 ]; then
        echo \$OBJSFILE >>\$CONFFILE
      fi
    fi


        update-rc.d cmastor start 28 S . stop 80 1 .
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)

    ;;

    *)
        echo "postinst called with unknown argument '\$1'" >&2
        exit 0
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
_EOT_

cat << _EOT_ > DEBIAN/prerm
#! /bin/sh

set -e

if [ "\$1" = "upgrade" -o "\$1" = "remove" ]; then
   /etc/init.d/cmastor stop

   
   rm -rf /var/spool/compaq/storage
   rmdir --ignore-fail-on-non-empty /var/spool/compaq
   rm -f /opt/compaq/cma.conf
   rm -f /opt/compaq/cmaobjects.conf
   rm -f /opt/compaq/storage/.version
fi
_EOT_

chmod 555 DEBIAN/postinst
chmod 555 DEBIAN/prerm

cd ..

dpkg-deb --build debian
mv debian.deb ${CMASTOR}-${CMASTOR_DEB_SV}.deb

#
# Last CPQACUXE
#

rm -rf debian
mkdir debian
cd debian
tar -xzf ../${CPQACUXE}.tgz

mkdir DEBIAN
chmod 755 DEBIAN

cat << _EOT_ > DEBIAN/control
Package: cpqacuxe
Section: util
Maintainer: Kianusch Sayah Karadji 
Architecture: i386
Version: 7.0-${CPQACUXE_DEB_SV}
Provides: cpqacuxe
Description: cpqacuxe
Pre-Depends: libstdc++2.9-glibc2.1
Suggests: hpasm
_EOT_

cat << _EOT_ > DEBIAN/postinst
#! /bin/sh
# postinst script for hpasm
#
# see: dh_installdeb(1)

## set -e

# summary of how this script can be called:
#        *  'configure' 
#        *  'abort-upgrade' 
#        *  'abort-remove' 'in-favour' 
#          
#        *  'abort-deconfigure' 'in-favour'
#            'removing'
#           
# for details, see /usr/share/doc/packaging-manual/
#
# quoting from the policy:
#     Any necessary prompting should almost always be confined to the
#     post-installation script, and should be protected with a conditional
#     so that unnecessary prompting doesn't happen if a package's
#     installation fails and the 'postinst' is called with 'abort-upgrade',
#     'abort-remove' or 'abort-deconfigure'.

case "\$1" in
    configure)
       INSTALL_ROOT=/opt/compaq/cpqacuxe
       cd "\$INSTALL_ROOT"
       ln -sf HTML "\$INSTALL_ROOT"/html
       cd HTML
       ln -sf images "\$INSTALL_ROOT"/HTML/Images
       ln -sf eng "\$INSTALL_ROOT"/HTML/ENG
       LINK_GOES_TO=/usr/sbin
       mkdir -p \$LINK_GOES_TO
       chmod 100 \$LINK_GOES_TO/cpqacuxe
       
       \$INSTALL_ROOT/bld/hpwebsetup -q: &>/dev/null
       if [ "\$?" = 5 ]; then
          echo " "
          echo " "
          echo "  ********************************************************"
          echo "  WARNING: Currently the HP HMMO administrator password"
          echo "  is NOT configured. You may be prompted to set the password"
          echo "  when you run cpqacuxe for the first time."
          echo "  ********************************************************"
       fi
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)

    ;;

    *)
        echo "postinst called with unknown argument '\$1'" >&2
        exit 0
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
_EOT_

cat << _EOT_ > DEBIAN/prerm
#! /bin/sh

# set -e

if [ "\$1" = "upgrade" -o "\$1" = "remove" ]; then
   cpqacuxe -stop
   INSTALL_ROOT=/opt/compaq/cpqacuxe
   rm \$INSTALL_ROOT/html/ENG
   rm \$INSTALL_ROOT/html/Images
   rm \$INSTALL_ROOT/html
   rm -rf /var/spool/compaq/wbem
fi
_EOT_


chmod 555 DEBIAN/postinst
chmod 555 DEBIAN/prerm

cd ..

dpkg-deb --build debian
mv debian.deb ${CPQACUXE}-${CPQACUXE_DEB_SV}.deb

rm -rf debian

echo ""
echo "You can install those packages with:"
echo ""
echo "  # dpkg -i hpasm-7.0.0-${HPASM_DEB_SV}.deb"
echo "  # dpkg -i cmastor-7.0.0-${CMASTOR_DEB_SV}.deb"
echo "  # dpkg -i cpqacuxe-7.0-${CPQACUXE_DEB_SV}.deb"
echo ""
echo "Make sure you have all the dependencies installed on your system:"
echo ""
echo "  # apt-get install libstdc++2.9-glibc2.1 snmpd tcl8.3 tix41 tclx8.3"
echo ""
echo "And reboot your server after installation.  This mostly helps,"
echo "if you feel something weird going on :)"
echo ""
echo "Questions?"
echo ""
echo "You can reach me at kianusch@sk-tech.net"
echo ""
echo "HAVE FUN!"