#!/bin/bash

#
# Script to re-name ppp interface being used by pppoe or pppoa to have
# a form: pppoe<unit> or pppoa<unit>.
#
# The name of the current ppp interface is passed in as argument 1.  The full
# name that we are to change it to is passed in as argument 6.  We don't
# use the rest of the arguments.
#
# We do this before device is brought up so that later scripts
# can see the correct name, and the interface doesn't have to be
# bounced

OLD_IFNAME=$1
NEW_IFNAME=$6

# The ppp daemon executes this script for all ppp interfaces, even those
# unrelated to pppoe or pppoa.  We want to change the names only of
# interface being used by pppoe or pppoa.
#
IFPREFIX=`echo $NEW_IFNAME | sed s/[0-9]//g`
if [ "$IFPREFIX" != "pppoe" -a "$IFPREFIX" != "pppoa" ]; then
    # its not a pppoe or pppoa interface
    exit 0;
fi

# Re-name the interface.  Log all errors to syslog.
logger -p debug -t "vyatta pppoe/pppoa"  Re-naming $OLD_IFNAME to $NEW_IFNAME
ip link set dev $OLD_IFNAME name $NEW_IFNAME | \
    logger -p debug -t "vyatta pppoe/pppoa"
