How to best handle three offices with three different sets of repositories and different proxies?

Grant McWilliams grantmasterflash at gmail.com
Thu Nov 29 00:39:53 PST 2007


>
>
> >
> > *The shell script*
> >
> >     #!/bin/bash
> >
> >     smart config --set http-proxy=
> >     http://username:password@proxy-ip:port
> >     <http://username:password@proxy-ip/>
> >     smart config --set ftp-proxy=http://username:password@proxy-ip:port
> >     <http://username:password@proxy-ip/>
> >
> >     smart channel --add channels.txt
> >
> >     smart mirror --add mirrors.txt
>
> this solution sounds easy enough - but if I switch to the other site,
> don't I have to remove the channels and mirrors from the previos one to
> only have one set?
>

I guess you could disable the channels but it would seem like the logic
would be more complex then just having seperate channel files.

smart channel --remove-all
smart mirror --show | grep '^h' | xargs smart mirror --remove-all

These lines will remove all channels and mirrors. You could add just a bit
to the script so it was something like this.

#!/bin/bash

if [ -n $1 ]
then
echo "You need to specify a site argument"
exit 192
else
SITE=$1
fi


case "$SITE" in
    site1)
smart config --set
http-proxy=http://username:password@proxy-ip:port<http://username:password@proxy-ip/>
smart config --set ftp-proxy=http://username:password@proxy-ip:port
smart channel --add site1-channels.txt
smart mirror --add site1-mirrors.txt
echo "Smartpm configured for site1"
         ;;
    site2)
smart config --set
http-proxy=http://username:password@proxy-ip:port<http://username:password@proxy-ip/>
smart config --set ftp-proxy=http://username:password@proxy-ip:port
 smart channel --add site2-channels.txt
smart mirror --add site2-mirrors.txt
echo "Smartpm configured for site1"
          ;;
    *)
         commands;
         ;;
esac

exit 0


The automatic proxy code looks something like this

#!/bin/bash

PROXYSERVER="proxy.domain.com"
PROXYPORT="8080"

if ping -c2 $PROXYSERVER &> /dev/null
then
smart config --set
http-proxy=http://username:password@PROXYSERVER:PROXYPORT<http://username:password@proxy-ip/>
smart config --set ftp-proxy=http://username:password@PROXYSERVER:PROXYPORT
else
smart config --remove http-proxy
smart config --remove ftp-proxy
fi

You could expand this to check for more than one proxy server and depending
on which one it found it would set the proxy settings.

Grant

-- 
Some people, when confronted with a problem, think "I know, I'll use
Windows."
Now they have two problems.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.labix.org/pipermail/smart-labix.org/attachments/20071129/0eea3855/attachment-0003.htm>


More information about the Smart mailing list