wx__CL2UeY 发表于 2022-7-9 14:01:34

关于开机自启动 WIFI 脚本的问题

本帖最后由 wx__CL2UeY 于 2022-7-18 11:12 编辑

在自启动目录 /etc/init.d 中观看了相关文件,但对内容的编写与后续操作毫无头绪。

wx__CL2UeY 发表于 2022-7-18 10:52:19

# WIFI 开机自动连接(Debian)

## Connmand

- 安装

```
apt install connmand
connmand --version
```

- 测试

```
connmanctl
enable wifi
scan wifi
agent on
services
connect xxxx.apk
ifconfig wlan0
```

- wifi 配置文件

```
cd /var/lib/connman/xxx.psk
vim settings

配置信息如下:
......
```

## 开机自启动脚本

- service 文件

```
cd /etc/systemd/system
vim rc-local.service
插入:

Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local


Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99


WantedBy=multi-user.target
```

- 启动服务

```
sudo systemctl enable rc-local.service
```

- 自启文件

```
vim /etc/rc.local
插入:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

connmanctl enable wifi
connmanctl agent on
connmanctl connect xxx.psk

exit 0
```

页: [1]
查看完整版本: 关于开机自启动 WIFI 脚本的问题