Jump to content

Squid

Community Developer
  • Posts

    28,769
  • Joined

  • Last visited

  • Days Won

    314

Everything posted by Squid

  1. USB Hot Plug for VM's with no passthrough TLDR: The instructions are a pain for me to try and explain, but this script does work. Don't be afraid to ask questions. But first and foremost when experimenting with this on a running VM, set the startup delay to 1-2 seconds so you're not waiting forever for it to get up and running. Also make sure that you're on the latest version of user.scripts prior to playing around. EDIT: it appears that some devices can get tossed into a different bus group when plugged in. For this reason, this plugin basically is going to require a USB hub to be monitored for changes, as in my testing anything plugged into a hub will always stay in the same group as the hub A simple little script to monitor a particular USB bus for changes and then automatically attach / detach the USB device to a particular VM. Useful if you cannot pass through a USB controller to a VM (not that I need this as I have a USB controller passed through to my main VM, but I was rather dismayed at the libvirt USB Hotplug plugin which didn't support true hotplugging without going back to the UI and manually attaching / detaching devices) This started out as being a potential plugin, but there are enough caveats with the initial setup to make this impractical. Couple of variables within the script need to be set: $vmName - Set to the name of the VM (must be exact) $pollingTime - Set to the number of seconds between looking for changes $startupDelay - Set to the number of seconds to wait after array start to begin monitoring And 2 variables of which one or the other should be set: (Comment out the one line that's not going to get set (ie: put a # in front of it) ) $hubName and $bus If you are using a particular USB bus (ie: 2 particular ports on the computer), the set the $bus to be the bus as listed by lsusb If you are using a USB Hub, I recommend that you set this to the exact name of the USB hub as determined by lsusb And now the caveats (which are workable IMHO) Bus: each USB bus is going to handle multiple ports on your computer. You want to make sure that those ports are going to be dedicated to the VM in question (ie: You can't use one of those ports for say Unassigned Devices) Also, on my system I found that when I plug a USB hub into a particular bus, then the hub gets moved into another bus which may or may not already have devices on it. TLDR: If you use the "bus" variable, don't plug a USB hub into it -> it won't work. hubName: If you want to use a usb Hub, then set this variable to be the exact name of the hub. Problem with this mode is that if the hub when plugged in gets moved from an isolated bus to one with other devices on it then everything on that particular bus either has to be permanently attached to unRaid itself (not the VM) otherwise the script will attempt to detach / attach those items from the VM. This is the recommended way of handling USB devices To illustrate, I have numerous empty USB busses on my system. If I plug in a USB Hub into one of those usb's, then the hub winds up being moved from the empty bus to another bus on my system which already has my unRaid flash drive and keyboard on it. Since those two devices are permanently attached to unRaid, this isn't a big deal to me. The best way to figure out how to set things is to plugin and unplug a device from every usb port on your system and type lsusb in between to see how it all reacts. Like I said, if you don't need a hub, find an unused bus and use it. If you need a hub, then make sure that everything else on that bus is permanent to unRaid itself an be aware that any other ports on your system that are on the same bus will also be passed through to the VM. Note that when I'm talking about USB Busses, I am not referring to USB 2 or USB 3. Each motherboard will have multiple busses on the system, each of which in general will control 2 ports connected to it. Additional caveat, do to how linux operates, I cannot guarantee that a particular port will always be on the same bus over resets of the system, but in my testing, it always was. One final caveat. Because this plugin monitors the bus for changes, upon startup (after the initial startup delay is finished), any device plugged into the bus or hub will not be attached to the VM. You must pull the device and reinsert it. Any pull and reinsert of the same device should take longer than the polling time (I'm defaulting that to 10 seconds) Pulls and inserts of different devices can be done as fast as you want. #!/usr/bin/php <?PHP #backgroundOnly=true #description=A script designed to monitor a USB hub or a particular USB bus for changes and then attach or detach devices to an applicable VM $vmName = "Windows 10"; # must be the exact name $pollingTime = 10; # the interval between checks in seconds $startupDelay = 300; # startup delay before monitoring for changes in seconds (set to enough time for the VM to get up and running) # only use one or the other of the following lines not both See thread for details #$hubName = "Texas Instruments, Inc. TUSB2046 Hub"; # must be exact as listed via lsusb $bus = "02"; # see thread for details function getDeviceList($bus) { exec("lsusb | grep 'Bus $bus'",$allDevicesOnBus); foreach ($allDevicesOnBus as $Devices) { $deviceLine = explode(" ",$Devices); $initialState[$deviceLine[5]] = $deviceLine[5]; } return $initialState; } function createXML($deviceID) { $usb = explode(":",$deviceID); $usbstr .= "<hostdev mode='subsystem' type='usb'> <source> <vendor id='0x".$usb[0]."'/> <product id='0x".$usb[1]."'/> </source> </hostdev>"; file_put_contents("/tmp/USBTempXML.xml",$usbstr); } function logger($string) { shell_exec("logger ".escapeshellarg($string)); } # Begin Main logger("Sleeping for $startupDelay before monitoring $bus for changes to passthrough to $vmName"); sleep($startupDelay); $hubBus = $bus; if ( ! $hubBus ) { $hub = explode(" ",exec("lsusb | grep '$hubName'")); $hubBus = $hub[1]; } logger("Monitoring $hubBus for changes"); $initialState = getDeviceList($hubBus); while (true) { $unRaidVars = parse_ini_file("/var/local/emhttp/var.ini"); if ($unRaidVars['mdState'] != "STARTED") { break; } $currentDevices = getDeviceList($hubBus); foreach ($currentDevices as $Device) { if ( ! $initialState[$Device] ) { logger("$Device Added to bus $hubBus Attaching to $vmName"); createXML($Device); exec("/usr/sbin/virsh attach-device '$vmName' /tmp/USBTempXML.xml 2>&1"); $initialState[$Device] = $Device; } } foreach ($initialState as $Device) { if ( ! $currentDevices[$Device] ) { logger("$Device Removed from bus $hubBus Detaching from $vmName"); createXML($Device); exec("/usr/sbin/virsh detach-device '$vmName' /tmp/USBTempXML.xml 2>&1"); unset ($initialState[$Device]); } } sleep($pollingTime); } ?> Technie note: There is no way to monitor a particular port for changes, because every time you remove and insert a device, the device number associated with the bus increases. Also, this script does not use udev to automatically attach / detach the usb devices. This is because: the USB device in question may or may not be known prior to attaching (ie: a buddy brought over a USB stick for you to use), and secondly because in theory you could have multiple copies of this script running for different VMs and the same device may wind up being plugged into a different VM as you require, rather than the one udev dictated. IE: I went for flexibility at the expense of minimal processor time. USB_HotPlug.zip
  2. Because it's a replacement for the stock New Perms tool. But if its taking forever, then it may be hitting your appdata (make sure you have your default appdata location within settings - docker set up correctly), or are running an old version which was hitting the appdata backup created with CA Appdata Backup. But realistically, on a properly configured system there should never be a reason to have to run newperms ever...
  3. Bosses can be sooo unreasonable sometimes Probably this line in the log 13:06:16 superserver emhttp: Warning: preg_grep() expects parameter 2 to be array, boolean given in /usr/local/emhttp/plugins/unassigned.devices/include/lib.php on line 112 It would be wise to check for plugin updates to UD, and post in the UD thread.
  4. You reinstall Recycle Bin via CA until after upgrading to 6.3.0 It's listed as being incompatible with all versions prior to 6.3.0 so it won't appear within CA until after the upgrade If I delete Recycle Bin (using CA) prior to installing unRAID 6.3 and then install the new version of Recycle Bin (also using CA) after updating to 6.3 will my settings in Recycle Bin be preserved? Just wondering if I need to grab some screenshots first? No idea. Pretty much depends upon if as part of the uninstall if Recycle Bin is deleting its settings. dlandon's recommended procedure is to uninstall and then reinstall so screen shots would probably be wise.
  5. Dan, respectfully, please don't terminate the previous version, there will be users who stay with older versions, that's just the way it is, probably always will be. Just a note about the term 'deprecate', when you say something is deprecated, you aren't saying it's terminated, you are saying it's still available and completely usable, but that there's another option that is now preferred over it. For example, Microsoft would say that Windows 7 is deprecated in favor of Windows 10. Many users would disagree, and continue using it. I would prefer that auto update be turned off for the previous version, so that the Recycle Bin still works for all users, no matter what version they decide to use. Better way is a completely separate plg file for the new version. With the appropriate template settings, CA will only display the one that works on the user's system, and in the case of a later upgrade, FCP will catch if the incorrect version is installed
  6. Yes. Remove the old recycle bin and then use CA to get the latest version. You can do this either before or after the update. Do it after upgrading. It won't be listed within CA until after the upgrade to 6.3
  7. Do not do this if you have docker applications running.
  8. The video shows how it starts up, shuts down and then starts again on it's own and stays running. No beep no post no display nothing. Not sure how much else I can show if it's not working? The green light would never flash green. It would always be a solid green no flashing or anything The MB is a X9DR7-LN4F Did you check if you have a spacer shorting the motherboard? I did and there was an extra mb standoff so I removed it but it still wont boot up. I don't think it's my PSU because the system stays on. Not a good thing. If you didn't wind up blowing your motherboard consider yourself lucky Sent from my Nexus 7 using Tapatalk
  9. Missing csrf_token on Dynamix Active Streams when trying to assign a user name to an IP Feb 3 13:50:16 Server_A root: error: update.php: missing csrf_token
  10. As requested, diagnostics attached... Thanks. Just wondering if anyone with far more knowledgable than me has managed to work out what might be causing the trace issues? Thanks. You should post a new thread in general support where more eyes will see it.
  11. Why? Because people asking for help often forget to include it and when requested manage to attach the wrong file. lol Everyone forgets to include it, and when they do Trurl et al bug them that there's no reason to include it, because diagnostics already includes it (but with troubleshooting mode, the syslog.txt will contain up to 30minutes more logging than the last diagnostics)
  12. What I do is change the share names to be zzz-Squidbait so that while they show they are at least at the bottom of the lists Sent from my LG-D852 using Tapatalk
  13. You would need to post your diagnostics. Call traces are meaningless without knowing what leads up to them. Sent from my LG-D852 using Tapatalk
  14. Easiest way is to overwrite the existing file (probably stored in /usr/local/emhtttp/plugins/sshWhateverTheFolderIs/images) with your replacement. You'd have to store the replacement on the flash drive somewhere and either create a script to run at array start with the user scripts plugin, or add the appropriate command to the go file on the flash drive.
  15. Two things. Within SMB settings you want Hide Dot Files to be yes. And Windows also has to be set to not show hidden files
  16. 1 - Not currently. I have however begun initial planning on a new plugin (or significantly expanding the capabilities of this one) that will have multiple sources, multiple destinations, multiple schedules, etc etc etc. 2 - The plugin uses the built-in notification system. You should be able to enable Agents on the Notifications from Settings Notifications, and have it work. I don't use any agents at all so not sure about that though.
  17. No real clue. The back does standard docker stop and docker start commands. You can tell it to keep any container running thru the advanced section Sent from my LG-D852 using Tapatalk
  18. Thanks a lot. Didn't know about this plugin but it seems to be exactly what I've searched for. I would think the autostart manager is simpler as it sounds like some sort of race condition and you just need to delay it. But it's 6.3 only Sent from my LG-D852 using Tapatalk
  19. Personally I would try CA docker autostart manager and delay the start of those apps to see what happens first. But if that doesn't work I would try this as a script running at startup. sleep 300 docker stop emby sleep 60 docker start emby Sent from my SM-T560NU using Tapatalk
  20. Hmm, I'm getting You're crossing mount points. You'll have to rearrange your folders again so they're all within the same mount with cp -al
  21. Should be a good workaround. That'll link the files, not the directories themselves...
  22. Ok, so I re-organised to have /mnt/user/tvshows/TV and /mnt/user/tvshows/kids, and trying both ln /mnt/user/tvshows/TV/The\ Simpsons/ /mnt/user/tvshows/Kids/The\ Simpsons fails with "hard link not allowed for directory" and ln -d /mnt/user/tvshows/TV/The\ Simpsons/ /mnt/user/tvshows/Kids/The\ Simpsons fails with "Operation not permitted" I'm Running 6.3.0-rc9. Never tried it with directories. But perhaps Limetech did not include support for hardlinking directories when they added support for hardlinks on user shares.
  23. Hardlinks do work in unRaid (6.2+) But hardlinks always have to be within the same mount point as on any system. ie: You can hardlink a file from /mnt/user/Movies/MyMovies to /mnt/user/Movies/KidMovies but not from /mnt/user/Movies to /mnt/user/KidMovies
  24. Automatic blacklisting if a template is potentially a security risk
×
×
  • Create New...