Jump to content

Squid

Community Developer
  • Posts

    28,769
  • Joined

  • Last visited

  • Days Won

    314

Everything posted by Squid

  1. Move Cache Only Share and Move Array Only Shares These two scripts will analyse your shares and move any files found on the array (for cache-only shares) to the cache drive, and its reverse script to move any files found on the cache drive to the array (for array-only shares) These two scripts require user.scripts version 2016.07.16+ to operate Move Cache Only Shares #!/usr/bin/php <?PHP function getRsyncReturnValue($returnValue) { $returnMessage[0] = "Success"; $returnMessage[1] = "Syntax or usage error"; $returnMessage[2] = "Protocol incompatibility"; $returnMessage[3] = "Errors selecting input/output files, dirs"; $returnMessage[4] = "Requested action not supported: an attempt was made to manipulate 64-bit files on a platform that cannot support them; or an option was specified that is supported by the client and not by the server."; $returnMessage[5] = "Error starting client-server protocol"; $returnMessage[6] = "Daemon unable to append to log-file"; $returnMessage[10] = "Error in socket I/O"; $returnMessage[11] = "Error in file I/O"; $returnMessage[12] = "Error in rsync protocol data stream"; $returnMessage[13] = "Errors with program diagnostics"; $returnMessage[14] = "Error in IPC code"; $returnMessage[20] = "Received SIGUSR1 or SIGINT"; $returnMessage[21] = "Some error returned by waitpid()"; $returnMessage[22] = "Error allocating core memory buffers"; $returnMessage[23] = "Partial transfer due to error"; $returnMessage[24] = "Partial transfer due to vanished source files"; $returnMessage[25] = "The --max-delete limit stopped deletions"; $returnMessage[30] = "Timeout in data send/receive"; $returnMessage[35] = "Timeout waiting for daemon connection"; $return = $returnMessage[$returnValue]; if ( ! $return ) { $return = "Unknown Error"; } return $return; } $shareList = @array_diff(@scandir("/boot/config/shares"),array(".","..")); if ( ! is_dir("/mnt/user") ) { echo "Array Must Be Started And User Shares Must Be Enabled To Utilize This Script. Exiting.\n"; return; } if ( ! is_dir("/mnt/cache") ) { echo "Cache Drive Not Installed. Exiting\n"; return; } if ( ! $shareList ) { $shareList = array(); } foreach ( $shareList as $shareCfg ) { $config = @parse_ini_file("/boot/config/shares/$shareCfg"); if ( ! $config ) { continue; } if ( $config['shareUseCache'] != "only" ) { continue; } $share = pathinfo($shareCfg,PATHINFO_FILENAME); if ( is_dir("/mnt/user0/$share") ) { echo "Share $share set to be cache-only, but files exist within array. Moving the files. Depending upon the size and number of files, this may take a bit\n"; $source = escapeshellarg("/mnt/user0/$share/"); $destination = escapeshellarg("/mnt/cache/$share"); $flag = true; exec("rsync -avXHq --remove-source-files $source $destination",$output,$returnValue); if ( $returnValue ) { echo "Errors Occurred: ".getRsyncReturnValue($returnValue)."\n"; $errors = true; } else { exec("rm -rf $source"); } } } if ( ! $flag ) { echo "All cache-only shares already only existed on the cache drive\n"; } else { if ( ! $errors ) { echo "All shares set to be cache-only have now had their files previously existing on the array to now be on the cache drive\n"; } else { echo "Errors Occurred In The Copying\n"; } } ?> Move Array Only Shares #!/usr/bin/php <?PHP function getRsyncReturnValue($returnValue) { $returnMessage[0] = "Success"; $returnMessage[1] = "Syntax or usage error"; $returnMessage[2] = "Protocol incompatibility"; $returnMessage[3] = "Errors selecting input/output files, dirs"; $returnMessage[4] = "Requested action not supported: an attempt was made to manipulate 64-bit files on a platform that cannot support them; or an option was specified that is supported by the client and not by the server."; $returnMessage[5] = "Error starting client-server protocol"; $returnMessage[6] = "Daemon unable to append to log-file"; $returnMessage[10] = "Error in socket I/O"; $returnMessage[11] = "Error in file I/O"; $returnMessage[12] = "Error in rsync protocol data stream"; $returnMessage[13] = "Errors with program diagnostics"; $returnMessage[14] = "Error in IPC code"; $returnMessage[20] = "Received SIGUSR1 or SIGINT"; $returnMessage[21] = "Some error returned by waitpid()"; $returnMessage[22] = "Error allocating core memory buffers"; $returnMessage[23] = "Partial transfer due to error"; $returnMessage[24] = "Partial transfer due to vanished source files"; $returnMessage[25] = "The --max-delete limit stopped deletions"; $returnMessage[30] = "Timeout in data send/receive"; $returnMessage[35] = "Timeout waiting for daemon connection"; $return = $returnMessage[$returnValue]; if ( ! $return ) { $return = "Unknown Error"; } return $return; } $shareList = @array_diff(@scandir("/boot/config/shares"),array(".","..")); if ( ! is_dir("/mnt/user") ) { echo "Array Must Be Started And User Shares Must Be Enabled To Utilize This Script. Exiting.\n"; return; } if ( ! is_dir("/mnt/cache") ) { echo "Cache Drive Not Installed. Exiting\n"; return; } if ( ! $shareList ) { $shareList = array(); } foreach ( $shareList as $shareCfg ) { $config = @parse_ini_file("/boot/config/shares/$shareCfg"); if ( ! $config ) { continue; } if ( $config['shareUseCache'] != "no" ) { continue; } $share = pathinfo($shareCfg,PATHINFO_FILENAME); if ( is_dir("/mnt/cache/$share") ) { echo "Share $share set to be array-only, but files exist on the cache drive. Moving the files. Depending upon the size and number of files, this may take a bit\n"; $source = escapeshellarg("/mnt/cache/$share/"); $destination = escapeshellarg("/mnt/user0/$share"); $flag = true; exec("rsync -avXHq --remove-source-files $source $destination",$output,$returnValue); if ( $returnValue ) { echo "Errors Occurred: ".getRsyncReturnValue($returnValue)."\n"; $errors = true; } else { exec("rm -rf $source"); } } } if ( ! $flag ) { echo "All cache-only shares already only existed on the cache drive\n"; } else { if ( ! $errors ) { echo "All shares set to be cache-only have now had their files previously existing on the array to now be on the cache drive\n"; } else { echo "Errors Occurred In The Copying\n"; } } ?> Move_Shares.zip
  2. This zip file contains the default user scripts included with the plugin, should you have deleted them from the flash drive and need to get them back delete.DS_Store Files #!/bin/bash echo "Searching for (and deleting) .DS_Store Files" echo "This may take a awhile" find /mnt/user -maxdepth 9999 -noleaf -type f -name ".DS_Store" -exec rm "{}" \; Delete Dangling docker Images #!/bin/bash docker rmi $(docker images --quiet --filter "dangling=true") echo Finished echo if an error shows above, no dangling images were found to delete View Docker Log Size du -ah /var/lib/docker/containers/ | grep -v "/$" | sort -rh | head -60 | grep .log User.Scripts_Included_Scripts.zip
  3. NOTE: I do not have time to keep the table of contents up to date, so there are going to be other scripts within this thread that are not listed here. Just a thread to contain any/all additional scripts created by users for use within the user.scripts plugin. I'm going to be using this thread for anything that pops into my head that may be of use but is either too simple for a plugin format, or just not worth the time for something that may only get run once. Ideal format to post any contributed scripts would be a zip file containing the script and description (stored within an already named folder for ease of adding to the plugin, and additionally a code block of the script itself for complete openness. See the user.scripts thread for details on how to add these scripts (or any others) Default Scripts Included in the plugin Fix Files Stored on the Array for cache-only shares and the reverse Clean Docker Logs Backup MySQL Folder Run mover at a certain utilization automatically Record Disk Assignments Enable / Disable Turbo Write Mode Auto set turbo mode based on drives spun up Run Mover At A Threshhold, optional to skip moving if parity check in progress Clear An unRaid Data Drive A script to have a file with the folders containing movies and tvshows. Send Server Status To Phone Backup vm xml files and ovmf nvram files Automatically download from repo and install custom VM icons to vm manager Run A Custom Script At Parity Check / Rebuild Start And Stop Catalog Drive Contents Move a folder when disk utilization exceeded Very simple script which will resume paused/suspended vms or start shut off vms Scheduled Scrubs Scheduled checks for Out Of Memory Errors Play PacMan On Your Server USB Hotplug for Virtual Machines with no passthrough and a revision HERE Enable / Disable Nested VM https://forums.unraid.net/topic/48707-additional-scripts-for-userscripts-plugin/?page=4#comment-547492 RemoveSpacesFromFile FolderfromFilename Automatically save syslog onto flash drive Check Plugin Integrity Allow unRaid to utilize the full width of the browser instead of limited to 1920px Get size of running containers Script to spin up all drives at certain times of day unRaid GUI Bleeding Edge Toolkit Enable Hardware Decoding In Plex Convert files from dos to linux format
  4. Good idea. I dunno much about these things but is it something about the semicolon and the php of CA? That would only be the case if it worked ok via command line though. It's not going to be CA. Sent from my LG-D852 using Tapatalk
  5. You guys would know better than I. All I ever do with the various plugins is communicate with dockerman Sent from my LG-D852 using Tapatalk
  6. 1 just post it. 2 yeah I guess in case of a install reinstall or an update through dockerMan the id can change. I'll bang together a script you can call with the name and it will return the id 3 anything scheduled to run here uses dynamix schedules. Scripts all run in the background and if there are multiple scheduled they will run concurrently Sent from my LG-D852 using Tapatalk
  7. Not the expert on docker exec but I think it's because you're running it in interactive mode -i and it recognizes there is no console input. Try removing that switch Sent from my LG-D852 using Tapatalk
  8. ok. Updated to support this. What I'm basically doing is if there is no user scripts defined on the flash drive, then at plugin install (or reboot) the sample scripts will get copied over to the flash drive. If there are already scripts on the flash drive, then no copying will take place. Net result is that you can delete / modify the included samples to your hearts content. Caveat however. If you are using (or want to) 1 or more of the sample scripts and already have user defined ones, you are going to lose access to the samples. Easiest solution is to rename the scripts folder on the flash drive to something else, uninstall and reinstall the plugin, then copy your user defined scripts back into the scripts folder. One time procedure.
  9. Only ever saw that once before. Try first deleting the container and image then readding it via CA previous apps (all will be the same as before) If that doesn't fix it delete the docker.ing file recreate it and add the apps back in. Can't remember which solution worked for me Sent from my LG-D852 using Tapatalk
  10. They will always run as root. I'm not an expert but I would think you could call the separate rsync script via sudo to change the user Sent from my LG-D852 using Tapatalk
  11. That's simple and easy (well, not right now it isn't, but by tomorrow it will be)
  12. Created (and updated) with every backup
  13. The permissions set are exactly the same as what the standard new perms tool sets. Full details are on the page for it (basically just a copy/paste from the standard newperms tool)
  14. At least someone here has 20-20 vision
  15. Can someone elaborate on the docker safe new permissions. I understand it's purpose, I need info on getting my server to utilize it. Is it a script file replacement or a checkbox/drop down option? I've been poking around and having trouble finding some info. Or a link to a thread about it would be great. Thanks. Sent from my iPhone using Tapatalk If you have the fix permissions plugin installed, it should appear under Tools, in the main unRAID webui. It explains what it does there In a nutshell it's the exact same script as the new perms but it won't touch your appdata (or CA appdata backup) share Sent from my LG-D852 using Tapatalk
  16. Sounds like your dns settings and or gateway is messed up in network settings Sent from my LG-D852 using Tapatalk
  17. Ah ok... Come to think of it I know someone just like that around here Were they also a bus driver? Haven't thought of the cat lover in a long time Sent from my LG-D852 using Tapatalk
  18. Ah ok... Come to think of it I know someone just like that around here
  19. google translate is your friend, my friend... I get the syslog behaves like a washerwoman (Must be some techno-babble that I'm not aware of) Yeah, I realised that after I posted. So what does washerwoman mean?
  20. google translate is your friend, my friend... I get the syslog behaves like a washerwoman (Must be some techno-babble that I'm not aware of)
  21. To make everything easier, post screen shots of the edit container screens for CP, headphones and sonarr (and wouldn't hurt to do the same for your dl client)
  22. Understanding mappings is a bitch to wrap your head around, and unfortunately like CHBMB (esq.) stated once you understand it, you'll understand it. This is probably the reason for what you stated about contradictory information in the docker FAQ. The "proper" way of doing it is what I advocated in the FAQ (and what CHBMB (CBE) et al are advocating here) The contradiction that you noticed is what JustinChase posted in the FAQ about a simpler way of doing it (eg: map /mnt to /mnt) so that how you reference something within the app is the exact same way you wind up referencing it within unRaid itself. Which direction you take is ultimately up to you, and CHBMB (BRCS) et al will adjust accordingly.
  23. Reinstall the app via CA's previous apps section. All of the mappings, ports, etc will all be the exact same as they were. Reinstalling via Available Apps will default the app so you will have to re-enter the mappings, ports, etc
×
×
  • Create New...