summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/rl-system.init33
-rwxr-xr-xscripts/vyatta_net_name29
2 files changed, 47 insertions, 15 deletions
diff --git a/scripts/rl-system.init b/scripts/rl-system.init
index d73dae74..cbdadd0f 100755
--- a/scripts/rl-system.init
+++ b/scripts/rl-system.init
@@ -22,6 +22,7 @@
#
# **** End License ****
+progname=${0##*/}
ACTION=$1
source /etc/default/vyatta
@@ -30,6 +31,7 @@ source /etc/default/vyatta
: ${vyatta_bindir:=${vyatta_prefix}/bin}
: ${vyatta_sbindir:=${vyatta_prefix}/sbin}
: ${vyatta_sysconfdir:=${vyatta_prefix}/etc}
+: ${hostname:=`hostname -s`}
[[ $PATH == *${vyatta_bindir}* ]] || PATH+=:${vyatta_bindir}
[[ $PATH == *${vyatta_sbindir}* ]] || PATH+=:${vyatta_sbindir}
@@ -41,6 +43,20 @@ export PATH
## BOOTFILE is provided by ofr.init
: ${BOOTFILE:=$prefix/etc/config/config.boot}
+if [ -z "$LOGFILE" ] ; then
+ if touch /var/log/messages &> /dev/null ; then
+ LOGFILE=/var/log/messages
+ else
+ LOGFILE=/dev/null
+ fi
+fi
+
+syslog ()
+{
+
+ date -u "+%b %d %H:%M:%S $hostname $progname: $*" >> $LOGFILE
+}
+
shopt -s extglob nullglob
search_config_if_wan () {
@@ -118,7 +134,24 @@ clear_or_override_config_files ()
rm -f /etc/ssh/ssh_host_key
}
+udev_rescan ()
+{
+ rm -f /tmp/vyatta_net_name_*
+ udevtrigger --subsystem-match=net && udevsettle
+ for ff in /tmp/vyatta_net_name_* ; do
+ f=${ff##*/}
+ cmd_name_hwid=${f/vyatta_net_name_/}
+ cmd=${cmd_name_hwid%%_*}
+ name_hwid=${cmd_name_hwid#*_}
+ name=${name_hwid%_*}
+ hwid=${name_hwid#*_}
+ syslog $cmd $name $hwid
+ $vyatta_sbindir/${cmd}_bootfile_eth_hwid $BOOTFILE $name $hwid
+ done
+}
+
start () {
+ udev_rescan
clear_or_override_config_files || \
log_failure_msg "can\'t reset config files"
set_reboot_on_panic || \
diff --git a/scripts/vyatta_net_name b/scripts/vyatta_net_name
index e048800e..9820d00f 100755
--- a/scripts/vyatta_net_name
+++ b/scripts/vyatta_net_name
@@ -21,6 +21,7 @@
#
# **** End License ****
+progname=${0##*/}
debug=
match=
attr_address=0:0:0:0:0:0
@@ -99,6 +100,15 @@ declare -a cfg_net_hwid=( $( sed -ne '
}
}' $BOOTFILE ))
+finish ()
+{
+ local cmd=$1 name=$2 address=$3
+
+ echo $name
+ touch /tmp/${progname}_${cmd}_${name}_${address} &> /dev/null
+ exit $?
+}
+
for name_hwid in ${cfg_net_hwid[@]} ; do
name=${name_hwid%=*}
hwid=${name_hwid#*=}
@@ -107,10 +117,7 @@ for name_hwid in ${cfg_net_hwid[@]} ; do
last_ethn=$ethn
if [ "$hwid" == "$attr_address" ] ; then
# we mod the config file interface sub-clock in case it is missing
- [[ "$BOOTFILE" != *test_* ]] && \
- ${vyatta_sbindir}/mod_bootfile_eth_hwid $BOOTFILE $name $attr_address
- echo $name
- exit 0
+ finish mod $name $attr_address
fi
[ "$name" == "$kname" ] && \
match=$name_hwid
@@ -123,13 +130,11 @@ done
if [ -z "$match" ] ; then
# the kernel interface name isnot in config
# so, we might as well use it
- name=$kname
- cmd=add
+ finish add $kname $attr_address
elif [ -z "${match#*=}" ] ; then
# the config has this interface but the sub-block is missing the hwid
# so again, we might as well use the kernel name
- name=$kname
- cmd=mod
+ finish mod $kname $attr_address
else
# The device mac address is not in the config but the config
# has another hwid associated with the device name. This
@@ -137,15 +142,9 @@ else
# detected earlier than the device configured with this name.
# Since this is non-deterministic, we make a new name.
(( ethn = last_ethn + 1 ))
- name=eth$ethn
- cmd=add
+ finish add eth$ethn $attr_address
fi
-[[ "$BOOTFILE" != *test_* ]] && \
- ${vyatta_sbindir}/${cmd}_bootfile_eth_hwid $BOOTFILE $name $attr_address
-
-echo $name
-
# Local Variables:
# mode: shell-script
# sh-indentation: 4