From 7de6c1179b895aac1f26b81173e64bff421d8b5f Mon Sep 17 00:00:00 2001 From: James Rayner Date: Fri, 30 May 2008 23:39:13 +1000 Subject: separate automagic from netcfg proper --- Makefile | 1 + contrib/net-auto | 43 +++++++++++++++++++++++++++++++++++++++++++ src/net-profiles | 8 +------- 3 files changed, 45 insertions(+), 7 deletions(-) create mode 100755 contrib/net-auto diff --git a/Makefile b/Makefile index 8634d96..eff422d 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,7 @@ install: install-contrib: install -m755 contrib/netcfg-auto-wireless $(DESTDIR)/usr/bin + install -m755 contrib/net-auto $(DESTDIR)/etc/rc.d tarball: sed -i "s/NETCFG_VER=.*/NETCFG_VER=$(VERSION)/g" src/netcfg diff --git a/contrib/net-auto b/contrib/net-auto new file mode 100755 index 0000000..add6711 --- /dev/null +++ b/contrib/net-auto @@ -0,0 +1,43 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions + +case "$1" in + start) + # Ensure any device renaming has occurred as intended + for daemon in "${DAEMONS[@]}"; do + if [ "$daemon" = "${daemon#!}" -a "$daemon" = "net-rename" ]; then + if ck_daemon net-rename; then + /etc/rc.d/net-rename start + fi + fi + done + + for network in ${AUTO_NETWORKS[@]}; do + case $network in + auto-*) # Automatic configuration, store type and get interface next + auto=$network + ;; + *) # Either interface or profile + if [[ "$auto" ]]; then # Auto set, so interface + /usr/bin/netcfg-$auto $network + unset auto + fi + esac + done + + add_daemon net-auto + ;; + stop) + /usr/bin/netcfg2 -a + rm_daemon net-auto + ;; + restart) + $0 stop; sleep 1; $0 start + ;; + *) + echo "usage: $0 {start|stop|restart}" +esac + +# vim: set ts=4 et sw=4: diff --git a/src/net-profiles b/src/net-profiles index d9cc4da..67ab5e8 100755 --- a/src/net-profiles +++ b/src/net-profiles @@ -33,14 +33,8 @@ case "$1" in menu) # Pull up menu of networks /usr/bin/netcfg-menu $NETWORKS_MENU_TIMEOUT ;; - auto-*) # Automatic configuration, store type and get interface next - auto=$network - ;; *) # Either interface or profile - if [[ "$auto" ]]; then # Auto set, so interface - /usr/bin/netcfg-$auto $network - unset auto - elif [ "$network" = "${network#!}" ]; then # otherwise profile + if [ "$network" = "${network#!}" ]; then # otherwise profile /usr/bin/netcfg2 -c $network fi ;; -- cgit v1.2.3-24-g4f1b