LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-06-2009, 02:16 PM   #1
ternarybit
Member
 
Registered: Jun 2009
Distribution: Debian, Arch, Mint
Posts: 51

Rep: Reputation: 15
Automatically updating software repository


I run a small PC repair shop with an Ubuntu samba server which shares a plethora of applications for shop use. These include virus removing apps, installers for firefox, OOo and others. Some of these do not receive new versions regularly, but many do.

An increasingly annoying part of my job has become updating these apps as new versions become available. It occurs to me that this could be an automated process. I imagine it would require a shell script and cron job. I have never done anything like this and I was wondering if any of you have advice on how I could accomplish this. If it requires more than 4 hours work, it's not worth it because it takes less than that to manually update the binaries.

Any advice would be greatly appreciated! Thank you all in advance.
 
Old 10-06-2009, 04:18 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
The most basic form of shell script is just a text file with the commands you want to run, usually with the first line specifying the command interpreter you want to use. So in its simplest form you can use something like this:

Code:
#!/bin/bash

apt-get update
apt-get install firefox openoffice.org <packagename> <packagename>
Or substitute aptitude if you use that.

Chmod this file so that root has execute permissions, then simply run "sudo ./scriptname".

You'll probably still want to monitor it manually though, as sometimes packages require manual intervention to avoid problems and conflicts. One of the packages might want to install a new dependency and ask you if you want to continue, or it might decide to terminate if it comes across a conflict for example.

Check the man page of apt-get or aptitude for ways to force it to bypass user intervention, if you really want to do it that way.


On the other hand, I see that there's also a program called cron-apt that will probably let you configure what you want more conveniently.

Last edited by David the H.; 10-06-2009 at 04:20 PM.
 
Old 10-06-2009, 04:43 PM   #3
ternarybit
Member
 
Registered: Jun 2009
Distribution: Debian, Arch, Mint
Posts: 51

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by David the H. View Post
The most basic form of shell script is just a text file with the commands you want to run, usually with the first line specifying the command interpreter you want to use. So in its simplest form you can use something like this:

Code:
#!/bin/bash

apt-get update
apt-get install firefox openoffice.org <packagename> <packagename>
Or substitute aptitude if you use that.

Chmod this file so that root has execute permissions, then simply run "sudo ./scriptname".

You'll probably still want to monitor it manually though, as sometimes packages require manual intervention to avoid problems and conflicts. One of the packages might want to install a new dependency and ask you if you want to continue, or it might decide to terminate if it comes across a conflict for example.

Check the man page of apt-get or aptitude for ways to force it to bypass user intervention, if you really want to do it that way.


On the other hand, I see that there's also a program called cron-apt that will probably let you configure what you want more conveniently.
Excellent, thank you for the information. Would the same thing work for Windows binaries, which is what most of our files are? Just a whole bunch of wget [url to download], then cp [permanent dir]?
 
Old 10-07-2009, 07:21 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
For the most part any command that you can run directly in the shell will work the same way inside a script, so yes, you should be able to do that.

But you can also do much more than that if you want to. Unix shells like bash have scripting languages that can almost rival true programming languages in complexity and ability. There are lots of good tutorials out there that can get you started. I personally recommend linuxcommand.org as an easy-to-follow primer on the basics.
 
Old 10-07-2009, 10:52 AM   #5
ternarybit
Member
 
Registered: Jun 2009
Distribution: Debian, Arch, Mint
Posts: 51

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by David the H. View Post
For the most part any command that you can run directly in the shell will work the same way inside a script, so yes, you should be able to do that.

But you can also do much more than that if you want to. Unix shells like bash have scripting languages that can almost rival true programming languages in complexity and ability. There are lots of good tutorials out there that can get you started. I personally recommend linuxcommand.org as an easy-to-follow primer on the basics.
Thank you very much. that website seems like just what I need. I will start there. This will be a good way to get a better understanding of bash.
 
Old 10-07-2009, 11:12 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by David the H. View Post
Unix shells like bash have scripting languages that can almost rival true programming languages in complexity and ability.
What do you mean "almost" David ! IMHO, bash script is more complex than C. That's not a Good Thing; C is the more elegant language; bash has accreted so much since the first sh; if we started designing a language with bash's functionality from scratch it would be a lot less complex, at least in its syntax.

Last edited by catkin; 10-07-2009 at 11:17 AM.
 
  


Reply



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
updating redhat server from CentOS repository bajones Linux - Newbie 4 04-23-2009 08:04 PM
After updating from repository, I lost GUI sjpiv44 SUSE / openSUSE 4 11-13-2008 04:09 PM
CentOS' YUM repository not updating? guest cAos 3 03-19-2005 03:57 AM
after updating RHEL AS 4 w/ CentOS' YUM repository.... guest cAos 2 03-17-2005 10:53 PM
automatically updating the hosts file sal_paradise42 Linux - Networking 3 12-31-2003 10:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:49 PM.

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
Open Source Consulting | Domain Registration