Trigger action when module is inserted (wake on lan)
DebianThis forum is for the discussion of Debian Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Trigger action when module is inserted (wake on lan)
Hi forum,
can anyone tell me how to trigger an action when a module il inserted?
My aim is to activate wake on lan, I have to activate the option on my NIC everytime I boot, so the most logic way of doing this is to trigger the small line of code (that I don't remember by now ) every time I load the modle for my NIC.
If your devices module supports options (modinfo modulename) why not add it to modules.conf, modprobe.conf or whatever the file is that lists module options? Else if it doesnt support options then you can possibly set it using ethtool/mii-tool using a "install <module> && { perform <action> }" line or post-install line.
could you be a bit more explicit?
Dunno if I can manage that. I thought I'd been quite verbose this time. OK. benefit of doubt, then...
I don't really get it how I can see if this module supports options...
Check with "modinfo modulename" where modulename is just the "short name" of your module. Like "processor" or "floppy".
but let's suppose it does, what next?
Find out what it is your distribution and kernel (there's a difference in the mechanism between how 2.4.x and 2.6.x kernels do this) uses to specify loading modules. Usually the conf files reside in /etc and are named something like modules.conf or modprobe.conf. Look inside these ASCII files for examples: if unsure post and I'm sure someone will comment.
I'll try to be a bit clearer...
I'm runnig debian unstable on amd64 kernel 2.6.15-1-amd64-generic. The module that should trigger an action is my NIC driver (sk98lin). The action to trigger is ´ethtool -s eth0 wol G´.
So, I should add this somewhere in my /etc/modules.con?
it doesn't seem to work
Tell me in detail how you tested it?
Are there any errors? In your syslog?
Is this line below the "options sk98lin" line?
Just in case post your modules.conf anyway.
Alright, here's my modules.conf (I've cut it a bit 'cause it's quite long)
Code:
### This file is automatically generated by update-modules
#
# Please do not edit this file directly. If you want to change or add
# anything please take a look at the files in /etc/modutils and read
# the manpage for update-modules.
#
### update-modules: start processing /etc/modutils/0keep
# DO NOT MODIFY THIS FILE!
# This file is not marked as conffile to make sure if you upgrade modutils
# it will be restored in case some modifications have been made.
#
# The keep command is necessary to prevent insmod and friends from ignoring
# the builtin defaults of a path-statement is encountered. Until all other
# packages use the new `add path'-statement this keep-statement is essential
# to keep your system working
keep
### update-modules: end processing /etc/modutils/0keep
### update-modules: start processing /etc/modutils/actions
# Special actions that are needed for some modules
# The BTTV module, up to kernel 2.4.17, does not load the tuner
# module automatically, so do that in here
if KERNEL_VER < 2.4.17
post-install bttv insmod tuner
post-remove bttv rmmod tuner
endif
### update-modules: end processing /etc/modutils/actions
### update-modules: start processing /etc/modutils/aliases
# Aliases to tell insmod/modprobe which modules to use
# Uncomment the network protocols you don't want loaded:
# alias net-pf-1 off # Unix
...
# Crypto modules (see http://www.kerneli.org/)
alias loop-xfer-gen-0 loop_gen
alias loop-xfer-3 loop_fish2
alias loop-xfer-gen-10 loop_gen
alias cipher-2 des
alias cipher-3 fish2
alias cipher-4 blowfish
alias cipher-6 idea
alias cipher-7 serp6f
alias cipher-8 mars6
alias cipher-11 rc62
alias cipher-15 dfc2
alias cipher-16 rijndael
alias cipher-17 rc5
# IDE modules changed names in 2.4.22
if KERNEL_VER >= 2.4.22
alias ide-mod ide-core
alias ide-probe-mod ide-detect
endif
### update-modules: end processing /etc/modutils/aliases
### update-modules: start processing /etc/modutils/alsa-base
# autoloader aliases
alias char-major-116 snd
alias char-major-14 soundcore
alias sound-slot-0 snd-card-0
...
above snd-mixer snd-mixer-oss
above snd-seq snd-seq-oss snd-seq-midi
above snd-emu10k1 snd-emu10k1-synth
above snd-via82xx snd-seq
# Cause a script to be run after snd-*-synth module initialization
post-install sk98lin ethtool -s eth0 wol g
post-install snd-emu8000-synth /lib/alsa/modprobe-post-install snd-emu8000-synth
post-install snd-emu10k1-synth /lib/alsa/modprobe-post-install snd-emu10k1-synth
# Cause a script to be run after card driver module initialization
post-install snd-ad1816a /lib/alsa/modprobe-post-install snd-ad1816a
post-install snd-ad1848 /lib/alsa/modprobe-post-install snd-ad1848
...
post-install snd-trident /lib/alsa/modprobe-post-install snd-trident
post-install snd-usb-audio /lib/alsa/modprobe-post-install snd-usb-audio
post-install snd-usb-usx2y /lib/alsa/modprobe-post-install snd-usb-usx2y
post-install snd-vx222 /lib/alsa/modprobe-post-install snd-vx222
post-install snd-vxpocket /lib/alsa/modprobe-post-install snd-vxpocket
post-install snd-wavefront /lib/alsa/modprobe-post-install snd-wavefront
post-install snd-ymfpci /lib/alsa/modprobe-post-install snd-ymfpci
# Prevent abnormal drivers from grabbing index 0
options snd-bt87x index=-2
options snd-atiixp-modem index=-2
options snd-intel8x0m index=-2
options snd-via82xx-modem index=-2
### update-modules: end processing /etc/modutils/alsa-base
### update-modules: start processing /etc/modutils/alsa-base-blacklist
# Uncomment these entries in order to blacklist unwanted modem drivers
# alias snd-atiixp-modem off
# alias snd-intel8x0m off
# alias snd-via82xx-modem off
### update-modules: end processing /etc/modutils/alsa-base-blacklist
### update-modules: start processing /etc/modutils/apm
alias char-major-10-134 apm
alias /dev/apm_bios /dev/misc/apm_bios
alias /dev/misc/apm_bios apm
### update-modules: end processing /etc/modutils/apm
### update-modules: start processing /etc/modutils/linux-sound-base_noOSS
...
alias sequencer off
alias soundcard off
alias usb-midi off
### update-modules: end processing /etc/modutils/linux-sound-base_noOSS
### update-modules: start processing /etc/modutils/paths
# This file contains a list of paths that modprobe should scan,
# beside the ones that are compiled into the modutils tools
# themselves.
### update-modules: end processing /etc/modutils/paths
I don't have anything about this in my syslog...
Maybe the problem is that I have to write a script that does my ethtool stuff so I don't have arguments in my modules.conf?
Alright, here's my modules.conf (I've cut it a bit 'cause it's quite long)
Just an OT remark but if you're gonna cut things using something like "grep -v "^#" file|grep -i [a-z]" will show you only the used lines and leave out the comments. Makes it better readable IMHO. You'll know it comes in handy once you start working with large confs like for Squid or confs that have a lot of defaults, but commented out, like sshd_config.
BTW, I don't see nothing weird in your /etc/modules.conf.
I don't have anything about this in my syslog
Ah, OK. Maybe look for logfiles in /var/log/ksymoops/ if you have that directory.
Maybe the problem is that I have to write a script that does my ethtool stuff so I don't have arguments in my modules.conf?
That shouldn't be necessary. I'm wondering how you did test it doesn't work. Let's test it by adding this line in /etc/modules.conf (placing doesn't matter as long as it's on its own line:
Code:
post-install sk98lin /sbin/ethtool -s eth0 wol g 2>/tmp/sk98lin.err >/tmp/sk98lin.log
After you "rmmod sk98lin && modprobe sk98lin" check /tmp/sk98lin.err and /tmp/sk98lin.log and also post output of "modinfo sk98lin". Thanks.
I've put this in my /etc/modules.conf:
<code>
post-install sk98lin /bin/echo zut > /home/benjalien/modprobelog
</code>
and when I run this:
<code>
rmmod sk98lin; modprobe sk98lin
</code>
nothing happens...
It seems Debian insists on dynamically creating /etc/modules.conf from stuff in /etc/modutils. So try adding the line to /etc/modutils/local instead and run update-modules or equivalent after that.
BTW, saying "nothing happens" isn't very methodical. If you would have said: "the line still is in /etc/modules.conf and /var/log/ksymoops/* and syslog don't contain any (error) messages and there's nothing on stdout/stderr" we would have known you checked all possibilities given. If this still doesn't work you better start reading up on how to set up modules in Debian yourself.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.