LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 12-12-2007, 10:19 AM   #1
hackhound
LQ Newbie
 
Registered: Dec 2007
Posts: 6

Rep: Reputation: 0
Lightbulb Need a script that does the following:


Greetings,
I cannot get 'yum update' on a CentOS 5 box to work through our proxy server at work, and am now looking for a workaround. I am thinking that a script (bash, perl, etc) to do:

1. Take the output of 'yum check-update' and parse out everything but the package name.
2. Take the list of packages and retrieve them to a local directory with wget.
3. Update the box with 'yum localinstall'
4. Delete the updates after successful install.

I am working on a script, but thought would check here in case someone has done this already, or can bang something together quicker than I can.

Thanks,
Hackhound
 
Old 12-12-2007, 01:27 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,725
Blog Entries: 54

Rep: Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970
Quote:
Originally Posted by hackhound View Post
I cannot get 'yum update' on a CentOS 5 box to work through our proxy server
Why doesn't it work? What did you try? What where the (exact!) errors shown? And if it's using NTLM auth you could try http://ntlmaps.sourceforge.net/.


Quote:
Originally Posted by hackhound View Post
with wget
If yum/apt/autoupdate/whatever else doesn't work why should wget work?


Quote:
Originally Posted by hackhound View Post
I am working on a script
Awww, just post what you got.
 
Old 12-12-2007, 04:26 PM   #3
hackhound
LQ Newbie
 
Registered: Dec 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by unSpawn View Post
Why doesn't it work? What did you try? What where the (exact!) errors shown? And if it's using NTLM auth you could try http://ntlmaps.sourceforge.net/.
I don't want to get into alot of detail, because I have already beat this to death trying to get yum update to work. I have my env proxy variable set correctly, but when I execute yum update <packagename> I get:

[Errno -1] Header is not complete.

Quote:
Originally Posted by unSpawn View Post
If yum/apt/autoupdate/whatever else doesn't work why should wget work?
My research of this error seems to indicate the problem lies with the proxy server not being able to handle the yum update request, which I have no control over. I tested wget, and it works fine.

Quote:
Originally Posted by unSpawn View Post
Awww, just post what you got.
OK. Here is what I have so far. It's not pretty because I am taking this in a 'step by step' approach. Basically, what I have so far grabs a list or programs needing to be updated, strips off the status messages on the top 5 lines, grabs just the first column, and then reads each packagename and outputs it to the screen.

#!/bin/bash
cd yum-updates
yum check-update > update.log
sed '1,5d' update.log > yum1.log
awk '{print $1}' yum1.log > yum2.log
for i in $( cat yum2.log ); do
echo $i
done

Next steps would be to replace the 'echo $i' with the wget command, then run yum localinstall, then delete the file.

Like I said, not the nicest looking code, but I'm not an expert, and what I have so far is working.

Hackhound
 
Old 12-12-2007, 05:03 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,725
Blog Entries: 54

Rep: Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970
Quote:
Originally Posted by hackhound View Post
[Errno -1] Header is not complete.
Could be the proxy byte-range thingie.


Quote:
Originally Posted by hackhound View Post
I tested wget, and it works fine.
If you don't mind me asking, did you try Yum with PGP sigs off and ftp or https style URI's by any chance?
 
Old 12-12-2007, 05:13 PM   #5
hackhound
LQ Newbie
 
Registered: Dec 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by unSpawn View Post
Could be the proxy byte-range thingie.
Could be. It's been a couple months since I investigated.

Quote:
Originally Posted by unSpawn View Post
If you don't mind me asking, did you try Yum with PGP sigs off and ftp or https style URI's by any chance?
Can you elaborate on what I should be trying? I am rather sure that I am not using PSP sigs.
 
Old 12-12-2007, 05:38 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,725
Blog Entries: 54

Rep: Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970
Hmm. There apparently are no mirrors providing HTTPS but definately Rsync and FTP. Tried using "ftp://mirror.pacific.net.au/linux/fedora/linux" instead of "http://mirror.pacific.net.au/linux/fedora/linux" style URI's in your .repo file?
 
Old 12-13-2007, 09:39 AM   #7
hackhound
LQ Newbie
 
Registered: Dec 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by unSpawn View Post
Hmm. There apparently are no mirrors providing HTTPS but definately Rsync and FTP. Tried using "ftp://mirror.pacific.net.au/linux/fedora/linux" instead of "http://mirror.pacific.net.au/linux/fedora/linux" style URI's in your .repo file?
Well, I tried that, and now it gives me the following:

