[Solved]Automating a script for a usb device on systemd?

Solution:See 3rd post by 65kid.
   Ok I'm trying to learn how to automate the execution of a script I wrote to run whenever a specific usb device is plugged in. In this case a usb flash drive with a specific partition identified though UUID following the path /dev/disk/by-uuid/specified-partion's-uuid.
   Basically the script uses rsync to update a snapshot of my system which I made bootable on this device. following the guide given in the wiki on full system backup using rsync I edited the --exclude options to ignore the contents of my /boot/ /etc/fstab and /etc/mkinitcpio.conf since the fstab entries, hooks array and initramfs and kernel images generated with them needed to be changed so as to make this snapshot bootable and adapted for use on the usb stick.
the ultimate goal is to have a bootable snapshot the can be updated with whatever changes have been made with my system(i.e. pacman -Syu updates,config changes etc...) while leaving out the important things needed to have the usb still bootable afterwards. I've already succeeded at getting the script to work but I have to mount it manually then execute the script myself and I know that it works afterwards as I can still boot from the stick afterwards.
   This is not a question about rsync (which is why the script isn't posted here), to repeat myself, It's about how to execute ANY custom script whenever a specific device is plugged in. More specifically when a storage device with a certain uuid is detected after the device has been plugged in. I believe it may be different for running pure systemd and so that was the reasoning for having it mentioned in the subjects title(if I'm wrong then correct my understanding). If anything a few pointers on where to look would be appreciated. I've been googling and reading the wiki a bit with nothing specific on how to approach this. If an example of the script is requested I'll post it but it's not relevent to my question.
   For a general veiw of my setup regarding external storage volumes I do not automount anything as I do not use all the things I plug in in the same manner. Some of the stuff I do requires them to be unmounted or  mounted to different mount points(specified by me). The script handles the mounting part by itself just fine. The idea I have is to run it automatically when the flash drive is present. Any suggestions?
Last edited by Thme (2012-12-29 00:06:56)

Awebb wrote:You "seem to remember" has FUD potential, could you care to find the post again?
he is probably referring to this: https://bbs.archlinux.org/viewtopic.php … 2#p1113682
imho this is way different, the SYSTEMD_WANTS tag is completely ok to use. yes, he may be mounting the drive from the script, but imho he is not "exploiting" anything here. I personally don't see a much more elegant way to do this.
these automount udev rules were however crappy and hackish. They were created by people who are like "but udisks is bloat!!1!" and whoever wrote them didn't really seem to know what he was doing because, for example, unmounting a device after it was unplugged from the system is completely non-sense.

Similar Messages

  • [SOLVED] setting up permissions for mounted usb devices

    Hi all,
    I've been having the following problem when mounting my external hd: in order to mount the external hd I created a folder /mnt/usbstick/ giving permissions to a non-root user to read the files/directories in this folder (using chmod); however, after I mount the external hd, the set of permissions for /mnt/usbstick/ change so that a non-root user cannot  read the mounted files in /mnt/usbstick. This is a problem for me because, when I copy a file from the external hd to the non-root home folder, the copied file can only be read by the root user.   
    Do you know how I can solve this problem? Should I write a udev rule and place it at /etc/udev/rules.d/? Or should I simply add the non-root user to a specific group from /etc/group? Any ideas?
    Thanks!
    Last edited by falsum (2010-05-08 09:21:59)

    You could try adding an entry for your usb device in /etc/fstab and specify the option user to let non-superusers mount it.
    Here's an example of an entry for my external HD. I'm sure there are probably other (and better) ways to do this but it works for me.
    UUID=4376-0BFB /media/FIRELITE vfat rw,user,noauto,async 0 0
    Nice howto found on the wiki: http://wiki.archlinux.org/index.php/Fstab

  • Software needed for the USB device, "USB Interface Controller TEST2.0"

    My mother recently acquired a digital camera. She acquired it from a second-hand store, which did not include an interface cable or software. The manual (and the USB port on the camera) indicates that a male-male USB cable is necessary for photos to be copied to the hard drive.
    I was not successful in locating such a cable at any local electronics store (I assume such a cable is now out-of-date). I purchased one from a seller on eBay. The brand is "e circuit electronics".
    Upon powering up the camera with the cable connected to it and the computer, the following message appeared:
    "Software needed for the USB device "USB Interface Controller TEST2.0" is not available. Would you like to look for the software on the Internet?"
    I clicked "Yes". After an approximate two-minute wait, another message appeared stating:
    "Software Update is not able to connect to the Internet. Please check your configuration and try again."
    I deleted, "Software Update Preferences" in the Preferences folder inside the System Folder, without solving the problem. How do I solve the issue of allowing Software Update to connect to the Internet?

    Thank you for your continued assistance, BDAqua. Unfortunately, the driver you linked to does not seem to be compatible with the camera. It is a driver for the V20 model, whereas my model would correspond to be a V2755, as referenced from a list of other Vivicam models when during a search at the Open Drivers web site.
    From the system requirement about the card reader you gave me, it will not work, as this system is running 9.1. I am hesistant to upgrade this computer to 9.2, as I have experienced system unstability with that version, with even the 9.2.2 update applied.
    In the mean time, I have e-mailed Vivitar regarding this issue, but have as of yet received a reply.
    I am not certain as to other specifics to give you, in order to solve the Software Update problem. Please elaborate.
    Yes eww, the computer in question is able to fully connect to the Internet for all that I need. I am fully aware of the difference between a computer connecting to the Internet, and a computer connecting to a digital camera. I have 15 years of Macintosh experience.

  • I am trying to update my iTunes to 10.5.1 so that I can upgrade my 3GS phone but am getting the following error message when trying to install the itunes:Install step failed: Run pre upgrade script for apple mobile device support. Contact software manufac

    I am trying to update my iTunes to 10.5.1 so that I can upgrade my 3GS phone but am getting the following error message when trying to install the itunes: Install step failed: Run pre upgrade script for apple mobile device support. Contact software manufacturer for assistance. I am on a MacBook pro running 10.5.8 OS. Has anyone seen this before and how can I get it resolved.
    Thanks for your help in advance....

    Did you ever figure out the problem? "Contact Software Manufacturer"?? That sounds ominous... I've got the same issue and I'm pretty durn aggravated right about now....
    Thanks!

  • Does anyone know how to get the vendor ID and product ID for a USB device in NI-Visa? TIA

    Does anyone know how to get the vendor ID and product ID for a USB device in NI-Visa? TIA

    Hello,
    Exactly which USB device are you referring to? Is the device a NI product?
    The Product ID for National Instruments DAQPad-6020E is 0x12C0. The USB vendor ID is 0x3923. This is a 16-bit hexadecimal number(1093) (that is decimal 4243).
    Also, here's a document on our website that will help you in configuring NI-VISA to control your USB device:
    http://zone.ni.com/devzone/conceptd.nsf/webmain/6792BAB18242082786256DD7006B6416?opendocument
    Swapnil P.
    National Instruments Engineer

  • I have an older Macbook with OS/X. Tried to download iTunes 10 a few times now, but when installing I always get the same error message: Run Preinstall Script for Apple Mobile Device Support. What can I do to finalise the installation?

    I have an older Macbook with OS/X. Tried to download iTunes 10 a few times now, but when installing I always get the same error message: Run Preinstall Script for Apple Mobile Device Support. What can I do to finalise the installation?

    Thanks. Short of the sort of "generic" suggestions of restaring your system, if you haven't, and repairing disk permissions and verifying the disk, I don't have any advice right now. I'll do some research and see if I can come across anything. Meanwhile, someone else may have an idea.
    Regards.

  • I'm not able to upgrade my Mac to itunes 10.5. Keep getting message "Run pre upgrade script for apple mobile device support" any help please?

    Hi I'm not able to upgrade my Mac OS X 10.5.8 to itunes 10.5 Keep getting message "the following install failed. run pre upgrade script for apple mobile device support" contact software manufacture for assistance. any help please?

    Did you ever figure out the problem? "Contact Software Manufacturer"?? That sounds ominous... I've got the same issue and I'm pretty durn aggravated right about now....
    Thanks!

  • Caznnot upgrade my iTunes to version 10.4.1---get message---The following install step failed: runupgrade script for Apple mobile device support.--Contact softwae=re manufacturer for assistance

    Cannot upgrade my iTunes to version 10.4.1---get message---The following install step failed: runupgrade script for Apple mobile device support.--Contact softwae=re manufacturer for assistance.
    Can someone help me?
    Thank you.
    Gerald

    me too did you get any help?

  • Cannot upgrade my iTunes to version 10.4.1---get message---The following install step failed: runupgrade script for Apple mobile device support.--Contact softwae=re manufacturer for assistance.   Can someone help me? Thank you.   Gerald

    Cannot upgrade my iTunes to version 10.4.1---get message---The following install step failed: runupgrade script for Apple mobile device support.--Contact softwae=re manufacturer for assistance.
    Can someone help me?
    Thank you.
    Gerald

    me too did you get any help?

  • [SOLVED] Openbox+Thunar, how to show usb devices in thunar?

    Hi.  I've been running a pretty standard Xfce environment for a while.  When I plug in a usb drive, I get a new item pop up in the "DEVICES" section of the left panel in thunar (note, it doesn't automount the device, it just shows that it's there and only mounts it when I click on it...I like this behaviour).
    Now, I'm setting up an even lighter-weight environment, just openbox and tint2 with thunar as the file manager.  But when I'm logged into the openbox environment, I don't get the item in the "DEVICES" section in thunar (but it still works fine in xfce).
    If it run thunar from the command line and plug in a usb drive I get this message in the terminal
    (thunar:21205): thunar-WARNING **: Failed to launch the volume manager (Failed to execute child process "thunar-volman" (No such file or directory)), make sure you have the "thunar-volman" package installed.
    I don't see why I would need thunar-volman if it works fine in xfce.  If I install thunar-volman and do the same, I get this message
    thunar-volman: Unsupported USB device type.
    thunar-volman: Unsupported USB device type.
    thunar-volman: Unknown block device type.
    So I'm wondering if maybe there is a daemon that is autostarted during an xfce session that makes thunar probe for devices to be plugged in or something like that.  Why does it work in an xfce session, but not in an openbox session?
    Last edited by Pacopag (2013-03-14 15:52:32)

    Thanks for your replies.
    henk:  I tried installing polkit-gnome and creating the rule as per the wiki, but it didn't work.  Volume detection seems to work fine in xfce without this package.
    jv2112:  I added udiskie to .config/openbox/autostart and it seems to work.  I've had problems with udiskie in the past; it seemed to have some trouble unmounting the drives properly after a write as I would find that the newly written files were corrupt.  But it seems to be working fine.
    I'll mark this as solved, but I'm still curious as to how xfce-thunar is mounting the usb devices. 
    One clue is that with udiskie, devices get mounted to /media, whereas in xfce they get mounted to /var/run/media/username/ (or something like that).

  • NI reset function for NI USB device available?

    Hi Just wondering if NI does provide reset function for any NI USB device?
    Just checking before purchasing NI USB device.
    regards,
    Clement

    Hi Clement,
    To add to what Mike said, you will be able to reset the USB device using the DAQmx driver. There are two ways to access this, using the DAQmx application programming interface (API) or in Measurement and Automation Explorer (which gets installed with DAQmx). The DAQmx Reset Device function immediately aborts all running tasks
    associated with the device. This action stops and releases any
    resources reserved for a task, such as trigger routes.
    Regards,
    Kent
    Applications Engineer
    Digital Multimeter Home

  • Setting Properties for a USB Device

    I am using LabView to manipulate a live video feed that is being supplied by a USB device.
    One device, a DVC100 (http://www.pinnaclesys.com/PublicSite/us/Products/Consumer+Products/Dazzle/Dazzle+Video+Archiving/Dazzle+DVD+Recorder.htm) works perfectly, as long as I set the correct input (S-Video or composite) through a secondary program.  I have tried the IMAQ USB Property Page.vi, but it does not access the input selection of the device, it does allow adjustment of some other useful features.  The secondary program is NOT device specific, it is a cheap video recording program, much like Windows Movie Maker, which allows for the same input adustment.
    I would like to be able to do this IN the vi that I have written, but I am not sure how to access the dll/driver to set the values.  I have written something in Visual Basic before using LabVIew that was able to talk to the driver to set the input value.  Is there an add-on or special vi that needs to be used to access the driver settings?
    I have another USB device, a Pinnacle HD Pro Stick (http://www.pinnaclesys.com/PublicSite/us/Products/Consumer+Products/PCTV+Tuners/PCTV+Analog_Digital+PVR/PCTV+HD+Pro+Stick) that has yet to work with my vi due to the same issue as above:  I need to set the driver with specifics of the capture device.  Unfortunately, setting the information in a secondary program, like above, does NOT work with this device.  I believe the reason is that along with the input selection, this time there is antennae, cable, S-Video and composite, but on top of this is the frequency for the antennae and cable.  The error I get from LabView is the following:  Error -1074396024 occurred at IMAQ USB Grab Setup.vi Error system.
    Is there something I can do in LabView directly, or is this something where I have to make a secondary program in something else to do these adjustments?
    Rich

    Hi rbergs,
    You can use the Call Library Function Node.vi in LabVIEW to make calls to the driver dll for the device. If you have made calls to the driver dll in VB, this should be pretty similar. Please look at this DevZone article for details on using this VI.
    Hope this helps.
    Jaidev
    National Instruments
    LabVIEW Embedded Product Support Engineer

  • Udev bash script for autodialing usb huawei modem

    Hey
    I've got an interesting one here.
    I have scripted up a bash script to be triggered by a udev add event for my usb modem. As far as I can tell the udev event is firing correctly according to udevadm.
    ACTION=="add", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1003", RUN+="/bin/sh /usr/local/bin/huawei_key.sh add"
    ACTION=="remove", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1003", RUN+="/bin/sh /usr/local/bin/huawei_key.sh remove"
    And heres the code from the script
    #!/bin/bash
    #returns
    # 0 Successfully ran script for case
    # 1 wvdial process already running
    # 2 wvdial was not terminated
    # 3 script was not ran with ADD or REMOVE events
    function getpid #get process id of running program
    pidof wvdial
    if [ "$?" = 0 ];
    then
    pid=`pidof wvdial`
    running=1
    else
    running=0
    fi
    function checkrun #check for a running copy of the program
    pidof wvdial
    if [ "$?" == "0" ];
    then
    running=1
    else
    running=0
    fi
    function killloop #a set of time kill commands to let the program exit gracefully
    #two terms, one int and one kill with suitable gaps
    getpid
    checkrun
    if [ "$running" = "0" ];
    then
    return
    fi
    kill $pid
    sleep 10
    checkrun
    if [ "$running" = "0" ];
    then
    return
    fi
    kill $pid
    sleep 10
    checkrun
    if [ "$running" = "0" ];
    then
    return
    fi
    kill -INT $pid
    sleep 5
    checkrun
    if [ "$running" = "0" ];
    then
    return
    fi
    kill -KILL $pid
    sleep 5
    checkrun
    if [ "$running" = "1" ];
    then
    exit 2 #process fails to die
    fi
    function getlaststatus
    if [ -e "/var/run/huawie" ];
    then
    last=`cat /var/run/huawie`
    else
    last=0
    fi
    if [ "$1" = "add" ];
    then
    getlaststatus
    if [ "$last" = "1" ];
    then
    exit 1
    fi
    echo 1 > /var/run/huawie #block future udev events
    getpid
    if [ "$running" = "1" ];
    then
    exit 1
    fi
    modprobe usbserial
    sleep 6 #modem init time
    wvdial &
    exit 0
    elif [ "$1" = "remove" ];
    then
    getlaststatus
    if [ "$last" = "2" ];
    then
    exit 0
    fi
    echo 2 > /var/run/huawie
    killloop
    exit 0
    else
    echo 3 > /var/run/huawie
    exit 3
    fi
    I'd appreciate any ideas, this one has me stumped
    Edit:
    Forgot to add that when I call the script manually it works like a charm.
    Last edited by adamd (2009-08-25 15:04:06)

    Hey
    I've got an interesting one here.
    I have scripted up a bash script to be triggered by a udev add event for my usb modem. As far as I can tell the udev event is firing correctly according to udevadm.
    ACTION=="add", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1003", RUN+="/bin/sh /usr/local/bin/huawei_key.sh add"
    ACTION=="remove", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1003", RUN+="/bin/sh /usr/local/bin/huawei_key.sh remove"
    And heres the code from the script
    #!/bin/bash
    #returns
    # 0 Successfully ran script for case
    # 1 wvdial process already running
    # 2 wvdial was not terminated
    # 3 script was not ran with ADD or REMOVE events
    function getpid #get process id of running program
    pidof wvdial
    if [ "$?" = 0 ];
    then
    pid=`pidof wvdial`
    running=1
    else
    running=0
    fi
    function checkrun #check for a running copy of the program
    pidof wvdial
    if [ "$?" == "0" ];
    then
    running=1
    else
    running=0
    fi
    function killloop #a set of time kill commands to let the program exit gracefully
    #two terms, one int and one kill with suitable gaps
    getpid
    checkrun
    if [ "$running" = "0" ];
    then
    return
    fi
    kill $pid
    sleep 10
    checkrun
    if [ "$running" = "0" ];
    then
    return
    fi
    kill $pid
    sleep 10
    checkrun
    if [ "$running" = "0" ];
    then
    return
    fi
    kill -INT $pid
    sleep 5
    checkrun
    if [ "$running" = "0" ];
    then
    return
    fi
    kill -KILL $pid
    sleep 5
    checkrun
    if [ "$running" = "1" ];
    then
    exit 2 #process fails to die
    fi
    function getlaststatus
    if [ -e "/var/run/huawie" ];
    then
    last=`cat /var/run/huawie`
    else
    last=0
    fi
    if [ "$1" = "add" ];
    then
    getlaststatus
    if [ "$last" = "1" ];
    then
    exit 1
    fi
    echo 1 > /var/run/huawie #block future udev events
    getpid
    if [ "$running" = "1" ];
    then
    exit 1
    fi
    modprobe usbserial
    sleep 6 #modem init time
    wvdial &
    exit 0
    elif [ "$1" = "remove" ];
    then
    getlaststatus
    if [ "$last" = "2" ];
    then
    exit 0
    fi
    echo 2 > /var/run/huawie
    killloop
    exit 0
    else
    echo 3 > /var/run/huawie
    exit 3
    fi
    I'd appreciate any ideas, this one has me stumped
    Edit:
    Forgot to add that when I call the script manually it works like a charm.
    Last edited by adamd (2009-08-25 15:04:06)

  • [solved] Permissions issue - can't mount usb device as user, just root

    In my last post I learned how to mount a secondary HDD from the command line.  Problem is I did it as root. Now I have xfce4 running and I need mount permissions as user.
    Here's my fstab:
    [dennis@archlinux media]$ cat /etc/fstab
    # /etc/fstab: static file system information
    # <file system> <dir> <type> <options> <dump> <pass>
    devpts /dev/pts devpts defaults 0 0
    shm /dev/shm tmpfs nodev,nosuid 0 0
    #/dev/cdrom /media/cd auto ro,user,noauto,unhide 0 0
    #/dev/dvd /media/dvd auto ro,user,noauto,unhide 0 0
    #/dev/fd0 /media/fl auto user,noauto 0 0
    /dev/sdb /media/disk0 ext4 rw,user,noauto 0 0
    /dev/sdb1 /media/disk1 ext4 rw,user,noauto 0 0
    /dev/sdb3 /media/disk3 ext4 rw.user,noauto 0 0
    UUID=1f813152-615e-41a1-b3e7-ce2b5b6836a5 / ext4 defaults 0 1
    UUID=aba18f0f-5f37-4ab0-8241-5a271dc3dddb swap swap defaults 0 0
    UUID=c4332450-df9e-4571-8256-8e1b10b4d162 /home ext4 defaults 0 1
    UUID=f0a6eca0-9668-454b-b444-371566663510 /boot ext2 defaults 0 1
    [dennis@archlinux media]$
    ....and these are the system messages I got when I plugged the device:
    Unable to mount "74G Volume":
    mount: only root can mount /dev/sdb3 on /media/disk3
    Unable to mount "4G Volume":
    mount: must be superuser to use mount
    What do I do here?
    Last edited by dennola4 (2010-06-28 00:56:51)

    Karol:
    # Cmnd alias specification
    # Defaults specification
    # Runas alias specification
    # User privilege specification
    root ALL=(ALL) ALL
    dennis ALL=(ALL) ALL
    %users ALL=(ALL) NOPASSWD: /usr/sbin/pppd
    %users ALL=(ALL) NOPASSWD: /usr/sbin/hibernate
    %users ALL=(ALL) NOPASSWD: /usr/sbin/standby
    # Uncomment to allow people in group wheel to run all commands
    %wheel ALL=(ALL) ALL
    # Same thing without a password
    %wheel ALL=(ALL) NOPASSWD: ALL
    # Samples
    # %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
    # %users localhost=/sbin/shutdown -h now
    Mr. Elendig:
    Why not use automounting instead?
    To install Arch packages I needed an Internet connection, which required use of a Sierra Wireless card, which required chatscripts stored on another filesystem.  In my first Arch forum post ever, the one preceding this one, I learned to mount a device by creating a mountpoint in /media then invoking #mount.  After installing all packages and creating a user name, I signed on with xfce4 and plugged in the usb device again.  It didn't mount.  So I did it manually using sudo.  Since that worked I had the idea that adding the mountpoints to /etc/fstab would be useful, so I did.  When that didn't work I decided to just ask for help.
    So sure, I'm down for some automounting action.  How do I do it?

  • How to build a Labview driver for a USB device?

    I have purchased a USB Hall probe (a device that measures magnetic fields) and now I need to build a LabVIEW driver for it (the company that sells this device did not build drivers for it, to keep the price down I suppose). The USB device does come with an operating software, but what I need is to control the device using LabVIEW. I have some experience with LabVIEW, but none with building drivers. I don´t really know where to start, so any advice would be helpful.

    To do USB in LabVIEW you'll want to get the NI-VISA driver. After you've got VISA, check out a few examples: 
    USB Instrument Control Tutorial
    Six Things You Need to Know about USB Instrument Control
    There are also examples built in to LabVIEW (under Help>>Find Examples to open the NI Example Finder, then under Hardware Input and Output>>VISA)
    Tim W.
    Applications Engineering
    National Instruments
    http://www.ni.com/support 

Maybe you are looking for

  • [CS3]How to export a table in InDesign to an excel file?

    Hi, Can any one tell me how to script the process of exporting a table to excel file in InDesign CS3 using javascript? Thanks in advance. myRiaz

  • ITunes Store Crashing iTunes

    I have updated to the new version of iTunes and whenever I try to access the iTunes Store it crashes iTunes. This started happening after the new download was installed. When I click on the store icon iTiunes behaves as usual with the bar filling up

  • Can't see my folios online...

    Hi, I've created folios with the Folio Builder panel in InDesign. I'm logged in from InDesign and the online DPS Folio Producer panel with the same login, but my folios aren't showing up in the online panel. Is this because I haven't purchased a memb

  • Olympus OM-D E-M5 Availability

    Will Best Buy be carrying the new Olympus OM-D E-M5 before August? I am going to be a photographer for our yearbook staff in our school and I would like to have it before school starts.

  • Openreach Engineer ?

    I am expecting an openreach engineer to visit my home in a few weeks to upgrade my current broadband from ADSL to Fibre. I understand that the process involves changing the faceplate on the BT Master Socket and connecting a new modem to the new facep