summaryrefslogtreecommitdiffstats
path: root/src/net-profiles
blob: f9c2875116ecd1f3b7d178500d42b5ff5e712e4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash

. /etc/rc.conf
. /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

		# 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 

		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}"  
esac

# vim: set ts=2 noet: