Bash Script with auto installation and log errors
Hi there people I'ma newbie at programming in Bash.
My problem is that I need to create a script with many specifications...
I will introduce them the most detailed possible and in the end put the most relevant questions that remains in my mind.
*Download package from internet
This function must asks the user the url of the package on the web, then use a command line application to download the file to a temporary directory.
*Extract the file
In this step, the script must create a temporary directory and afterwards extract the file of the file (saved in the previous step) to there.
EXTRA: By default the file type is "tar.gz", by the way the detection of the compressed file type and the correct extraction is valuable.
The compilation of the source code must be made assuming that the compilation is made in two steps (configuration and compilation)
Asks the user the directory where the software will be installed in the system
Execute the configuration script
$ ./configure -prefix=$directory
EXTRA: use the make allowing the use of more processors, by using more jobs. This I had advance using the make -j command
In this step we need to assure that can write in the directory. In case of true install with the privileges of the user ($make install) otherwise must be set to root and do this step as root:
THIS PART ---> SOLVED
Must assure that the execution of the program wouldn't be run as root after installing. EXTRA: detect of the existence of sudo and prefer this, if not present in the system use the su command.
UNTIL THERE SOLVED<---
All this steps must be recorded in separate files of output of the application (stdout and stderr in separate files)
In this option must show the contents of the apropriate file in the last action made. EXTRA: use the default editor of the user to see the error files.
Generating a package in RPM format and the installation of the package using the RPM manager.
In the end exit the installer.
Now where I'm stuck
Don't know out to redirect the stderr and stdout to separate files while the script is executing, detect the file type and proper application to extract and create the RPM.
Can you help me? I know this is a long and advanced program for a newbie, but this can be helpful for everyone.
What I've done right now is this:
mkdir temporary_folder 2>&tee -a stdout.txt
echo "Please insert the URL of the file to install"
wget $URL 2>stdout.txt | tee -a stdout.txt
Thanks for all your help in advance
Last edited by Matafome; 01-18-2010 at 08:40 PM.