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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
12-12-2007, 09:19 AM
|
#1
|
|
LQ Newbie
Registered: Dec 2007
Posts: 6
Rep:
|
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
|
|
|
|
12-12-2007, 12:27 PM
|
#2
|
|
Moderator
Registered: May 2001
Posts: 24,805
|
Quote:
Originally Posted by hackhound
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
with wget
|
If yum/apt/autoupdate/whatever else doesn't work why should wget work?
Quote:
Originally Posted by hackhound
I am working on a script
|
Awww, just post what you got.
|
|
|
|
12-12-2007, 03:26 PM
|
#3
|
|
LQ Newbie
Registered: Dec 2007
Posts: 6
Original Poster
Rep:
|
Quote:
Originally Posted by unSpawn
|
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
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
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
|
|
|
|
12-12-2007, 04:03 PM
|
#4
|
|
Moderator
Registered: May 2001
Posts: 24,805
|
Quote:
Originally Posted by hackhound
[Errno -1] Header is not complete.
|
Could be the proxy byte-range thingie.
Quote:
Originally Posted by hackhound
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?
|
|
|
|
12-12-2007, 04:13 PM
|
#5
|
|
LQ Newbie
Registered: Dec 2007
Posts: 6
Original Poster
Rep:
|
Quote:
Originally Posted by unSpawn
Could be the proxy byte-range thingie.
|
Could be. It's been a couple months since I investigated.
Quote:
Originally Posted by unSpawn
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.
|
|
|
|
12-12-2007, 04:38 PM
|
#6
|
|
Moderator
Registered: May 2001
Posts: 24,805
|
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?
|
|
|
|
12-13-2007, 08:39 AM
|
#7
|
|
LQ Newbie
Registered: Dec 2007
Posts: 6
Original Poster
Rep:
|
Quote:
Originally Posted by unSpawn
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
|
|
|
|
12-13-2007, 11:55 AM
|
#8
|
|
Moderator
Registered: May 2001
Posts: 24,805
|
|
|
|
|
12-13-2007, 12:28 PM
|
#9
|
|
LQ Newbie
Registered: Dec 2007
Posts: 6
Original Poster
Rep:
|
Quote:
Originally Posted by unSpawn
|
Uncommenting the baseurl line in yum.repos.d and then running yum udpate gives me the same "[Errno -1] Header is not complete." error.
|
|
|
|
12-14-2007, 02:35 AM
|
#10
|
|
Moderator
Registered: May 2001
Posts: 24,805
|
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
|
|
|
|
12-14-2007, 10:27 AM
|
#11
|
|
LQ Newbie
Registered: Dec 2007
Posts: 6
Original Poster
Rep:
|
Quote:
Originally Posted by unSpawn
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
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
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.
|
|
|
|
12-14-2007, 11:51 AM
|
#12
|
|
Moderator
Registered: May 2001
Posts: 24,805
|
NP, you're welcome. If you ever find a fix though I'd appreciate you posting a follow-up.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 07:04 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|