Could not retrieve mirrorlist ftp://mirrorlist.centos.org/?release...h=i386&repo=os error was
[Errno 14] HTTP Error 502: Bad Gateway
Error: Cannot find a valid baseurl for repo: base

I don't have any problem getting the mirrorlist, the problem occurs when yum tries to grab a package from one of the sites in the mirrorlist.

Hackhound
 
Old 12-13-2007, 12:55 PM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,725
Blog Entries: 54

Rep: Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970
Quote:
Originally Posted by hackhound View Post
Error: Cannot find a valid baseurl for repo: base
See http://www.linuxquestions.org/questi...o-core-469993/ or http://www.linuxquestions.org/questi...r-repo-478600/ ?
 
Old 12-13-2007, 01:28 PM   #9
hackhound
LQ Newbie
 
Registered: Dec 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Uncommenting the baseurl line in yum.repos.d and then running yum udpate gives me the same "[Errno -1] Header is not complete." error.
 
Old 12-14-2007, 03:35 AM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,725
Blog Entries: 54

Rep: Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970
I don't know what you're doing but "ftp://mirrorlist.centos.org/?release=5&arch=i386&repo=os" does not exist. Next to that I think help should be a two-way street and since you haven't exactly been forthcoming with details. Here's a script: remember YMMV(VM).
Code:
#!/bin/sh -
# Set debug and error mode when testing:
set -xe
# Make it a temp dir?
mkdir /tmp/yum-updates
cd /tmp/yum-updates
# Get list (your command, don't know if it works).
PKGS=$(yum check-update 2>/dev/null| sed '1,5d' | awk '{print $1}')
# Get packages. Replace basurl with the basurl of the repo.
for PKG in $PKGS; do wget "${baseurl}/$PKG" -P /tmp/yum-updates; done
# Install and only delete packages on success.
yum localinstall /tmp/yum-updates/*.rpm && \
rm -rf /tmp/yum-updates/*.rpm
exit 0
 
Old 12-14-2007, 11:27 AM   #11
hackhound
LQ Newbie
 
Registered: Dec 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by unSpawn View Post
I don't know what you're doing but "ftp://mirrorlist.centos.org/?release=5&arch=i386&repo=os" does not exist.
Correct. I did a global replace of http: with ftp: in yum.repos.d, which caused the mirrorlist url to be changed as well. I caught the mistake and changed it back to http:

Quote:
Originally Posted by unSpawn View Post
Next to that I think help should be a two-way street and since you haven't exactly been forthcoming with details.
I do not know how I could be more forthcoming. I have tried everything you suggested and reported back my results. As you may recall, I never asked for help with getting yum to work, as I have beat this to death already without ever finding a solution. All I wanted was a script to give me a workaround, which I see that you have provided below.

Quote:
Originally Posted by unSpawn View Post
Here's a script: remember YMMV(VM).
Code:
#!/bin/sh -
# Set debug and error mode when testing:
set -xe
# Make it a temp dir?
mkdir /tmp/yum-updates
cd /tmp/yum-updates
# Get list (your command, don't know if it works).
PKGS=$(yum check-update 2>/dev/null| sed '1,5d' | awk '{print $1}')
# Get packages. Replace basurl with the basurl of the repo.
for PKG in $PKGS; do wget "${baseurl}/$PKG" -P /tmp/yum-updates; done
# Install and only delete packages on success.
yum localinstall /tmp/yum-updates/*.rpm && \
rm -rf /tmp/yum-updates/*.rpm
exit 0
Thank You for the help.
 
Old 12-14-2007, 12:51 PM   #12
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,725
Blog Entries: 54

Rep: Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970
NP, you're welcome. If you ever find a fix though I'd appreciate you posting a follow-up.
 
  


Reply

Tags
bash, script, wget, yum


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
How to execute a ssh script on Linux server from Windows through a bat script? wanna13e Programming 13 10-23-2009 03:41 AM
set variables in a bash script; ansi PS1 color script donnied Programming 4 11-21-2007 12:33 PM
Shell Script: want to insert values in database when update script runs ring Programming 2 10-25-2007 11:48 PM
i get an error message running php script inside a cgi script. repolona Linux - Software 0 02-22-2007 10:10 PM
linux 9 and java script error - premature end of script header sibil Linux - Newbie 0 01-06-2004 05:21 PM


All times are GMT -5. The time now is 09:42 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration