foreword
The development board burns the Debian system image. Before writing the QT program, I think about how to make the program run automatically at startup, or load some necessary drivers at startup, and some initialization work.
After consulting some articles, the final experiment is feasible, and I will make a record here.
Proceed as follows:
First, write a script first
Create a new empty file mystart with the following content:
#!/bin/sh
#wifi
startPath1=/opt/8723du.ko
if [ ! -f ${startPath1} ];then
echo ${startPath1}
echo "File does not exist !"
else
sudo insmod ${startPath1}
echo "Wifi has been loaded !"
fi
#usblp
startPath2=/opt/usblp.ko
if [ ! -f ${startPath2} ];then
echo ${startPath2}
echo "File does not exist !"
else
sudo insmod ${startPath2}
echo "Usblp has been loaded !"
fi
#chmod lp0
startPath3=/dev/usb
if [ ! -d ${startPath3} ];then
echo ${startPath3}
echo "Directory does not exist !"
else
sudo chmod 777 ${startPath3}/lp0
echo "Permission has been released !"
fi
The approximate content of the script is:
1. If the file exists, load the WIFI driver.
2. If the file exists, load the USB print driver.
3. If the path exists, set the permission of the printer to mount the file.
2. Put the script in the /etc/init.d/ directory and set the executable permission
3. Add a link
sudo ln -s /etc/init.d/mystart /etc/rc2.d/S99mystart
In this way, the script file we wrote can be automatically run when Linux starts.
It's over, sprinkle flowers~~~
written in the back
When Linux starts, it will run a program called init, and then it will start the subsequent tasks, including user environment, network, module drivers, necessary programs and so on.
The script files are stored in the /etc/init.d/ directory, but the running of these scripts is in order, how to determine it?
1. First, the link file of the script is stored in the /etc/rcn.d directory, and n is divided into 0~6, among which:
directory name | illustrate |
rc0.d | run when the machine is off |
rc1.d | Single-user mode, similar to Windows' safe mode |
rc2.d | Multi-user mode, but without NFS support |
rc3.d | Full multi-user mode, which is the standard runlevel |
rc4.d | Generally not used |
rc5.d | Enter X Windows and execute |
rc6.d | run when the machine restarts |
2. In the rcn.d directory, the naming of the files determines the execution sequence.
For example, in the file S99mystart , S stands for start, and 99 stands for the startup sequence.
It's over, sprinkle flowers~~~