diff options
author | James Rayner <james@archlinux.org> | 2008-01-06 05:15:42 +0100 |
---|---|---|
committer | James Rayner <james@archlinux.org> | 2008-01-06 05:15:42 +0100 |
commit | 4997f3a7b48c41f6b4a78e11210106037545ddc2 (patch) | |
tree | c6f1bc4b36370e275104a7526573849057dfe223 /src/net-profiles | |
parent | 9f37f0b195fd75dd8a940f6478c5dcee8a5db4e3 (diff) | |
download | netctl-4997f3a7b48c41f6b4a78e11210106037545ddc2.tar.gz netctl-4997f3a7b48c41f6b4a78e11210106037545ddc2.tar.xz |
Added "automatic wireless" support and sort of 'cleaned' up rc.d/net-profiles
Diffstat (limited to 'src/net-profiles')
-rwxr-xr-x | src/net-profiles | 98 |
1 files changed, 54 insertions, 44 deletions
diff --git a/src/net-profiles b/src/net-profiles index f9c2875..d9cc4da 100755 --- a/src/net-profiles +++ b/src/net-profiles @@ -4,52 +4,62 @@ . /etc/rc.d/functions case "$1" in - start) - if ! ck_daemon net-profiles; then - echo "Network Profiles are already running. Try '/etc/rc.d/net-profiles restart'" - exit - fi + start) + if ! ck_daemon net-profiles; then + echo "net-profiles has already been started. Try '/etc/rc.d/net-profiles restart'" + exit + fi - # 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 + # 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 - # $NET env var is passed from the kernel boot line - [ ! "$NETWORKS_MENU_TIMEOUT" ] && NETWORKS_MENU_TIMEOUT=5 + # $NET env var is passed from the kernel boot line + [ ! "$NETWORKS_MENU_TIMEOUT" ] && NETWORKS_MENU_TIMEOUT=5 + + if [[ "$NET" = "menu" ]]; then + /usr/bin/netcfg-menu $NETWORKS_MENU_TIMEOUT + elif [[ "$NET" ]]; then + /usr/bin/netcfg2 -c $NET + else + # No NET= passed at boot, go to NETWORKS=() + for network in ${NETWORKS[@]}; do + case $network 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 + /usr/bin/netcfg2 -c $network + fi + ;; + esac + done + fi - if [ "$NET" = "menu" -o "$NETWORKS" = "menu" ]; then - /usr/bin/netcfg-menu $NETWORKS_MENU_TIMEOUT - elif [ "$NET" ]; then - /usr/bin/netcfg2 $NET - elif [ "${NETWORKS[0]}" = "auto-wireless" ]; then - if [ "${NETWORKS[1]}" ]; then - /usr/bin/netcfg-auto-wireless ${NETWORKS[1]} - fi - elif [ "$NETWORKS" ]; then - for prof in ${NETWORKS[@]}; do - if [ "$prof" = "${prof#!}" ]; then - /usr/bin/netcfg2 -c $prof - fi - done - fi - - add_daemon net-profiles - ;; - stop) - # shutdown any profiles started by netcfg (or from NET_PROFILES in rc.conf) - /usr/bin/netcfg2 -a - rm_daemon net-profiles - ;; - restart) - $0 stop; sleep 1; $0 start - ;; - *) - echo "usage: $0 {start|stop|restart}" + add_daemon net-profiles + ;; + stop) + # shutdown any profiles started by netcfg (or from NET_PROFILES in rc.conf) + /usr/bin/netcfg2 -a + rm_daemon net-profiles + ;; + restart) + $0 stop; sleep 1; $0 start + ;; + *) + echo "usage: $0 {start|stop|restart}" esac -# vim: set ts=2 noet: +# vim: set ts=4 et sw=4: |