From 953e3fd506abed09dee8b352e7d40c0e5451258f Mon Sep 17 00:00:00 2001
From: Mario Fetka <mario@localhost.localdomain>
Date: Fri, 10 Nov 2017 18:25:52 +0100
Subject: [PATCH] add debain parts

---
 build_orig.sh        |   8 +-
 debian/3dm2.8        |  35 +++++++++
 debian/README.Debian |  13 ++++
 debian/changelog     |  47 ++++++++++++
 debian/compat        |   1 +
 debian/control       |  21 +++++
 debian/copyright     | 177 +++++++++++++++++++++++++++++++++++++++++++
 debian/dirs          |   5 ++
 debian/docs          |   1 +
 debian/init          | 114 ++++++++++++++++++++++++++++
 debian/links         |   1 +
 debian/manpages      |   1 +
 debian/postrm        |  17 +++++
 debian/rules         |  76 +++++++++++++++++++
 files.diz            |   4 +-
 15 files changed, 518 insertions(+), 3 deletions(-)
 create mode 100644 debian/3dm2.8
 create mode 100644 debian/README.Debian
 create mode 100644 debian/changelog
 create mode 100644 debian/compat
 create mode 100644 debian/control
 create mode 100644 debian/copyright
 create mode 100644 debian/dirs
 create mode 100644 debian/docs
 create mode 100644 debian/init
 create mode 100644 debian/links
 create mode 100644 debian/manpages
 create mode 100644 debian/postrm
 create mode 100755 debian/rules

diff --git a/build_orig.sh b/build_orig.sh
index bc5ab97..3254ecd 100644
--- a/build_orig.sh
+++ b/build_orig.sh
@@ -42,12 +42,18 @@ do
   mkdir -p $WORK_DIR/${type}
   pushd $WORK_DIR/${type}
   unzip $DIR/../$outputfile
