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
I've been working on this sort of thing for quite a while now, along with gnashley, another LQ member. My version is on github at http://github.com/tuxdev/src2pkg-ng and you can find the parent/sibling project at http://distro.ibiblio.org/pub/linux/...nload/src2pkg/
Both me and gnashley are very much Slackers, the DEB and RPM support is a little shaky because neither of us are completely familiar with how DEBs and RPMs are handled the way we know Slack packages.
One question solved more to answer
[QUOTE=tuxdev;3831571]I've been working on this sort of thing for quite a while now, along with gnashley, another LQ member. My version is on github at http://github.com/tuxdev/src2pkg-ng and you can find the parent/sibling project at http://distro.ibiblio.org/pub/linux/...nload/src2pkg/
In your doinst.sh there is parts that were good for me =)
To detect if the user got's permission or not of root. To get the files I will use wget url_to_file_src since it's easier for me to understand.
Thanks for your help
P.S.: Do you want that anyone translates the program to Portuguese of Portugal? If yes I'm available to do that
I don't really get what you're saying.. My point is that there's already a tool that does 90% of what you want, and you might consider contributing the last 10% you need for yourself rather than trying to do the whole thing from scratch.
Oh, and a translation would certainly be nice, though -ng is very volatile so it'd probably get out of date pretty often.
It's a project that I need to create from scratch
I don't have trouble to translate the program every version that get's out, since I believe that open source software is the best way to create jobs, for example in my country every kid that reads a computer book thinks is a master of computers, using click and run from windows. And people with knowledge don't got jobs because this kids get out from school and to soon and tries to get jobs for the people most suitable for those tasks. Since using Linux requires more technical knowledge that's the future making sure that the companies get's better support employes and kicks out every wannabe that tries to get in without proper knowledge.
|All times are GMT -5. The time now is 07:47 PM.|