Il giorno Mar 24 Mag 2011 12:27:04 CET, Dejan Muhamedagic ha scritto:
> Hi,

Hi Dejan,

[...]
>> # Read parameters
>> conf_file="/etc/hetzner.cfg"
>> user=`cat /etc/hetzner.cfg | egrep "^user.*=" | sed 's/^user.*=\ *//g'`
> Better:
> user=`sed -n 's/^user.*=\ *//p' /etc/hetzner.cfg`

Absolutely agree.

>> pass=`cat /etc/hetzner.cfg | egrep "^pass.*=" | sed 's/^pass.*=\ *//g'`
>> hetzner_server="https://robot-ws.your-server.de";
> I assume that this is a well-known URL which doesn't need to be
> passed as a parameter.

As far as I know it is the only address, I hard-coded it for this 
reason, but maybe should be a parameter...

>> is_host_up() {
>>        if [ "$1" != "" ]
>>         then
>>          status=`curl -s -u $user:$pass $hetzner_server/server/$1 | sed 
>> 's/.*status\":"\([A-Za-z]*\)",.*/\1/g'`
>>          if [ "$status" = "ready" ]
>>           then
>>            return 0
>>           else
>>            return 1
>>          fi
> This if statement can be reduced to (you save 5 lines):
>           [ "$status" = "ready" ]
>>         else
>>          return 1
>>        fi
>> }

You mean the statement should be:

[ "$status" = "ready" ] && return 0
return 1

?

[...]
> Again, better (is return code of is_host_up inverted?):
>       is_host_up "$hostaddress"
>        exit # this is actually also superfluous, but perhaps better left in

The action is reset, so if I had success then is_host_up must be NOT 
ready. Or not?

[...]
> Ditto.
> Good work!
> Cheers,
> Dejan
> P.S. Moving discussion to linux-ha-dev.

If the compact way is correct, I can modify the script and post it again.

-- 
RaSca
Mia Mamma Usa Linux: Niente รจ impossibile da capire, se lo spieghi bene!
ra...@miamammausalinux.org
http://www.miamammausalinux.org

_______________________________________________
Linux-HA mailing list
Linux-HA@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha
See also: http://linux-ha.org/ReportingProblems

Reply via email to