我有一个第三方软件。现在,每次我重启系统时,我都被迫insmod
通过 shell 手动加载模块。
我读了一点Ubuntu 维基百科-DKMS并找到了这个。所以我猜这个知识管理系统是目前最先进的。顺便提一下,我还在这里发现了这个问题:https://stackoverflow.com/questions/4356224/how-to-load-a-custom-module-at-the-boot-time-in-ubuntu- 但看起来这已经不再是最新的了。
所以,我的日常生活是这样的:
cd /usr/src/gx/kernel/gxsd/
make
/sbin/insmod gxsd.ko
cd /usr/src/gx/kernel/fxmc_usb/
make
/sbin/insmod fxmc_usb.ko
cd /usr/src/gx/examples/cpp/cpd
make
我从第三方模块的支持团队那里得到了反馈,每次重启时都必须这样做。但这不是选项。我想让它自动启动。
如果我没记错的话,这些make
部分只需要一次,对吧?我不需要make
每次重启时都使用。但是insmod
-part 需要再次执行,对吧?
我刚刚安装了 dkms,但是现在我不知道如何将这些 insmod 命令添加到自动启动中。
答案1
要允许任何人“自动”插入模块,请使用以下步骤:
- 创建以下脚本:
#!/bin/sh
# Example script for loading modules
# This script is in answer to question http://askubuntu.com/questions/660901/insmod-to-autostart
# Copyright (c) 2015 Fabby
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. See the GNU General Public License for more details.
# You DID NOT receive a copy of the GNU General Public License along with this program as the license is bigger then this program.
# Therefore, see http://www.gnu.org/licenses/ for more details.
# Note:
# untested as I do not have these proprietary modules.
# Version 0.1 DD 2015/08/13 converted from manual work.
# version 0.2 DD 2015/08/14 added sudo ls /home
# Activate sudo with bogus command so next lines will not need password
sudo ls /home > /dev/null
if [ "$EUID" -ne 0 ]; then
read -p "You need to be a member of the im-operator group or root to be able to run this script"
exit
fi
# Make statement : cd /usr/src/gx/kernel/gxsd/&&make
# Insmod statement : /sbin/insmod gxsd.ko
sudo /sbin/insmod /usr/src/gx/kernel/gxsd/gxsd.ko
# Make statement : cd /usr/src/gx/kernel/fxmc_usb/&&make
# Insmod statement : /sbin/insmod fxmc_usb.ko
sudo /sbin/insmod fxmc_usb.ko
# Make statement : cd /usr/src/gx/examples/cpp/cpd&&make
# Seems superfluous, so let's skip this
- 保存在
/usr/local/bin/DasSaffe_insmod.sh
执行以下命令:
chmod +x /usr/local/bin/DasSaffe_insmod.sh
现在我们需要允许这台机器上的所有用户加载这些模块,因此我们将调整该
sodoers
文件:sudo visudo
现在查找部分
### Alias section ###
,然后查找# Cmnd alias specification
。添加以下行:
# Fabby: 2015-08-14 Create special operator for insmod InsMod_alias INSMOD_OPERATOR=/sbin/insmod, /usr/local/bin/DasSaffe_insmod.sh
现在查找以下部分:
# Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL
并在下面添加:
# Fabby: 2015-08-14 Allow the group "im-operator" to use certain applications
%im-operator ALL=CMD_OPERATOR
im-operator
通过以下方式添加组和您的用户:sudo groupadd im-operator&&sudo adduser $USER im-operator
转到仪表板并输入
startup app
,然后单击那里的唯一图标。- 点击Add
- 在
Command
字段类型中:以及在和字段DasSaffe_insmod.sh
中输入任何你喜欢的内容,它会提醒你这是什么。Name
Comment
- 测试:重新启动并登录。
警告:我无法在上面进行测试,所以你是我的实验对象。请留言,看看这是否有效。
如果它确实有效,那就很简单了:
sudo adduser zsUserName im-operator
其中szUserName
是用户的名称,允许他们从该时间点开始插入模块。