About this list Date view Thread view Subject view Author view Attachment view

From: Liam Helmer (linuxlists_at_thevenue.org)
Date: Wed 31 Mar 2004 - 07:43:01 BST


On Wed, 2004-03-31 at 05:11, Herbert Poetzl wrote:

> On Wed, Mar 31, 2004 at 01:41:14AM +0000, Liam Helmer wrote:
> printf "%s:%02x" eth0 12345
>

Ooh, cool. That's much nicer. So, after fixing a couple of other bugs
too, it should look more like this:

vstohex () {
        [ -n "$1" ] || return 1
        local oct1=$((${1} / 256))
        local oct2=$((${1} % 256))
        printf "%02:%02" ${oct1} ${oct2}
        }

if [ -n "${BUILD_VSIF}" ] && ! /sbin/ip link ls ${VSERVER_NAME} >
/dev/null 2>&1 ; then
        olddummylist=($(/sbin/ip link ls 2> /dev/null | gawk '$2 ~ /^dummy/
{print $2}' | sed 's/:$//g' | sort))
        insmod -o dummy-${VSERVER_NAME} dummy
        newdummylist=($(/sbin/ip link ls 2> /dev/null | gawk '$2 ~ /^dummy/
{print $2}' | sed 's/:$//g' | sort))
        if [[ "${newdummylist[@]}" = "${olddummylist[@]}" ]] ; then
                ${LOGERROR} "Sorry, no dummy support in kernel!"
        else
                for nd in ${newdummylist[@]} ; do
                        for od in ${olddummylist[@]} ; do
                                [ "$nd" = "$od" ] && continue 2
                        done
                        dummylock=/var/run/vserver/.lock.${nd}
                        [ -f "$dummylock" ] && continue
                        echo $$ >> $dummylock
                        hexend=$(vstohex ${S_CONTEXT})
                        mac="ff:ff:ff:ff:${hexend}"
                        ip link set dev ${nd} address ${mac}
                        nameif ${VSERVER_NAME} ${mac} || ${LOGERROR} "Couldn't set up
interface ${VSERVER_NAME} correctly!"
                        rm -f ${dummylock}
                        break
                done
        fi
fi
if [ "$BUILD_VSIF" ] ; then
        if ! /sbin/ip link ls ${VSERVER_NAME} > /dev/null 2>&1 ; then
                ${LOGERROR} "Dummy interface ${VSERVER_NAME} doesn't exist!"
        else
                ip addr flush ${VSERVER_NAME}
                for ipaddr in ${IPROOT} ; do
                        ip addr add dev ${VSERVER_NAME} $ipaddr
                done
        fi

fi

> 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
>

_______________________________________________
Vserver mailing list
Vserver_at_list.linux-vserver.org
http://list.linux-vserver.org/mailman/listinfo/vserver


About this list Date view Thread view Subject view Author view Attachment view
[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Wed 31 Mar 2004 - 07:44:24 BST by hypermail 2.1.3