Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
helper-script for host behind firewall (instead of blocked r
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
zyta2k
n00b
n00b


Joined: 29 Apr 2002
Posts: 7
Location: Switzerland

PostPosted: Thu May 02, 2002 12:48 pm    Post subject: helper-script for host behind firewall (instead of blocked r Reply with quote

Hi there,

wrote a small script because I've a problem using rsync behind a firewall.
Do you have the same problem... then this is for you :)

Code:

#!/bin/bash

MAXDAYS=5

cd /usr
echo -n "searching snapshot..."
for ((BACKDAYS=0; BACKDAYS<=MAXDAYS; BACKDAYS++))
do
 DATESTR="now -"`expr $BACKDAYS \* 24`" hours"
 DAY=`date -d "$DATESTR" +%Y%m%d`
 PORTAGEZIP="portage-$DAY.tar.bz2"
 RESULT=`wget --spider http://www.ibiblio.org/gentoo/snapshots/$PORTAGEZIP 2>&1 | grep "^200 OK"`
 if [[ $RESULT == "200 OK" ]] ; then
  break
 fi
done
echo -e "\tfound at today - $BACKDAYS day(s) !"
echo "downloading snapshot..."
wget "http://www.ibiblio.org/gentoo/snapshots/$PORTAGEZIP"
if [[ $1 == "clean" ]] ; then
    echo -n "removing old tree"
    rm -rf portage
fi
echo -n "unzipping snapshot..."
tar xvfj $PORTAGEZIP > /dev/null 2>&1
echo -e "\tdone"
echo -n "removing tarball..."
rm $PORTAGEZIP
echo -e "\tdone"
cd -


have fun :!:
Comments welcome :wink:
Back to top
View user's profile Send private message
DArtagnan
l33t
l33t


Joined: 30 Apr 2002
Posts: 942
Location: Israel, Jerusalem

PostPosted: Wed May 15, 2002 2:34 pm    Post subject: script Reply with quote

Hi :-) thanks for help
Can you explaind these lines because i did't understand where do u untar the package and what is 'cd -'?

Quote:
echo -n "unzipping snapshot..."
tar xvfj $PORTAGEZIP > /dev/null 2>&1
echo -e "\tdone"
echo -n "removing tarball..."
rm $PORTAGEZIP
echo -e "\tdone"
cd -


Many thanks
_________________
All for one and one for All
--

MACPRO machine...
Back to top
View user's profile Send private message
zyta2k
n00b
n00b


Joined: 29 Apr 2002
Posts: 7
Location: Switzerland

PostPosted: Thu May 16, 2002 11:23 am    Post subject: script Reply with quote

Hi...

first chanhing into dir /usr
Code:
 cd /usr


then I download the latest snapshot on ibiblio.org to the above dir (/usr) using wget

Code:
 wget "http://www.ibiblio.org/gentoo/snapshots/$PORTAGEZIP"


if you run update_portage with the argument "clean", the whole portage tree will be deleted before unpacking the new one...
this results in a clean portage-tree in /usr/portage

Code:

if [[ $1 == "clean" ]] ; then
    echo -n "removing old tree"
    rm -rf portage
fi


then I unzip my previously downloaded using the command
Code:
 tar xvfj $PORTAGEZIP > /dev/null 2>&1


now i cleanup the downloaded tarball /usr/snapshot-xxyyzz.ta.bz2 because nothing should reside in /usr (it's a little hack I know ;) ) but it works...

Code:
 cd -

this snipplet changes back to the origin-dir (where the script is startet, before the 'cd /usr')

It's tested under bash on a i686.
Hope it works :)

Greetz from Switzerland
Back to top
View user's profile Send private message
DArtagnan
l33t
l33t


Joined: 30 Apr 2002
Posts: 942
Location: Israel, Jerusalem

PostPosted: Thu May 16, 2002 12:29 pm    Post subject: emerge rsync Reply with quote

First of all thanks.
Do you want to say that this script will help instead "emerge rsync" ?
_________________
All for one and one for All
--

MACPRO machine...
Back to top
View user's profile Send private message
zyta2k
n00b
n00b


Joined: 29 Apr 2002
Posts: 7
Location: Switzerland

PostPosted: Thu May 16, 2002 3:26 pm    Post subject: Re: emerge rsync Reply with quote

pacman wrote:

Do you want to say that this script will help instead "emerge rsync" ?


Yes... from the Gentoo-FAQ:
Quote:

If you're behind a firewall that doesn't permit rsync traffic, then you can instead download the daily /usr/portage snapshot from http://cvs.gentoo.org/snapshots. Just unpack the tarball (using tar xvjf portage-foo.tbz2) in the /usr directory.


I only followed the instructions ;)
But my script is a little bit more powerful than the manual wget way *g*
Back to top
View user's profile Send private message
step
Apprentice
Apprentice


Joined: 16 May 2002
Posts: 198

PostPosted: Fri Jun 28, 2002 9:02 am    Post subject: Reply with quote

you probably like to replace
http://www.ibiblio.org/gentoo/snapshots/
with the new url
http://www.ibiblio.org/pub/Linux/distributions/gentoo/snapshots/

worekd for me
Back to top
View user's profile Send private message
DArtagnan
l33t
l33t


Joined: 30 Apr 2002
Posts: 942
Location: Israel, Jerusalem

PostPosted: Fri Jun 28, 2002 9:04 am    Post subject: Reply with quote

in make.conf or in this script?
_________________
All for one and one for All
--

MACPRO machine...
Back to top
View user's profile Send private message
mksoft
l33t
l33t


Joined: 28 May 2002
Posts: 844

PostPosted: Fri Jun 28, 2002 9:23 am    Post subject: Reply with quote

One problem though. From the code:
Code:
echo -e "\tfound at today - $BACKDAYS day(s) !"
echo "downloading snapshot..."
wget "http://www.ibiblio.org/gentoo/snapshots/$PORTAGEZIP"
if [[ $1 == "clean" ]] ; then
    echo -n "removing old tree"
    rm -rf portage
fi


If somehow wget in the code snippet fails (timeout during download, lost connection etc..) the portage tree will be removed, without no new file available.

The return value from wget should be checked, and continue only if OK.
_________________
There's someone in my head but it's not me - Pink Floyd
Back to top
View user's profile Send private message
DArtagnan
l33t
l33t


Joined: 30 Apr 2002
Posts: 942
Location: Israel, Jerusalem

PostPosted: Fri Jun 28, 2002 10:36 am    Post subject: Reply with quote

Mr. debug ;-)
_________________
All for one and one for All
--

MACPRO machine...
Back to top
View user's profile Send private message
rizzo
Retired Dev
Retired Dev


Joined: 30 Apr 2002
Posts: 1067
Location: Manitowoc, WI, USA

PostPosted: Fri Sep 27, 2002 1:18 pm    Post subject: Reply with quote

step wrote:
you probably like to replace
http://www.ibiblio.org/gentoo/snapshots/
with the new url
http://www.ibiblio.org/pub/Linux/distributions/gentoo/snapshots/


Both of these URLs work and point to apparently the same directory on the webserver anyway.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum