ecks
05-21-2004, 09:07 PM
I'm sure that a lot of you people have this script already written, but for those of you that don't, here's a basic script for installing from source:
#!/bin/bash
download_dir=/home/ecks/Desktop
src_dir=/usr/local/src
input=$1
check_file()
{
file_exist=`ls | grep $input`
if [ -z $file_exist ] ; then
echo "No such file in current directory"
exit
fi
}
check_root()
{
user=`whoami`
if [ $user != "root" ] ; then
echo "You need to log in as root to use this script"
exit
fi
}
make_env()
{
cd $download_dir
check_file
check_root
mv $input $src_dir
cd $src_dir
check_file
tar -x -z -f $input
tar_dir=${input%%.tar.gz}
cd $src_dir/$tar_dir
}
make_file()
{
./configure
make
make install
make clean
}
# this puts all the files in it's appropriate directories
make_env
# this actually compiles the program. Comment it if you don't want to install.
make_files
Note that it checks for files saved in ~/Desktop, so because your dir is different you need to change it.
EDIT: So far, it only works for .tar.gz files.
#!/bin/bash
download_dir=/home/ecks/Desktop
src_dir=/usr/local/src
input=$1
check_file()
{
file_exist=`ls | grep $input`
if [ -z $file_exist ] ; then
echo "No such file in current directory"
exit
fi
}
check_root()
{
user=`whoami`
if [ $user != "root" ] ; then
echo "You need to log in as root to use this script"
exit
fi
}
make_env()
{
cd $download_dir
check_file
check_root
mv $input $src_dir
cd $src_dir
check_file
tar -x -z -f $input
tar_dir=${input%%.tar.gz}
cd $src_dir/$tar_dir
}
make_file()
{
./configure
make
make install
make clean
}
# this puts all the files in it's appropriate directories
make_env
# this actually compiles the program. Comment it if you don't want to install.
make_files
Note that it checks for files saved in ~/Desktop, so because your dir is different you need to change it.
EDIT: So far, it only works for .tar.gz files.