General :: Udev Rule To Invoke A Script?
Mar 29, 2011I am not good at writing udev rules. I am using RHEL 4.7, I would like to invoke a file install.sh which is in CDROM as soon as the CDROM is inserted
View 2 RepliesI am not good at writing udev rules. I am using RHEL 4.7, I would like to invoke a file install.sh which is in CDROM as soon as the CDROM is inserted
View 2 RepliesI'm running Ubuntu 9.10 (Karmic Koala) on a laptop and would like NumLock to automatically toggle depending on whether my USB keyboard is plugged in (numlock on) or unplugged (numlock off).
To accomplish this, I first installed the "numlockx" package. numlockx on and numlockx off works fine.
To hook into the device system, I thought I'd use udev. I have read "Writing udev rules", but I'm having trouble getting the udev rule to work.
First, here's an example of the dmesg output:
[20906.985102] usb 3-2: new low speed USB device using uhci_hcd and address 6
[20907.166403] usb 3-2: configuration #1 chosen from 1 choice
[20907.192904] input: Microsoft Natural® Ergonomic Keyboard 4000 as /devices/pci0000:00/0000:00:1a.0/usb3/3-2/3-2:1.0/input/input20
[20907.193100] microsoft 0003:045E:00DB.000B: input,hidraw1: USB HID v1.11
[Code]....
I am trying to write a udev rule for my headset but i don't understand where i get the information to make the rule. I know i need to add
Code: RUN+="bash /home/luke-jennings/headset" at the end of it so the script i wrote runs. I don't know how to get any of the identifying info for the headset and which bits to use where. How do I get the information?
I'm trying to set my network interfaces so that they don't get random every boot.(eg assign eth0 to a network interface with a given MAC addr, and eth1 to the other one)I trew in a udev rule (in fact just modified the rules that was automatically generated and set the ethX in it) but the system ignores my udev rule.What am I missing ?Here is all the info :
Code:
$cat /etc/udev/rules.d/70-persistent-net.rules
# This file maintains persistent names for network interfaces.
[code]....
I have a UDEV rule below that maps a symlink from a specific usb device and 'Should' run a command.
Code:
BUS=="usb",SYSFS{serial}=="1111111111111111111111111111",SYMLINK+="myusbstick_%n",RUN+="/usr/local/bin/my_command"
The symlink part is fine but it does not appear to run the command when I plug the device in. I can run the command "/usr/local/bin/my_command" from the shell fine.
Code:
mount /dev/myusbstick_1 /media/TMPUSB && cryptsetup luksOpen /dev/md5 md5_crypt --key-file=/media/TMPUSB/key && vgscan && vgchange -ay && mount -a && umount /media/TMPUSB
What am I missing. I have tried +x in owner,group and other.By the way what does UDEV run as, I assumned +x on ROOT as that is the owner should be enough.
On Ubuntu 10.04 I would like to setup udev to execute a backup script when a specific USB drive is inserted. Udev detects the USB drive, but my script is executed 7 times instead of just once. Can't figure out what's wrong.
My udev rules file:
Code:
/etc/udev/rules.d# cat 20-stick.rules
ACTION=="add", ATTRS{vendor}=="Kingston", ATTRS{model}=="DataTraveler G2 ", RUN="/usr/local/bin/sync.sh"
Dummy backup script: connecting USB drive results in 7 times date written to /tmp/test
code....
i need all my /media/* newly created by insertion of usb drives, chmodded 666.I tried some tips using various threads, but i failed.I'm on Slack 64 13.0.
View 14 Replies View RelatedI'm having some trouble with udev, in that it won't create me a symlink for the infrared device which is part of my Hauppauge Nova-TD-500 TV card.I've got the card installed, and for the most part working, but I want to have the infrared device on /dev/ir.I've created a rule in /etc/udev/rules.d/ called 55-dvb_usb_dib0700-ir.rules which contains this:
Code:
SUBSYSTEM=="input", ATTR{name}=="IR-receiver inside an USB DVB receiver", RUN="/bin/date > /home/xbmc/foo", SYMLINK+="ir"
[code]....
I'm trying to configure gpsd 2.96 to start automatically from udev rule on a Slack 13.37 box.1. I've compiled and installed gpsd from sources and made sure it starts manually.2. I've copied the /lib/udev/gpsd.hotplug and /lib/udev/gpsd.hotplug.wrapper scripts in their places from the source tree and made them executable.3. I've copied the gpsd.rules file from sources into /etc/udev/rules.d4. I renamed it 99-persistent-gpsd.rules to run late in the bootup process.5. I've copied the /etc/default/gpsd file from sources and made sure it has the right settings inside.
Now, for the results. If I plug the gps usb dongle in while the system runs, it starts gpsd if it is not started, and it connects to it just as it should. But if I start the system with the dongle in, gpsd doesn't get started during boot. I can't find any relevant message in /var/log/syslog or /var/log/messages for boot time. There is stuff there from when I plug the dongle in while the system is running though. It's like udev ignores the rules for it at boot time.Is there something in the Slackware boot scripts that would prevent running those scriptssd.hotplug.wrapper which in turn runs /lib/udev/gpsd.hotplug which is a Python script)?Here is the contents of 99-persistent-gpsd.rules (ignore the comments referring to Debian, it was meant for a Debian box). My usb gps adapter is the first one - the Prolific chipset one:
Code:
# udev rules for gpsd
# $Id: gpsd.rules 5861 2009-08-03 13:41:01Z bzed $
[code]....
I have a trayless SATA hotswap bay that is really terrific for quickly attaching and removing SATA hard drives. I'm trying to write a udev rule to create a symbolic link to the device node for the drive that is attached through the hotswap bay (/dev/bay -> /dev/sdX). This eliminates any ambiguity when performing destructive tasks (fdisk, etc). I'm running squeeze amd64. I've read through several tutorials and have it working somewhat. Here's the output of udevadm info for a drive attached via the hotswap bay.
looking at device '/devices/pci0000:00/0000:00:11.0/host7/target7:0:0/7:0:0:0/block/sdb':
KERNEL=="sdb"
SUBSYSTEM=="block"
DRIVER==""
ATTR{range}=="16"
ATTR{ext_range}=="256"
ATTR{removable}=="0"
ATTR{ro}=="0"
ATTR{size}=="156301488"
ATTR{alignment_offset}=="0"
ATTR{capability}=="52" ....
Here is my udev rule
DEVPATH=="/devices/pci0000:00/0000:00:11.0/host7/*", SUBSYSTEM=="block", SYMLINK+="bay%n"
This produces the desired behavior and gives me an fdisk-able device node. The problem I am having is that the "host" component of the DEVPATH varies from bootup to bootup. I'm just using on onboard SATA, host2-7, specifically host7. There is also onboard PATA, host0-1. It seems to just be random which "host"s are assigned to which controller. For example, the next time I boot the system, the onboard SATA will be host0-5 and the onboard PATA will be host6-7. In this simple case, I could just write 2 rules, one for each possibility and it would still be correct because of the different PCI addresses of the two controllers. But on systems with more SCSI (uh... libata, actually) controllers, a "host" file can point to different physical ports between bootstraps. This would be bad. Does anyone know of a way to write a rule to tie a device node to a specific physical SATA port on the motherboard/hba?
I have a netbook (MSI Wind U100 rebrand) that has one of those card readers built into the handrest. The thing is I've never used it once, and it keeps popping up in powertop as waking the cpu when it should just shut up and be quiet.Aside from breaking open the case and tearing it out, the immediate solution is to browse to /sys/bus/usb/devices/usb1/1-6/ and pipe 1 to the file remove. That disables it until system reboot or resume, at which point I have to do it all over again.
Code:
$ echo 1 | sudo tee /sys/bus/usb/devices/usb1/1-6/remove
Now I'd like to create an udev rule to make it not get initialized at all. A quick Google search found me this article on creating udev rules, and after toying about with the udevadm tool I managed to produce the attributes/properties of the device.
Code:
zorael@lethe:/sys/bus/usb/devices/usb1/1-6$ udevadm info -a -p $(pwd)
Udevadm info starts with the device specified by the devpath and then walks up the chain of parent devices. It prints for every device found, all possible attributes in the udev rules key format. A rule to match, can be composed by the attributes of the device and the attributes from one single parent device.
looking at device '/bus/usb/devices/usb1/1-6':
KERNEL=="1-6"
SUBSYSTEM=="usb"
DRIVER=="usb"
ATTR{configuration}=="CARD READER
[code].....
Question (and Google results aren't making this clear): Ubuntu has both iptables & ip6tables installed. 1. If I set a rule in iptables, does that rule also apply to ipv6, or just ipv4?
2. If "no" to above, then it would be prudent to *also* set ip6tables rules as well if I want to maintain an active firewall, correct?
3. Does ip6tables rules have the same syntax and behavior (more or less) to iptables rules - i.e. can I just copy my iptables rules & change "iptables" to "ip6tables"?
4. Any gotchas or issues that I should be aware of?
I want to use php for mailing on linux.But when I do it with"$a=`msmtp niubl967@gmail.com < /u1/ftp/mail.txt &`",it does not work.The mail.txt's contents are following:
Subject:test
Whenever I got to type the command below:
#iwconfig eth1 essid mynetwork key xxxxxxxx
#dhclient eth1
to use this command, i have to be in su or sudo. Is there a way I could allow all users to invoke these commands without the root password?? I try to make a file (wireless.sh), which consists the commands above, in /usr/local/bin/. Change the mode to 755 (chmod 755 wireless.sh) however, it does not allow me to use this also.
I just wonder the distinction calling the function between $(one_function) and one_function in bash shell script.
When I set the variable PS1 in ~/.bashrc, I can't invoke the function by one_func
ex:
export PS1="
[e[31m] $(one_func) # it works
export PS1="
[e[31m] one_func # it doesn't work
I'm using ArchLinux and I have an IP tables rule that I know works (from my other server), and it's in /etc/iptables/iptables.rules, it's the only rule set in that directory. I run, /etc/rc.d/iptables save, then /etc/rc.d/iptables/restart, but when I do "iptables --list", I get ACCEPTs on INPUT,FORWARD & OUTPUT.
# Generated by iptables-save v1.4.8 on Sat Jan 8 18:42:50 2011
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
[Code]....
I have created a new user define chain # iptanles -N blacklistNormally when we add a new rule it automatically insert in the default iptable but when we create a user define chain then how can I add my rules in this chain ?
View 3 Replies View RelatedDo I have to create a rule for:
Code:
$IPT -A fwalert -p tcp --tcp-flags SYN,ACK SYN,ACK -m conntrack --ctstate NEW $RLIMIT -j LOG $LOGLIMIT --log-tcp-options --log-level 4 --log-prefix
to drop rather than log if my table has a default policy of drop with :
Code:
$IPT -t fwalert -P DROP
I am getting this following error when I do compilation..Please let me know what is missing
ubuntu@ubuntu-desktop:/home/swamy/ttviewer/uvcvideo-2.6.32$ make
make -C /lib/modules/2.6.31-203-gee1fdae/build SUBDIRS=/home/swamy/ttviewer/uvcvideo-2.6.32 modules
make[1]: Entering directory `/usr/src/linux'
[code]....
I have samba running on 192.168.100.209 and I am trying to open samba ports only for hosts in 192.168.100.0/24 network.. I have added following rules to iptables. But still I am not able to connect from machines from 192.168.100.0/24 network
Code:
iptables -A INPUT -s 192.168.100.0/24 -p tcp --dport 139 -j ACCEPT
iptables -A INPUT -s 192.168.100.0/24 -p tcp --dport 445 -j ACCEPT
What's wrong with the above rules ?
I have configured a sendmail MTA for incoming mails in a network and by using IPtables i have redirected the traffic internally to other port where one more SMTP by a application is running.Iptables rule:iptables -A INPUT -i eth0 -p tcp --dport 25 -j ACCEPTiptables -A PREROUTING -t nat -i eth0 -p tcp --dport 25 -j REDIRECT --to-port 25000My sendmail config is as below.
Sendmail.mc
define(`SMART_HOST', `relay:host.subdomain.mydomain.com')dnl
dnl # define(`RELAY_MAILER',`esmtp')dnl
[code]...
My network diagram is internet<---->dansguardian proxy(centos5)<--->my network i have blocked facebook for my network but now i want to give only 2 ips to get its access & i do not want to enter these ip in exceptioniplist as if i doo so then they will be able to access all the sites that i have blocked. and if i am giving this entry [URL] in bannedsite list it is also not working.....
View 1 Replies View RelatedI am using Fedora 8. I tried to install ns 2.31. But error came as " No rule to make target "VERSION" needed by gen/version.c".
View 2 Replies View RelatedHow to update /dev directory after creation of new partition on a disk? I have the udev installed, it works perfectly except this. The new devices appear only on reboot.
View 1 Replies View Relatedsetting up the Xterminal ( xmanager ) application on Linux. I've installed Xterminal-1.0.7-1.i386.rpm on RHEL 4.0.May i know how could i invoke the installed application? What commands should i use?
View 13 Replies View RelatedInstalled FC-8 (DVD) on old dell 866mhez desktop years ago; works like a champ. Inherited dimension 2400, used same DVD. No errors loading (std config). Reboot and linux starts. Gets to 'Set clock - ok' and hangs on 'starting UDev'
Celeron 2.4G
bus speed 400M
L2 cache 128kb
384 DDR SDRAM
FC-8 2.6.23.1-42 on the DVD.
I know FC-12 is out, but with older HW, trying to stay compatible.
I have written a udev rule as follows:Code:RUN+=/.../.../example.shWhenever i plug in a USB drive, this rule is executed, however it is also done when i plug in a dongle for WiFi. How do i make this udev rule specific for USB drives only. In other words this script should be run for USB devices only.
View 3 Replies View RelatedI have to execute certain commands (like shutdown Tomcat) on several servers so I'm using a loop and ssh. I put the server's IP on a CSV file which I parse, execute the commands for each line and send the output to a file. The problem is that after processing one line the program stops execution. I wonder if someone could lend me a hand with this, I'm new in bash scripting and I ran out of ideas.
The CSV (servers.csv) file looks like this:
Code:
192.168.254.5:Server 1
192.168.254.6:Server 2
...
And the script looks like this:
Code:
#!/bin/bash
while IFS=: read ip name
do
sshpass -p "pass" ssh -o "StrictHostKeyChecking no" root@"$ip" 'sh <CATALINA_BASE>/bin/shutdown.sh' >> output.log
done < servers.csv
Is there any way to pipe video from the screen to a video device that can be used as if it came from a webcam? I assume it uses udev somehow...
View 4 Replies View RelatedI need to prevent udev from creating the /dev/v4l/by-path/* and /dev/v4l/by-id/* files upon connecting my webcam. The problem is that Kopete doesn't want to display the video if these files are present. It works fine if I remove them, but I'd rather not have them created in the first place, since they seem to be completely useless anyway.
View 4 Replies View Related