about summary refs log tree commit diff stats
path: root/core/conf/rc.d/wlan
diff options
context:
space:
mode:
authorSilvino Silva <silvino@bk.ru>2018-12-15 19:07:28 +0000
committerSilvino Silva <silvino@bk.ru>2018-12-15 19:07:28 +0000
commit57a604e35930f4f58aabe93c8c51de5ee378813c (patch)
treec525b26849561aaef85abd50b36c7d6f6344cbae /core/conf/rc.d/wlan
parent7dd5f7d9c2875f8d8b5ad7ba92484d805e94dabb (diff)
parentd29168d07293ffd1c8c1a186c42fc70f5461e928 (diff)
downloaddoc-57a604e35930f4f58aabe93c8c51de5ee378813c.tar.gz
doc-0.4.0 release
Diffstat (limited to 'core/conf/rc.d/wlan')
-rwxr-xr-xcore/conf/rc.d/wlan47
1 files changed, 36 insertions, 11 deletions
diff --git a/core/conf/rc.d/wlan b/core/conf/rc.d/wlan
index 86910bc..c9c60ec 100755
--- a/core/conf/rc.d/wlan
+++ b/core/conf/rc.d/wlan
@@ -3,8 +3,11 @@
 # /etc/rc.d/wlan: start/stop wireless interface
 #
 
-DEV=wlp7s0
+# Connection type: "DHCP" or "static"
+#TYPE="DHCP"
+TYPE="static"
 
+DEV=wlp7s0
 
 SSD=/sbin/start-stop-daemon
 PROG_DHCP=/sbin/dhcpcd
@@ -15,6 +18,11 @@ PID_WIFI=/var/run/wpa_supplicant.pid
 OPTS_DHCP="--waitip -h $(/bin/hostname) -z $DEV"
 OPTS_WIFI="-B -P $PID_WIFI -D nl80211,wext -c /etc/wpa_supplicant.conf -i $DEV"
 
+ADDR=192.168.1.67
+MASK=24
+GW=192.168.1.254
+
+
 print_status() {
 	$SSD --status --pidfile $2
 	case $? in
@@ -27,20 +35,37 @@ print_status() {
 
 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=$?
+
+		if [ "${TYPE}" = "DHCP" ]; then
+			$SSD --start --pidfile $PID_WIFI --exec $PROG_WIFI -- $OPTS_WIFI && \
+			$SSD --start --pidfile $PID_DHCP --exec $PROG_DHCP -- $OPTS_DHCP
+			RETVAL=$?
+		else
+
+			/sbin/ip link set ${DEV} up
+
+			$SSD --start --pidfile $PID_WIFI --exec $PROG_WIFI -- $OPTS_WIFI 
+
+			RETVAL=$?
+
+			/sbin/ip addr add ${ADDR}/${MASK} dev ${DEV} broadcast +
+			/sbin/ip route add default via ${GW}
+		fi
 		;;
 	stop)
-		( $SSD --stop --retry 10 --pidfile $PID_DHCP 
-		  $SSD --stop --retry 10 --pidfile $PID_WIFI )
 
-		RETVAL=$?
-		  /sbin/ip route del default dev ${DEV}
-                  /sbin/ip route flush dev ${DEV}
-                  /sbin/ip link set ${DEV} down
-                  /sbin/ip addr flush dev ${DEV}
+		if [ "${TYPE}" = "DHCP" ]; then
+			( $SSD --stop --retry 10 --pidfile $PID_DHCP 
+			  $SSD --stop --retry 10 --pidfile $PID_WIFI )
+			RETVAL=$?
+		else
+			$SSD --stop --retry 10 --pidfile $PID_WIFI 
+			RETVAL=$?
 
+			/sbin/ip link set ${DEV} down
+			/sbin/ip route del default
+			/sbin/ip addr del ${ADDR}/${MASK} dev ${DEV}
+		fi
 		;;
 	restart)
 		$0 stop