about summary refs log blame commit diff stats
path: root/core/conf/rc.d/wlan
blob: 263cf42a2c1633b9439cc8965b3c1d6508024098 (plain) (tree)






















































                                                                                     
#!/bin/sh
#
# /etc/rc.d/wlan: start/stop wireless interface
#
DEV=wlp7s0

SSD=/sbin/start-stop-daemon
PROG_DHCP=/sbin/dhcpcd
PROG_WIFI=/usr/sbin/wpa_supplicant
PID_DHCP=/var/run/dhcpcd-${DEV}.pid
PID_WIFI=/var/run/wpa_supplicant.pid

OPTS_DHCP="-h $(/bin/hostname) -C resolv.conf $DEV"
OPTS_WIFI="-B -P $PID_WIFI -D nl80211,wext -c /etc/wpa_supplicant.conf -i $DEV"

print_status() {
	$SSD --status --pidfile $2
	case $? in
	0) echo "$1 is running with pid $(cat $2)" ;;
	1) echo "$1 is not running but the pid file $2 exists" ;;
	3) echo "$1 is not running" ;;
	4) echo "Unable to determine the program status" ;;
	esac
}

case $1 in
	start)
		$SSD --start --pidfile $PID_WIFI --exec $PROG_WIFI -- $OPTS_WIFI && \
		$SSD --start --pidfile $PID_DHCP --exec $PROG_DHCP -- $OPTS_DHCP
		RETVAL=$?
		;;
	stop)
		( $SSD --stop --retry 10 --pidfile $PID_DHCP
		  $SSD --stop --retry 10 --pidfile $PID_WIFI )
		RETVAL=$?
		/sbin/ip link set ${DEV} down
		/sbin/ip addr flush dev ${DEV}
		;;
	restart)
		$0 stop
		$0 start
		;;
	status)
		print_status $PROG_WIFI $PID_WIFI
		print_status $PROG_DHCP $PID_DHCP
		;;
	*)
		echo "Usage: $0 [start|stop|restart|status]"
		;;
esac

exit $RETVAL

# End of file