Firefly开源社区

打印 上一主题 下一主题

[技术讨论] 关于开机自启动 WIFI 脚本的问题

55

积分

0

威望

0

贡献

技术小白

积分
55
QQ

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

发表于 2022-7-9 14:01:34      浏览:2642 | 回复:1        打印      只看该作者   [复制链接] 楼主
问题描述及复现步骤:
本帖最后由 wx__CL2UeY 于 2022-7-18 11:12 编辑

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

log.zip

18.5 KB, 下载次数: 0, 下载积分: 灯泡 -1 , 经验 -1

WIFI_log.zip

16.17 KB, 下载次数: 0, 下载积分: 灯泡 -1 , 经验 -1

回复

使用道具 举报

55

积分

0

威望

0

贡献

技术小白

积分
55
QQ
发表于 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
插入:
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local

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

[Install]
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
```

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

友情链接 : 爱板网 电子发烧友论坛 云汉电子社区 粤ICP备14022046号-2
快速回复 返回顶部 返回列表