LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 01-18-2010, 08:43 PM   #1
Matafome
LQ Newbie
 
Registered: May 2006
Location: Portugal
Distribution: Ubuntu
Posts: 4

Rep: Reputation: 1
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.

*Compilation
The compilation of the source code must be made assuming that the compilation is made in two steps (configuration and compilation)

*Configuration
Asks the user the directory where the software will be installed in the system
Execute the configuration script
$ ./configure -prefix=$directory

*Compilation
$ make
EXTRA: use the make allowing the use of more processors, by using more jobs. This I had advance using the make -j command

*Instalation
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:
$make install


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<---


*Show logs
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.

EXTRA FUNCTIONS:
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:

################

#!/bin/bash


mkdir temporary_folder 2>&tee -a stdout.txt
cd instalador
echo "Please insert the URL of the file to install"
read URL
wget $URL 2>stdout.txt | tee -a stdout.txt

Thanks for all your help in advance

Last edited by Matafome; 01-18-2010 at 09:40 PM.
 
Old 01-18-2010, 09:20 PM   #2
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,014

Rep: Reputation: 115Reputation: 115
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.

Last edited by tuxdev; 01-18-2010 at 09:24 PM.
 
Old 01-18-2010, 09:38 PM   #3
Matafome
LQ Newbie
 
Registered: May 2006
Location: Portugal
Distribution: Ubuntu
Posts: 4

Original Poster
Rep: Reputation: 1
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
 
Old 01-20-2010, 11:58 AM   #4
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,014

Rep: Reputation: 115Reputation: 115
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.
 
Old 01-20-2010, 08:34 PM   #5
Matafome
LQ Newbie
 
Registered: May 2006
Location: Portugal
Distribution: Ubuntu
Posts: 4

Original Poster
Rep: Reputation: 1
It's a project that I need to create from scratch

Quote:
Originally Posted by tuxdev View Post
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.
Muy problem is that I need to create it from the scratch since it's a project for University, and all in just one file not how you had done your project. So I'm searching and I found tee interesting for the parto of the logs =)

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.
 
  


Reply

Tags
bash, help, installation, installing, programming, script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
simple bash script errors cbtsig215 Linux - Newbie 4 12-04-2009 04:33 AM
Bash script has errors smeezekitty Programming 30 11-19-2009 04:34 PM
how to log everything from a bash script to a file prodsac Linux - Server 2 04-15-2008 05:56 PM
Bash script for server log (namely var/log/messages) tenaciousbob Programming 17 05-24-2007 11:43 AM
auto run bash script when logged in linuxmandrake Fedora 1 06-11-2005 09:22 PM


All times are GMT -5. The time now is 07:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration