11、TPU设置自动开机启动的用户自定义的命令行

1、首先进入指定目录创建脚本文件

mendel@hopeful-pig:/etc/init.d$ pwd
/etc/init.d

2、创建文件(set_wlan.sh),并写入需要开机之后执行的命令行

mendel@hopeful-pig:/etc/init.d$ cat set_wlan.sh 
#!/bin/bash
### BEGIN INIT INFO
# Provides:          set_wlan0.sh
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the set_wlan0.sh daemon
# Description:       starts set_wlan0.sh using start-stop-daemon
### END INIT INFO
sudo rm -rf ~/.set_waln0.txt

sudo ifconfig wlan0 up

echo "
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto wlan0
iface wlan0 inet static
address IP
netmask NETMASK
getway  GETWAY
broadcast BROADCAST
pre-up ip link set wlan0 up
pre-up iwconfig wlan0 essid ssid
wpa-ssid SSID
wpa-psk PASSWD
" > /etc/network/interfaces

sudo ifup wlan0

sudo ifconfig wlan0|grep -w inet|awk '{print $2}'|awk -F '/' '{print $1}' >>~/.set_wlan0.txt



#sudo ifconfig wlan0 IP
exit 0

3、设置文件访问权限和填入启动项

sudo chmod 775 set_wlan.sh
sudo update-rc.d set_wlan.sh defaults 90

# if you want to give up the pre operation, you can using the bottom command

cd /etc/init.d
sudo update-rc.d -f set_wlan.sh remove

 

上一篇:详细记录丨Realtek RTL8188FU WiFi 连接路由


下一篇:2020.11.24-2020.12.04