-  tar -zxf *.tgz
+  tar -zxf tdmCliLnx.tgz
+  mkdir msg
+  tar -zxf tdm2Msg.tgz -C msg
+  mkdir help
+  tar -zxf tdm2Help.tgz -C help
   popd
   mkdir -p $WORK_DIR/${app}-${version}/${type}
   dos2unix $WORK_DIR/${type}/*.txt
   mv $WORK_DIR/${type}/*.txt $WORK_DIR/${app}-${version}
   mv $WORK_DIR/${type}/3dm2* $WORK_DIR/${app}-${version}/${type}
+  mv $WORK_DIR/${type}/msg $WORK_DIR/${app}-${version}
+  mv $WORK_DIR/${type}/help $WORK_DIR/${app}-${version}
   pushd $WORK_DIR/${app}-${version}/${type}
   case "${type}" in
     "amd64" )
diff --git a/debian/3dm2.8 b/debian/3dm2.8
new file mode 100644
index 0000000..4437671
--- /dev/null
+++ b/debian/3dm2.8
@@ -0,0 +1,35 @@
+.TH 3DM2 8 "2012-01-30" "2.11.00.019+10.2.1" "3Ware Disk Management"
+
+.SH NAME
+3dm2 \- 3ware 3DM 2 Disk Management Utility.
+
+.SH SYNOPSIS
+.B 3dm2
+
+.SH DESCRIPTION
+3ware Disk Manager 2 (3DM 2), allows you to view the status of and manage 3ware
+RAID controllers and associated drives. 3DM 2 runs as a daemon. When it is
+running, you can use your browser to view status and perform administrative
+tasks locally or remotely.
+.PP
+This version of 3DM2 supports all known 3Ware controllers.
+
+.SH OPTIONS
+.B 3dm2
+has no options.
+
+.SH CONFIGURATION
+In /etc/3dm2/3dm2.conf, the following defaults are set:
+.TP
+3DM 2 is listening on <https://localhost:888/>.
+.TP
+Default password for both the user and the administrator is '3ware'.
+.TP
+Remote access is disabled for security reasons (change 'RemoteAccess 0' to 'RemoteAcces 1' to enable it and restart the 3dm2 daemon).
+.PP
+
+.SH AUTHOR
+3dm2 was written by the AMCC 3DM 2 Development Team.
+.PP
+This manual page was written by Jonas Genannt <jonas.genannt@capi2name.de> for
+the Debian project (but may be used by others).
diff --git a/debian/README.Debian b/debian/README.Debian
new file mode 100644
index 0000000..028efed
--- /dev/null
+++ b/debian/README.Debian
@@ -0,0 +1,13 @@
+3dm2 for Debian
+----------------
+
+3DM2 is listening on <https://127.0.0.1:888/> as default.
+Please note that, for evident security reason, it's not available from any
+remote computer.
+You can change this behavior by modifying /etc/3dm2/3dm2.conf and by setting
+RemoteAccess to 1. After modifying the value, please, do restart the service.
+
+Default passwords for both user and administrator are '3ware'.
+PLEASE CHANGE THESE PASSWORDS *BEFORE* ENABLING REMOTE ACCESS !
+
+ -- Adam Cécile (Le_Vert) <gandalf@le-vert.net>  Mon, 30 Jan 2012 14:28:34 +0100
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..07e788d
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,47 @@
+3dm2 (2.11.00.019+10.2.1+KB16625-1) unstable; urgency=low
+
+  * New upstream release:
+    - Update binaries according to:
+      http://kb.lsi.com/KnowledgebaseArticle16625.aspx (Closes: #226).
+
+ -- Adam Cécile (Le_Vert) <gandalf@le-vert.net>  Mon, 24 Sep 2012 21:41:47 +0200
+
+3dm2 (2.11.00.019+10.2.1-1) unstable; urgency=low
+
+  * New upstream release.
+  * Do not use separate tarball for each architecture anymore.
+  * Improve debian/copyright to explain how to generate sources tarball.
+  * Update licence and copyright information.
+
+ -- Adam Cécile (Le_Vert) <gandalf@le-vert.net>  Mon, 30 Jan 2012 14:28:34 +0100
+
+3dm2-x86-64 (2.11.00.016+10.2-1) unstable; urgency=low
+
+  * New upstream release.
+
+ -- Adam Cécile (Le_Vert) <gandalf@le-vert.net>  Mon, 19 Sep 2011 22:04:56 +0200
+
+3dm2-x86-64 (2.09.00.009+9.5.2-2) unstable; urgency=low
+
+  * Disable logger which breaks daemon's start.
+
+ -- Adam Cécile (Le_Vert) <gandalf@le-vert.net>  Wed, 08 Jul 2009 19:24:27 +0200
+
+3dm2-x86-64 (2.09.00.009+9.5.2-1) unstable; urgency=low
+
+  * New upstream release.
+
+ -- Adam Cécile (Le_Vert) <gandalf@le-vert.net>  Tue, 07 Jul 2009 19:57:18 +0200
+
+3dm2-x86-64 (2.08.00.008+9.5.1.1-1) unstable; urgency=low
+
+  * New upstream release.
+  * Better versionning.
+
+ -- Adam Cécile (Le_Vert) <gandalf@le-vert.net>  Mon, 22 Dec 2008 13:04:31 +0100
+
+3dm2-x86-64 (2.07.00.009-1) unstable; urgency=low
+
+  * Initial release.
+
+ -- Adam Cécile (Le_Vert) <gandalf@le-vert.net>  Tue, 26 Aug 2008 14:10:59 +0200
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..7ed6ff8
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..1fbf56a
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,21 @@
+Source: 3dm2
+Section: admin
+Priority: optional
+Maintainer: Adam Cécile (Le_Vert) <gandalf@le-vert.net>
+Build-Depends: debhelper (>= 5)
+Standards-Version: 3.9.2
+Homepage: http://www.3ware.com
+
+Package: 3dm2
+Architecture: amd64 i386
+Depends: ${shlibs:Depends}, ${misc:Depends}, lsb-base, exim4 | postfix | sendmail | mail-transport-agent
+Description: 3ware 3DM2 RAID HBAs Management Utility
+ 3ware Disk Manager 2 (3DM2), allows you to view the status of and manage
+ 3ware RAID controllers and associated drives.
+ .
+ 3DM2 runs as a daemon. When it is running, you can use your browser to view
+ status and perform administrative tasks locally or remotely.
+ .
+ It can also be used to report RAID failures by mail.
+ .
+ This package supports all known 3Ware controller.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..83b7108
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,177 @@
+This package was debianized by Adam Cécile (Le_Vert) <gandalf@le-vert.net> on
+Tue, 26 Aug 2008 14:10:59 +0200.
+
+It was downloaded from http://www.3ware.com/support/download.asp
+
+Upstream Author:
+
+  LSI Corporation
+
+Copyright:
+
+  Copyright (C) 2011 LSI Corporation
+  Copyright (c) 2004, 2005 Applied Micro Circuits Corporation (AMCC)
+  Copyright (C) 2002, 2003, 2004 3ware, Inc.
+
+License:
+
+  STOP!
+
+  BEFORE YOU INSTALL OR USE THIS SOFTWARE 
+
+  Carefully read this Software License Agreement. Installing or using this
+  software (the "Software") and the related documentation, (the
+  "Documentation"), indicates that you agree to abide by this Software
+  License Agreement. If you do not agree with it, promptly
+  return the Software and we will refund the purchase price.
+
+  Software License Agreement
+  THE SOFTWARE AND DOCUMENTATION PROVIDED HEREIN IS PROPRIETARY TO LSI
+  CORPORATION AND ITS LICENSORS. LSI CORPORATION IS WILLING TO LICENSE THE
+  SOFTWARE AND DOCUMENTATION TO YOU ONLY UPON THE CONDITION THAT YOU ACCEPT
+  ALL OF THE TERMS CONTAINED IN THIS SOFTWARE LICENSE AGREEMENT. BY USING
+  THIS SOFTWARE, YOU, THE END-USER, AGREE TO THE LICENSE TERMS BELOW. IF YOU
+  DO NOT AGREE TO THESE TERMS, YOU MAY NOT USE THE SOFTWARE.
+
+  1. Grant of License
+  Conditioned upon compliance with the terms and conditions of this Software
+  License Agreement ("Agreement"), LSI Corporation ("LSI") grants you, the
+  original licensee, a nonexclusive and nontransferable limited license to
+  use (including installation on multiple computers) for your internal
+  business purposes the Software and the Documentation, ("Permitted Use").
+
+  2. License Conditions; Confidentiality
+  The Software and Documentation are confidential information of LSI and its
+  licensors. Except as expressly permitted herein, you may not disclose or
+  give copies of the Software or Documentation to others and you may not let
+  others gain access to the same. You may not post the Software or
+  Documentation, or otherwise make available, in any form, on the Internet or
+  in other public places or media. You may not modify, adapt, translate,
+  rent, lease, loan, distribute or resell for profit, or create derivative
+  works based upon, the Software or Documentation or any part of thereof, but
+  you may transfer the original media containing the Software and
+  Documentation on a one-time basis provided you retain no copies of the
+  Software and Documentation and the recipient assumes all of the terms of
+  this Agreement. You may not reverse engineer, decompile, disassemble or
+  otherwise attempt to derive source code from the Software except to the
+  extent allowed by law.
+
+  3. No Warranty
+  LSI grants a limited warranty only to the original licensee, that the
+  Software will perform substantially in accordance with the Documentation
+  prepared by LSI for a period of ninety (90) days from the date of receipt
+  by the original licensee. LSI's entire liability and the licensee's
+  exclusive remedy for breach of the limited warranty above shall be, at
+  LSI's sole option and discretion, either: (a) the repair or replacement of
+  the non-conforming Software which is returned to LSI and determined by LSI
+  to be non-conforming, or (b) the return of the price the original licensee
+  paid solely for the Software. This limited warranty is void if the
+  non-conformance of the Software results from accident, abuse, negligence,
+  misapplication, or failure to use the Software in accordance with the
+  Documentation. Any replacement Software will be warranted to the original
+  licensee for the remainder of the original warranty period, or thirty (30)
+  days, whichever is longer. EXCEPT AS SPECIFIED EXPRESSLY IN THIS LIMITED
+  WARRANTY, ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS, AND
+  WARRANTIES INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTY OR CONDITION
+  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT,
+  SATISFACTORY QUALITY, NON-INTERFERENCE, ACCURACY OF INFORMATIONAL CONTENT,
+  OR ARISING FROM A COURSE OF DEALING, LAW, USAGE, OR TRADE PRACTICE, ARE
+  HEREBY EXCLUDED TO THE EXTENT ALLOWED BY APPLICABLE LAW AND ARE EXPRESSLY
+  DISCLAIMED BY LSI, ITS SUPPLIERS AND LICENSORS. TO THE EXTENT AN IMPLIED
+  WARRANTY CANNOT BE EXCLUDED, SUCH WARRANTY IS LIMITED IN DURATION TO THE
+  EXPRESS WARRANTY PERIOD. BECAUSE SOME STATES OR JURISDICTIONS DO NOT ALLOW
+  LIMITATIONS ON HOW LONG AN IMPLIED WARRANTY LASTS, THE ABOVE LIMITATION MAY
+  NOT APPLY. THIS WARRANTY GIVES YOU SPECIFIC LEGAL RIGHTS, AND YOU MAY ALSO
+  HAVE OTHER RIGHTS WHICH VARY FROM JURISDICTION TO JURISDICTION. This
+  disclaimer and exclusion shall apply even if the express warranty set forth
+  above fails of its essential purpose.
+
+  4. LIMITATION OF LIABILITY AND REMEDIES
+  IN NO EVENT SHALL LSI OR ITS LICENSORS BE LIABLE TO YOU FOR ANY INDIRECT,
+  CONSEQUENTIAL, EXEMPLARY, INCIDENTAL OR SPECIAL DAMAGES ARISING FROM THIS
+  AGREEMENT OR THE USE OF THE SOFTWARE OR DOCUMENTATION (INCLUDING, WITHOUT
+  LIMITATION, DAMAGE FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
+  LOSS OF BUSINESS INFORMATION, LOSS OF GOODWILL, OR OTHER PECUNIARY LOSS),
+  WHETHER RESULTING FROM LSI'S NEGLIGENCE OR OTHERWISE, EVEN IF LSI WAS
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. LSI'S MAXIMUM LIABILITY FOR ANY
+  DAMAGES ARISING UNDER THIS AGREEMENT AND THE USE OF THE SOFTWARE AND
+  DOCUMENTATION WILL NOT EXCEED AN AMOUNT EQUAL TO THE LICENSE FEES YOU PAID
+  TO LSI FOR THE SOFTWARE AND DOCUMENTATION. THE LAWS OF SOME JURISDICTIONS
+  DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY, AND THE ABOVE
+  EXCLUSION MAY NOT APPLY TO YOU.
+
+  5. U.S. Government End User Purchasers
+  The Software and Documentation qualify as "commercial items," as that term
+  is defined at Federal Acquisition Regulation ("FAR") (48 C.F.R.) 2.101,
+  consisting of "commercial computer software" and "commercial computer
+  software documentation" as such terms are used in FAR 12.212. Consistent
+  with FAR 12.212 and DoD FAR Supp. 227.7202-1 through 227.7202-4, and
+  notwithstanding any other FAR or other contractual clause to the contrary,
+  you may provide to Government end user or, if this Agreement is direct,
+  Government end user will acquire, the Software and Documentation with only
+  those rights set forth in this Agreement. Use of either the Software or
+  Documentation or both constitutes agreement by the Government that the
+  Software and Documentation are "commercial computer software" and
+  "commercial computer software documentation," and constitutes acceptance of
+  the rights and restrictions herein.
+
+  6. Term And Termination
+  You may terminate this Agreement at any time, and it will automatically
+  terminate if you fail to comply with it. If terminated, you must
+  immediately destroy the Documentation and the Software and all copies you
+  have made.
+
+  7. Audit Rights
+  LSI shall have the right on reasonable notice, at its own cost and no more
+  than once per year, directly or through its independent auditors, to
+  inspect, examine, take extracts, and make copies from, your records to the
+  extent reasonably necessary to verify your compliance with the terms and
+  conditions of this Agreement. This right shall apply during the term of
+  this Agreement and for one (1) year thereafter.
+
+  8. Export
+  You may not export this Software or Documentation, unless you have complied
+  with applicable United States and foreign government laws.
+
+  9. General
+  You assume full responsibility for the legal and responsible use of the
+  Software and Documentation. You agree that this Agreement is the complete
+  agreement between you and LSI (and that any verbal or written statements
+  that are not reflected in this Agreement and any prior agreements, are
+  superseded by this Agreement). To be effective, any amendment of this
+  Agreement must be in writing and signed by both you and LSI. Should any
+  provisions of this Agreement be held to be unenforceable, then such
+  provision shall be separable from this Agreement and shall not affect the
+  remainder of the Agreement. This Agreement shall be governed by California
+  law, not including its choice of law provisions. The United Nations
+  Convention on the International Sale of Goods shall not be applied to this
+  Agreement. All rights in the Software and Documentation not specifically
+  granted in this Agreement are reserved by LSI or its licensors. The English
+  language version of this Agreement shall be the official version. The terms
+  and conditions of this Software License Agreement shall be binding upon you
+  and your respective heirs, successors and assigns.
+
+  10. Survival
+  The provisions of Sections 2, 3, 4, 7, 8 and 9 shall survive any
+  termination of this Agreement.
+
+
+The Debian packaging is Copyright (C) 2008-2012 Adam Cécile (Le_Vert)
+<gandalf@le-vert.net> and is licensed under GNU General  Public License
+version 2 (or later) see `/usr/share/common-licenses/GPL-2'.
+
+
+Please note that AMMC provides 3DM2 only through an shell based installer.
+
+This source package has been repacked to include binary, conf ,documentation
+and localisation files extracted from the package by running the installer on
+my system (press Ctrl+C as soon as it says 'Cleaning files'). All you need is
+now available in /tmp/3ware.
+
+Here is MD5 of the package used to create this source package:
+  b7d718ede4ebbc7d31e7cf5c95d5a33d  10.2.1-Codeset-Complete.iso
+
+Later, binaries have been updated according to this page:
+http://kb.lsi.com/KnowledgebaseArticle16625.aspx
+  32202e87ba0f13f1bc3cc70db439b8ab  3dm2.x86
+  b497b6a04edcea049a251ff54925c21a  3dm2.x86_64
diff --git a/debian/dirs b/debian/dirs
new file mode 100644
index 0000000..7a40e05
--- /dev/null
+++ b/debian/dirs
@@ -0,0 +1,5 @@
+usr/sbin
+etc/3dm2
+usr/share/3dm2
+usr/share/doc/3dm2
+var/lock/subsys
diff --git a/debian/docs b/debian/docs
new file mode 100644
index 0000000..2211df6
--- /dev/null
+++ b/debian/docs
@@ -0,0 +1 @@
+*.txt
diff --git a/debian/init b/debian/init
new file mode 100644
index 0000000..6ff15c8
--- /dev/null
+++ b/debian/init
@@ -0,0 +1,114 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:          3dm2
+# Required-Start:    $local_fs $remote_fs $syslog $network
+# Required-Stop:     $local_fs $remote_fs $syslog $network
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: 3ware 3DM2 RAID HBAs Management Utility
+# Description:       This initscript start the 3dm2 as daemon.
+### END INIT INFO
+
+# Author: Adam Cécile (Le_Vert) <gandalf@le-vert.net>
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC="3ware 3DM2 RAID HBAs Management Utility"
+NAME=3dm2
+DAEMON=/usr/sbin/$NAME
+SCRIPTNAME=/etc/init.d/$NAME
+LOCKFILE=/var/lock/subsys/3dm2
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
+. /lib/lsb/init-functions
+
+# Function that starts the daemon/service
+do_start()
+{
+	# Return
+	#   0 if daemon has been started
+	#   1 if daemon was already running
+	#   2 if daemon could not be started
+	start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \
+		|| return 1
+	start-stop-daemon --start --quiet --exec $DAEMON -- \
+		|| return 2
+	touch $LOCKFILE
+}
+
+# Function that stops the daemon/service
+do_stop()
+{
+	# Return
+	#   0 if daemon has been stopped
+	#   1 if daemon was already stopped
+	#   2 if daemon could not be stopped
+	#   other if a failure occurred
+	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --exec $DAEMON
+	RETVAL="$?"
+	[ "$RETVAL" = 2 ] && return 2
+	# Wait for children to finish too if this is a daemon that forks
+	# and if the daemon is only ever run from this initscript.
+	# If the above conditions are not satisfied then add some other code
+	# that waits for the process to drop all resources that could be
+	# needed by services started subsequently.  A last resort is to
+	# sleep for some time.
+	start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
+	[ "$?" = 2 ] && return 2
+	rm -f $LOCKFILE
+	return "$RETVAL"
+}
+
+case "$1" in
+  start)
+	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+	do_start
+	case "$?" in
+		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+	esac
+	;;
+  stop)
+	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+	do_stop
+	case "$?" in
+		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+	esac
+	;;
+  restart|force-reload)
+	log_daemon_msg "Restarting $DESC" "$NAME"
+	do_stop
+	sleep 1
+	case "$?" in
+	  0|1)
+		do_start
+		case "$?" in
+			0) log_end_msg 0 ;;
+			1) log_end_msg 1 ;; # Old process is still running
+			*) log_end_msg 1 ;; # Failed to start
+		esac
+		;;
+	  *)
+	  	# Failed to stop
+		log_end_msg 1
+		;;
+	esac
+	;;
+  *)
+	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
+	exit 3
+	;;
+esac
+
+:
diff --git a/debian/links b/debian/links
new file mode 100644
index 0000000..6e96b84
--- /dev/null
+++ b/debian/links
@@ -0,0 +1 @@
+usr/share/doc/3dm2/html/en/OLH_3DM_2_First.html	usr/share/doc/3dm2/html/en/index.html
diff --git a/debian/manpages b/debian/manpages
new file mode 100644
index 0000000..a59af0f
--- /dev/null
+++ b/debian/manpages
@@ -0,0 +1 @@
+debian/3dm2.8
diff --git a/debian/postrm b/debian/postrm
new file mode 100644
index 0000000..9762bc9
--- /dev/null
+++ b/debian/postrm
@@ -0,0 +1,17 @@
+#!/bin/sh -e
+
+case "$1" in
+
+  remove)
+    # Remove lock if still exists
+    rm -f /var/lock/subsys/3dm2 
+  ;;
+
+  purge)
+    # Remove conf and ssl cert
+    rm -rf /etc/3dm2
+  ;;
+
+esac
+
+#DEBHELPER#
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..edd6ae1
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,76 @@
+#!/usr/bin/make -f
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+DESTDIR = $(CURDIR)/debian/3dm2
+DEB_BUILD_ARCH  ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
+
+build: build-arch build-indep
+build-arch:
+build-indep:
+
+clean:
+	dh_testdir
+	dh_testroot
+	dh_clean
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k
+	dh_installdirs
+	# Install data
+ifeq ($(DEB_BUILD_ARCH),amd64)
+	install -m 755 $(CURDIR)/amd64/3dm2.x86_64 \
+	               $(DESTDIR)/usr/sbin/3dm2
+	install -m 600 $(CURDIR)/amd64/3dm2.conf \
+		       $(DESTDIR)/etc/3dm2/3dm2.conf
+endif
+ifeq ($(DEB_BUILD_ARCH),i386)
+	install -m 755 $(CURDIR)/i386/3dm2.x86 \
+	               $(DESTDIR)/usr/sbin/3dm2
+	install -m 600 $(CURDIR)/i386/3dm2.conf \
+		       $(DESTDIR)/etc/3dm2/3dm2.conf
+endif
+	cp -a $(CURDIR)/msg $(DESTDIR)/usr/share/3dm2/
+	cp -a $(CURDIR)/help $(DESTDIR)/usr/share/doc/3dm2/html
+	find $(DESTDIR)/usr/share -type f -exec chmod 644 {} \;
+	# Fix default conf file
+	sed -i 's!^EmailEnable .*$$!EmailEnable 1!' \
+	  $(DESTDIR)/etc/3dm2/3dm2.conf
+	sed -i 's!^EmailSender .*$$!EmailSender 3dm2!' \
+	  $(DESTDIR)/etc/3dm2/3dm2.conf
+	sed -i 's!^EmailServer .*$$!EmailServer 127.0.0.1!' \
+	  $(DESTDIR)/etc/3dm2/3dm2.conf
+	sed -i 's!^EmailRecipient .*$$!EmailRecipient root!' \
+	  $(DESTDIR)/etc/3dm2/3dm2.conf
+	sed -i 's!^RemoteAccess .*$$!RemoteAccess 0!' \
+	  $(DESTDIR)/etc/3dm2/3dm2.conf
+	sed -i 's!^MsgPath .*$$!MsgPath /usr/share/3dm2/msg!' \
+	  $(DESTDIR)/etc/3dm2/3dm2.conf
+	sed -i 's!^Help .*$$!Help /usr/share/doc/3dm2/html!' \
+	  $(DESTDIR)/etc/3dm2/3dm2.conf
+	sed -i 's!^Logger .*$$!Logger 0!' \
+	  $(DESTDIR)/etc/3dm2/3dm2.conf
+
+binary-indep: build install
+binary-arch: build install
+	dh_testdir
+	dh_testroot
+	dh_installchangelogs
+	dh_installdocs
+	dh_installinit
+	dh_installman
+	dh_link
+	dh_strip
+	dh_compress -Xusr/share/doc/3dm2/html
+	dh_fixperms -Xetc/3dm2/3dm2.conf
+	dh_installdeb
+	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
diff --git a/files.diz b/files.diz
index ccec895..c220bd1 100644
--- a/files.diz
+++ b/files.diz
@@ -1,2 +1,2 @@
-amd64!3dm2!2.11.00.021!3DM2_CLI-linux_10-2-2-1_9-5-5-1.zip!https://docs.broadcom.com/docs-and-downloads/raid-controllers/raid-controllers-common-files/3DM2_CLI-linux_10-2-2-1_9-5-5-1.zip!3889909bc63c7f65be89006d22a55b28
-i386!3dm2!2.11.00.021!3DM2_CLI-linux_10-2-2-1_9-5-5-1.zip!https://docs.broadcom.com/docs-and-downloads/raid-controllers/raid-controllers-common-files/3DM2_CLI-linux_10-2-2-1_9-5-5-1.zip!3889909bc63c7f65be89006d22a55b28
+amd64!3dm2!2.11.00.021.0!3DM2_CLI-linux_10-2-2-1_9-5-5-1.zip!https://docs.broadcom.com/docs-and-downloads/raid-controllers/raid-controllers-common-files/3DM2_CLI-linux_10-2-2-1_9-5-5-1.zip!3889909bc63c7f65be89006d22a55b28
+i386!3dm2!2.11.00.021.0!3DM2_CLI-linux_10-2-2-1_9-5-5-1.zip!https://docs.broadcom.com/docs-and-downloads/raid-controllers/raid-controllers-common-files/3DM2_CLI-linux_10-2-2-1_9-5-5-1.zip!3889909bc63c7f65be89006d22a55b28