Pankaj Mishra wrote:
> Hi folks,
> I want to create a *tar.bin file . Basically an executable file which
> should ask for a ceratin prompt, which if it gets , untars the
> contents else ignore it and do not untar. Something like SUN ships
> whwn we download JDk . How do I do it. Help is required urgently!
> Punkuz
Here is an example script that I use to setup an tarred application
along with setting up crontab.
copy this script to some place with some name
then prepare your tar file
try to get the number of lines of this script then modify the line
tail +99
to
tail +<number of lines in this script including the extra new lines
at the end>
change this line too for the kind of check sum and the number of blocks
for your tar file with the real numbers
if expr $sum1 != 23008 || expr $sum2 != 80 ; then
then make an another file with appending the content of the tar file to
the shell script, you may want to keep original script file, it will be
necessary for every action
then chmod to 755 or whatever you want
then run it
test test test!!!
this is a dangerous process, if you screw up you may screw up your
entire system, entire rick is in your hand, do not blame me afterwards
#!/bin/sh
PATH=/usr/bin:/bin
more <<"EOF"
Here is the installation step
Enter the directory name that you wish to install.
Then the program will extract this file to the specified
folder
This program will install a cronjob, which actually
start for every week at early morning on saturday at 2 AM
that is it.
EOF
destdir=$1
while [ x$destdir = x ]; do
echo
echo "Do you want to install the application? "
read reply leftover
case $reply in
y* | Y*)
echo "Please provide the directory where you want to install:"
read destdir leftover
[ x$destdir = x ] && ( echo "Installation cancelled."; exit 2);;
n* | n*)
echo "If you don't provide the dest dir then you can't install
this sofware";
exit 1;;
esac
done
CWD=`pwd`;
outname=$CWD/out.tar.$$
trap 'rm -f $outname; exit 1' HUP INT QUIT TERM
echo "Unpacking..."
tail +99 $0 > $outname
if [ -x /usr/bin/sum ] ; then
echo "Checksumming..."
sum=`/usr/bin/sum $outname`
index=1
for s in $sum
do
case $index in
1) sum1=$s;
index=2;
;;
2) sum2=$s;
index=3;
;;
esac
done
if expr $sum1 != 23008 || expr $sum2 != 80 ; then
echo "The download file appears to be corrupted."
echo "Please do not attempt to install this archive."
exit 1
fi
else
echo "Can't find /usr/bin/sum to do checksum. Continuing anyway."
fi
echo "Extracting..."
mkdir -p $destdir; cd $destdir; tar xf $outname
crontabfile=$CWD/cron.tab.$$
INSTALL=$CWD/$destdir
echo $destdir | egrep -n -e "^/"
[ $? == 0 ] && INSTALL=$destdir
echo "15 2 * * sun $INSTALL/download.sh > /dev/null 2>&1" > $crontabfile
crontab $crontabfile
cd $CWD
echo "$CWD: Done."
rm -f $outname
rm -f $crontabfile
exit 0
#---------------------------------------------------END OF THE
SCRIPT----------------------------------------------------
-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone? Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
linux-india-help mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/linux-india-help