11. TPU sets a user-defined command line for automatic startup

1. First enter the specified directory to create a script file

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

2. Create a file (set_wlan.sh) and write the command line that needs to be executed after booting

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 172.××.×.54
netmask 255.255.255.0
getway  172.××.×.254
broadcast 172.××.×.255
pre-up ip link set wlan0 up
pre-up iwconfig wlan0 essid ssid
wpa-ssid trechina03
wpa-psk qdtre@2019
" > /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 172.22.2.38
exit 0

3. Set file access permissions and fill in startup items

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

 

Guess you like

Origin blog.csdn.net/sxj731533730/article/details/103676639