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 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、設置文件訪問權限和填入啓動項

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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章