Hi Rich:
On 03/09/2012 11:48 PM, Richard W.M. Jones wrote:
> On Fri, Mar 09, 2012 at 02:50:17PM +0800, Wanlong Gao wrote:
>> +#FIXME: This may not work OK for IPv6 ?
>
> :-)
> Does it work or not? Anyone??
The "enable=ipconfig" can work but "--ipconfig" here can't work
on IPv6
because the IPv6 address's format is "XXXX:XXXX:...", so we can add the
IPv6 part if it needed future.
Will you push this or further comment? ;)
Thanks,
Wanlong Gao
>
>> +if [ "$ipconfig" = "yes" ]; then
>> + case "$type/$distro" in
>> + linux/fedora|linux/rhel)
>> + if [ -d $mnt/etc/sysconfig/network-scripts ]; then
>> + if [ -z $ipconfig_param ]; then
>
> Apparently you don't need to quote parameters in bash, but while this
> is technically correct, I think it is safer to quote it. There are a
> few other similar ones later in the code.
>
>> + for (( i=1; i<8 ; i+=2 )); do
>> + __device=$(echo "$ipconfig_param" | awk -v
j=$i -F: '{print $j}')
>> + if [ -z $__device ]; then
>> + break
>> + fi
>> + __ipconfig=$(echo "$ipconfig_param" | awk -v
j=$((i+1)) -F: '{print $j}')
>> + __config_file=$(echo
"$mnt/etc/sysconfig/network-scripts/ifcfg-$__device")
>> + if [ -e $__config_file ]; then
>> + __ip=$(echo "$__ipconfig" | awk -F,
'{print $1}')
>> + __mask=$(echo "$__ipconfig" | awk -F,
'{print $2}')
>> + __gw=$(echo "$__ipconfig" | awk -F,
'{print $3}')
>> + sed
'/^IPADDR=/d;/^BOOTPROTO=/d;/^NETMASK=/d;/^GATEWAY=/d;/^DNS/d' \
>> + < "$__config_file" >
"$__config_file.new"
>> + echo "IPADDR=$__ip" >>
"$__config_file.new"
>> + echo "BOOTPROTO=static" >>
"$__config_file.new"
>> + echo "NETMASK=$__mask" >>
"$__config_file.new"
>> + echo "GATEWAY=$__gw" >>
"$__config_file.new"
>> + mv -f "$__config_file.new"
"$__config_file"
>> + fi
>> + done
>> + fi
>> + fi
>
> I can't see any fault in this code. I wonder if there's an easier
> way, but maybe not, this is shell script after all ...
>
> Seems OK in general.
>
> Rich.
>
_______________________________________________
Libguestfs mailing list
Libguestfs(a)redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs