Skip to content

Instantly share code, notes, and snippets.

@bjhaid
Created September 17, 2013 12:52
Show Gist options
  • Save bjhaid/6593923 to your computer and use it in GitHub Desktop.
Save bjhaid/6593923 to your computer and use it in GitHub Desktop.
self extrator (cat compressed.tar.gz >> install.sh)
#!/bin/bash
if [[ `whoami` != foo ]]
then echo "Please login as foo user to run this script.... Thanks!"
exit 1
fi
echo ""
echo "######################################################################################################################"
echo " ################Extracting DEPENDENCIES##################"
echo "######################################################################################################################"
echo ""
echo ""
echo "Extracting file into `pwd`"
echo ""
echo ""
SKIP=`awk '/^__TARFILE_FOLLOWS__/ { print NR + 1; exit 0; }' $0`
#remember our file name
THIS=`pwd`/$0
#Change directory to the root folder of the foo user
cd /home/foo
# take the tarfile and pipe it into tar
tail -n +$SKIP $THIS | tar -zx
#
# place any bash script here you need.
# Any script here will happen after the tar file extract.
cd `pwd`/deployment
chmod +x *
./mongo.sh
./rvm.sh
source /home/foo/.bash_profile
./oracle.sh
./cron.sh
echo "Completed installing"
exit 0
# NOTE: Don't place any newline characters after the last line below.
__TARFILE_FOLLOWS__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment