| you.chen | c992858 | 2023-04-24 15:39:37 +0800 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | |
| 3 | for ((i=0; i < 10; i++)); do |
| 4 | state=`systemctl is-active wg870_drv_insmod.service` |
| 5 | if [ "$state" == "active" ]; then |
| 6 | break |
| 7 | elif [ "$state" != "activating" ]; then |
| 8 | |
| 9 | systemctl start wg870_drv_insmod.service |
| 10 | fi |
| 11 | usleep 100000 |
| 12 | done |
| 13 | |
| 14 | if [ "$state" != "active" ]; then |
| 15 | exit 1 |
| 16 | fi |
| 17 | |
| 18 | for ((i=0; i < 10; i++)); do |
| 19 | connmanctl technologies | grep -q "/net/connman/technology/wifi" |
| 20 | if [ $? == 0 ]; then |
| 21 | connman_started=1 |
| 22 | break |
| 23 | fi |
| 24 | done |
| 25 | |
| 26 | if [ "$connman_started" == ""]; then |
| 27 | exit 2 |
| 28 | fi |
| 29 | |
| 30 | ifconfig | grep -q wlan0 |
| 31 | |
| 32 | if [ $? != 0 ]; then |
| 33 | connmanctl enable wifi |
| 34 | |
| 35 | for ((i=0; i < 5; i++)); do |
| 36 | usleep 100000 |
| 37 | ifconfig | grep -q wlan0 |
| 38 | if [ $? == 0 ]; then |
| 39 | wlan0_started=1 |
| 40 | wpa_cli -iwpa_wlan0_cmd -p/var/run/ IFNAME=wlan0 disconnect |
| 41 | break |
| 42 | fi |
| 43 | done |
| 44 | else |
| 45 | wlan0_started=1 |
| 46 | fi |
| 47 | |
| 48 | |
| 49 | if [ "$wlan0_started" == ""]; then |
| 50 | exit 3 |
| 51 | fi |
| 52 | |
| 53 | ifconfig | grep -q ap0 |
| 54 | |
| 55 | if [ $? != 0 ]; then |
| 56 | wpa_cli -iwpa_wlan0_cmd -p/var/run/ IFNAME=wlan0 DRIVER interface_create ap0 |
| 57 | connmanctl tether wifi on lynq 1qaz@WSX#$%^ |
| 58 | |
| 59 | for ((i=0; i < 5; i++)); do |
| 60 | usleep 100000 |
| 61 | ifconfig | grep -q ap0 |
| 62 | if [ $? == 0 ]; then |
| 63 | ap0_started=1 |
| 64 | wpa_cli -iwpa_wlan0_cmd -p/var/run/ IFNAME=ap0 disconnect |
| 65 | break |
| 66 | fi |
| 67 | done |
| 68 | else |
| 69 | ap0_started=1 |
| 70 | fi |
| 71 | |
| 72 | |
| 73 | if [ "$ap0_started" == ""]; then |
| 74 | exit 4 |
| 75 | fi |
| 76 | |