http://www.bashscripts.org/downloads/Sc ... ing.tar.gz
This script is nothing serious, I just wanted to see if you could create a installer out of bash. What the script does, if you examine the code, is create a tar.gz archive from the files and renames it (purely so that you don;t get confused with other tar.gz files) to another extension. then the script mkbash generates a file called bash.installer which renames the archive to a tar.gz archive and extracts it to a location specified in the script. This is all tarred and gzipped into another .tar.gz file which is renamed to .bash (again so you don't get confused with .tar.gz files). The installer (called installbash) just renames this archive to a tar.gz, extracts it, runs bash.installer which then extracts the archive with the files in into the appropriate directory. To see what I mean download the script and install it using runme (you need to be root).
To test this script, download this test archive and examine it or extract it using my script or a archive manager.
I just wanted to see if I could create a whole kind of rpm/deb thing from bash and other common unix utils.
Some hints:
1. Akways run makeinstaller in the folder that contains the files you want in - it will just create an archive out of all the files in that folder.
2. Again run installbash in the folder that contains the archive.bash file.
If people like it I may add more features.
Here is the code for the files:
makeinstaller
Code:
#!/bin/bash
echo "Making installer from files in current directory"
tar -cf bashinstall.tar *
gzip -9 bashinstall.tar
rename bashinstall.tar.gz archive.bash.install bashinstall.tar.gz
mkbash
if [[ -e bash.installer ]]
then
echo "bash.installer found, continuing with script"
else
echo "ERROR!";
echo "No bash.installer file found in current directory, please create one with mkbash";
exit 1;
fi
tar -cf install.tar archive.bash.install bash.installer
gzip -9 install.tar
rename install.tar.gz archive.bash install.tar.gz
echo "archive.bash created in `pwd` "
rm -f archive.bash.install bash.installer
mkbashCode:
#!/bin/bash
echo "bash.installer will be created in `pwd`/.bash.installer"
read -p "Press enter to continue" enter
read -p "Where would you like the files to be installed (no trailing slash) - eg /usr/local : " extdir
echo "Ok, generating bash.installer"
echo "
#!/bin/bash
if [[ -d $extdir ]]
then
echo " "
else
mkdir -p $extdir; chmod 777 $extdir
fi
rename archive.bash.install bashinstall.tar.gz archive.bash.install
cp bashinstall.tar.gz $extdir
rm -f bashinstall.tar.gz
cd $extdir
tar -zxf bashinstall.tar.gz
echo "Files extracted in $extdir"
rm -f $extdir/bashinstall.tar.gz
exit 0
" >> bash.installer
installbashCode:
#!/bin/bash
checkforroot ()
{
clear
echo ""
echo "This script needs to be run as root."
echo "Now checking for root permissions"
sleep 1
ROOT_UID=0
if [ "$UID" -ne "$ROOT_UID" ]
then
echo ""
echo "**************** ERROR !! **************"
echo "You must be logged in as root to run this script"
echo "Please log in as root and re-run this script."
sleep 1
echo ""
echo "**************** ERROR !! **************"
exit
fi
echo "You are running as root.. good .. moving along now ;) "
sleep 2
}
checkforroot
if [[ -e archive.bash ]]
then
echo " "
else
echo "No archive.bash found";
exit;
fi
rename archive.bash install.tar.gz archive.bash
tar -zxvf install.tar.gz
chmod 777 bash.installer
./bash.installer
rm -f bash.installer
rm -f install.tar.gz
exit