From: Herbert Poetzl (herbert_at_13thfloor.at)
Date: Wed 31 Mar 2004 - 06:11:45 BST
On Wed, Mar 31, 2004 at 01:41:14AM +0000, Liam Helmer wrote:
> The creation of the dummy devices is ugly and has races ('dummy0' is
> used by every 'vserver ... start' instance which conflicts with the
> parallel vserver startup). 'dummy<ctx>' would be ideally but is not
> supported by the kernel.
>
> I've attached what I was thinking, roughly. Yes, this is part of a
> much larger script... I'll share it with everyone when it's more
> complete.
> One problem with this code is that there's no real way of dumping the
> vserver interfaces when you're done. I can't think of others off the
> top of my head, but they're probably there.
> vstohex () {
> [ -n "$1" ] || return 1
> local oct1=$((${1} / 256))
> local oct2=$((${1} % 256))
> local -a out=()
> for seg in $oct1 $oct2 ; do
> hex1=$(($seg / 16))
> [ "$hex1" = "15" ] && hex1=f
> [ "$hex1" = "14" ] && hex1=e
> [ "$hex1" = "13" ] && hex1=d
> [ "$hex1" = "12" ] && hex1=c
> [ "$hex1" = "11" ] && hex1=b
> [ "$hex1" = "10" ] && hex1=a
> hex2=$(($seg % 16))
> [ "$hex2" = "15" ] && hex2=f
> [ "$hex2" = "14" ] && hex2=e
> [ "$hex2" = "13" ] && hex2=d
> [ "$hex2" = "12" ] && hex2=c
> [ "$hex2" = "11" ] && hex2=b
> [ "$hex2" = "10" ] && hex2=a
> out[${#out[@]}]=$hex1$hex2
> done
impressive, but
printf "%s:%02x" eth0 12345
is a good solution too (for bash)
best,
Herbert
_______________________________________________
Vserver mailing list
Vserver_at_list.linux-vserver.org
http://list.linux-vserver.org/mailman/listinfo/vserver