To add functionality to small Linux, let's write a script.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Important points of knowledge: FILE=/ETC/LOCAL/SRC
from left to right
Echo ${file#/} A # indicates that the first/left content is stripped out of the execution result to ETC/LOCAL/SRC
Echo ${file##/} represents a left-to-right look, finds the last/and removes all left-hand content from the execution result to/SRC (for filename)
From right to left
Echo ${file%/*} Search from right to left/find first will/and right content all delete execution result to/etc/local (directory for fetching files)
Echo ${file%%/*} Go from right to left to the last/and remove all of its contents to the right
*******************************************************************
#!/bin/bash
#
# #复制生成路径
Dest=/mnt/sysroot
LIBCP () {
libpath=${1%/*}
[!-D $DEST $libpath] && mkdir-p $DEST $libpath
[!-e $DEST ${1}] && cp $DEST $libpath && echo "copy $ finished."
}
# #复制命令
BINCP () {
cmdpath=${1%/*}
[!-D $DEST $cmdpath] && mkdir-p $DEST $cmdpath
[!-e $DEST ${1}] && cp $DEST $cmdpath
For LIB in ' LDD $ | Grep-o "/.*lib\ (64\) \{0,1\}/[^[:space:]]\{1,\}"; Do
LIBCP $LIB
Done
}
Read-p "Your command:" CMD
until [$CMD = = ' Q ']; Do
! Which $CMD && echo "wrong command" && read-p "Input again" CMD && continue
Command= ' which $CMD | Grep-v "^alias" | Grep-o "[^[:space:]]\{1,\}" '
BINCP $COMMAND
echo "Copy $COMMAND finished"
Read-p "Continue:" CMD
Done
###########################################
At last
Mkdir/mnt/sysroot/lib/modules
Modinfo Mii The execution result has a path and then copies the path
cp/lib/modules/2.6.18....mii.ko/mnt/sysroot/lib/modules/
Modeinfo Pcnet32 the execution results have a path and then copy
Cp/lib/modules/2.6.18....net.pcnet32.ko
Sync
We look forward to automatically loading these two modules when booting
Vim/mnt/sysroot/etc/rc.d/rc.sysinit
Insmod/lib/modules/mii.ko
Insmod/lib/modules/pcnet32.ko
Ifconfig eth0 192.168.9.224/16
Ifconfig Lo 192.0.0.0/8
Sync
Add functionality to small Linux and automatically add dependent libraries to the appropriate location