Update

Signed-off-by: Joel Fernandes <joel@linuxinternals.org>
diff --git a/src/addons/device-startup b/src/addons/device-startup
new file mode 100755
index 0000000..8489159
--- /dev/null
+++ b/src/addons/device-startup
@@ -0,0 +1,8 @@
+#!/system/bin/sh
+# This script looks for /data/androdeb/deb.tar.gz and unpacks it
+# into debian, also tries to shut down any open chroots and clean up.
+
+cd /data/
+rm -rf debian
+tar -xf debian.tar.gz
+rm debian.tar.gz
diff --git a/src/addons/device-teardown b/src/addons/device-teardown
new file mode 100755
index 0000000..e5fd049
--- /dev/null
+++ b/src/addons/device-teardown
@@ -0,0 +1,4 @@
+#!/system/bin/sh
+
+spath=$( cd "$(dirname "$0")" ; pwd -P )
+
diff --git a/src/addons/device-unpack b/src/addons/device-unpack
new file mode 100755
index 0000000..7c43e09
--- /dev/null
+++ b/src/addons/device-unpack
@@ -0,0 +1,34 @@
+#!/system/bin/sh
+function die() {
+	exit_code=$1
+	msg=$2
+	echo "ERROR: $msg (code $exit_code)"
+	exit $exit_code
+}
+	
+set -e
+
+# Script to do unpack of rootfs, ensures proper tear down
+# of existing environment. Expects debian rootfs in
+# /data/deb.tar.gz which it will delete after successful
+# unpack of rootfs.
+
+spath=$( cd "$(dirname "$0")" ; pwd -P )
+
+if [ ! -f /data/deb.tar.gz ]; then
+	echo "Debian rootfs tar doesn't existing at /data/deb.tar.gz"
+	echo "Run androdeb with device connected first"
+	exit 1
+fi
+
+if [ -d /data/androdeb/debian ]; then
+	echo "androdeb environment already exists, doing a tear down"
+	# TODO: run env tear down script first
+	rm -rf /data/androdeb/debian
+fi
+
+
+mkdir -p /data/androdeb/
+tar -zxf /data/deb.tar.gz -C /data/androdeb/ || die 2 "Couldn't unpack due to tar -x errors"
+
+echo "Unpack of rootfs successful! Go forth and hack."
diff --git a/src/addons/device-unpack.sh b/src/addons/device-unpack.sh
deleted file mode 100755
index 3339f43..0000000
--- a/src/addons/device-unpack.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/system/bin/sh
-
-cd /data/
-rm -rf debian
-tar -xf debian.tar.gz
-rm debian.tar.gz