diff options
-rwxr-xr-x | core/conf/rc.d/wlan | 47 | ||||
-rwxr-xr-x | tools/conf/etc/rc.d/blan | 13 |
2 files changed, 44 insertions, 16 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 diff --git a/tools/conf/etc/rc.d/blan b/tools/conf/etc/rc.d/blan index 56d1809..61ac2d6 100755 --- a/tools/conf/etc/rc.d/blan +++ b/tools/conf/etc/rc.d/blan @@ -1,14 +1,16 @@ #!/bin/sh # -# /etc/rc.d/net: start/stop network interface +# /etc/rc.d/blan: start/stop virtual network interfaces # DEV="br0" PHY="enp8s0" -ADDR=10.0.0.1 -NET=10.0.0.0 -MASK=24 +ADDR=10.0.0.254 +#ADDR=10.0.1.254 +MASK=8 +#GW=10.0.0.1 +GW=192.168.1.254 # one tap for each cpu core NTAPS=$((`/usr/bin/nproc`)) @@ -20,6 +22,7 @@ case $1 in /sbin/ip link set dev ${DEV} up /bin/sleep 0.2s + # Add network to virtual bridge /sbin/ip link set dev ${PHY} down /bin/sleep 0.1s /sbin/ip route flush dev ${PHY} @@ -28,7 +31,7 @@ case $1 in /bin/sleep 0.2s /sbin/ip link set dev ${PHY} master ${DEV} - #/sbin/ip route add default via ${GW} + /sbin/ip route add default via ${GW} for i in `/usr/bin/seq $NTAPS` do |