Self extracting zipped encrypted linux package

#!/bin/bash
T=`mktemp -d /tmp/$$XXXX`;trap "rm -rf $T" EXIT SIGINT; tail -n+3 $0|openssl enc -d -aes-256-cbc|tar zx -C $T;C=`pwd`; cd $T;./_;cd $C;exit 0

build:

#!/bin/bash
find . -name "*~" -delete
TMP=`mktemp -d /tmp/$$.XXXXX`
trap "rm -rf $TMP" EXIT

# Create payload
tar -czf $TMP/payload --exclude=*~ ./*
cd ..

#??
DST=./packages/`date +%Y%m%d`/sysprep.run
mkdir `dirname $DST`
( tail -n2 $0 ; cat $TMP/payload | openssl enc -aes-256-cbc )  > $DST 
chmod +x $DST
cp -f $DST `dirname $DST`/../latest.run
echo;echo;
ls -alh $DST
exit 0
# LAST 2 LINES MUST BE DECOMPRESS SCRIPT
#!/bin/bash
T=`mktemp -d /tmp/$$XXXX`;trap "rm -rf $T" EXIT SIGINT; tail -n+3 $0|openssl enc -d -aes-256-cbc|tar zx -C $T;C=`pwd`; cd $T;./_;cd $C;exit 0