Additional Scripts For User.Scripts Plugin


Recommended Posts

On 12/07/2017 at 5:19 PM, Squid said:

CHBMB suggested the same thing a while ago, and I basically blew him off.

 

Firstly I'd like to ask you to rephrase that slightly and secondly I'd like to gloat that I told you it was a good idea.  But I do understand that it is a lot of work and can completely understand not wanting to take it on in addition to everything else you do....

Link to comment
  • 4 weeks later...

Automatically save syslog onto flash drive

 

Set the script to run at First Only Array Start in the background

#!/bin/bash
mkdir -p /boot/logs
FILENAME="/boot/logs/syslog-$(date +%s)"
tail -f /var/log/syslog > $FILENAME

 

Edited by Squid
Link to comment

Delete Dangling Images

 

I'm having issues with this script. When I run it, It gives me the following error

"docker rmi" requires at least 1 argument(s).
See 'docker rmi --help'.

Usage: docker rmi [OPTIONS] IMAGE [IMAGE...]

 

Edited by jrdnlc
Link to comment
6 hours ago, jrdnlc said:

Delete Dangling Images

 

I'm having issues with this script. When I run it, It gives me the following error


"docker rmi" requires at least 1 argument(s).
See 'docker rmi --help'.

Usage: docker rmi [OPTIONS] IMAGE [IMAGE...]

 

Then there's no dangling images present

Link to comment
  • 4 weeks later...
3 hours ago, johnieutah said:

This clear array script... I started it running in the foreground in my browser and it seems it will take ages...

So what happens when I close my browser or it hangs or something?!?

... and how long should this take as it seems to be going slooooooooooooooooowly... @ 2.8MB/sec for 750GB drive.

 

Thanks.

General rule is that anything running in the foreground will stop once you close the pop up.  A lot of factors though at play.

Link to comment

So the browser did hang in the end and I ended up killing the server (it took 2 goes) as I didn't like the idea of this process going on for a week anyway.

Now I started the server I get an unmountable disk error. Not a problem, I just need the easiest and quickest way to remove this device from the array... and the clear drive process was certainly not the quickest..

Ideas guys?

2017-09-03 18_05_34-Microsoft Edge.png

Link to comment
30 minutes ago, johnieutah said:

So the browser did hang in the end and I ended up killing the server (it took 2 goes) as I didn't like the idea of this process going on for a week anyway.

Now I started the server I get an unmountable disk error. Not a problem, I just need the easiest and quickest way to remove this device from the array... and the clear drive process was certainly not the quickest..

Ideas guys?

2017-09-03 18_05_34-Microsoft Edge.png

There isn't really a quick way. You either have to zero the disk while it is still part of the array so parity can be kept in sync, or you have to New Config without the disk and rebuild parity.

Link to comment
7 hours ago, johnieutah said:

Thanks for the reply. Will the second option work even though unraid says the drive can't be mounted?

So the steps would be:

Stop array

Set drive to unassigned

Turn off

Remove drive

Start server

Rebuild parity

 

 

 

No. If by the second option you mean:

On 9/3/2017 at 0:41 PM, trurl said:

you have to New Config without the disk and rebuild parity.

 

That is done by going to Tools - New Config. There you will be able to keep/change any drive assignments. After New Config, the default is to rebuild parity. So you would NOT check the box saying parity is valid.

Link to comment
3 hours ago, trurl said:

 

No. If by the second option you mean:

 

That is done by going to Tools - New Config. There you will be able to keep/change any drive assignments. After New Config, the default is to rebuild parity. So you would NOT check the box saying parity is valid.

Ok, so I can start a new config, keep the drive assignments that I want (make note of device ids), rebuild parity, let that finish, then I can remove the drive safely after a shutdown? 

Just want to be 100%, thanks.

Edited by johnieutah
Link to comment

When you go to New Config, you will have several options about what assignments to retain. I recommend choosing Retain All. Then you will have everything already assigned just as it is, and you can make changes from that as a starting point. Then after you have everything assigned like you want, start the array and let it build parity.

Link to comment
1 hour ago, ogi said:

I just ran this script, while completed without issue, when I have gone to stop the array, the array is taking a long time to sync filesystems... is this normal (I'm currently passing 20 minutes)? 

After a little over an hour of sync-ing, I powered the machine off, let it come up, it's doing a parity check now, but the disk I was running this before is labeled as unmountable, so as soon as the parity check completes, I'll resume the shrink array procedure from step 9.

 

https://wiki.lime-technology.com/Shrink_array

Link to comment

I'm not sure if it's a seperate issue I'm having, but while removing a second disk, I'm having problems with 'syncing disks'.  I attempted to restart a docker container (Plex Media Server) while the clear-disk script was running.  The container won't stop, it appears to be stuck on [s6-finish] syncing disks ... I've been trying to kill the container with no luck.

 

Current plan is to let the clear disk script finish on the current disk, then force a shut-down/restart (will likely have to manually umount all my disks).

 

Anyway I don't think this issue is directly due to the script so much as the suggested setting md_write_method to reconstruct write (from auto or read/modify/write).  Given that that setting is suggested, I'm going to try running through this script next time around w/ read/modify/write setting instead (full well knowing it will take longer), and see if I have sync filesystem or sync disks issues then.

Link to comment

It is quite normal to have issues stopping anything that requires a disk sync if you have a pre-clear running in parallel.   The pre-clear keeps writing new data so that the sync never completes.   Another symptom that is common in this scenario is being unable to stop the array for the same reason.    The only solution is to either wait for the pre-clear to finish or to terminate it early.     In a perfect world it would be possible to pause a pre-clear and later resume it, but I can understand that this would add a very large level of complexity to the plugin and hitting this issue on a running system is rare enough that it  almost certainly does not justify the effort that would be required.

Link to comment
On 9/5/2017 at 7:55 PM, trurl said:

When you go to New Config, you will have several options about what assignments to retain. I recommend choosing Retain All. Then you will have everything already assigned just as it is, and you can make changes from that as a starting point. Then after you have everything assigned like you want, start the array and let it build parity.

Thanks for the advice. I ended up going down this route, and the parity rebuild took 10hours or so. Ok, the array is not parity protected, but the other (newer) method seemed like it would go on for at least a week... An easy decision to make IMO.

Link to comment
  • 3 weeks later...
On 10/29/2016 at 0:56 PM, Squid said:

Run A Custom Script At Parity Check / Rebuild Start And Stop

Use it to run a custom script to (as an example), shut down various docker applications, etc.  Adjust the variables within the script file.

 

Note that you either need to run this in the background or at array start.  Running this in the foreground will not work.

 

 


#!/usr/bin/php
<?PHP
# A simple script to allow you to run a custom script when a parity check starts or stops
# Adjust the following variables to suit:

$checkInterval = 300;                             # Number of seconds in between checks
$startScript   = "full path to the script";       # The full path to the script to run when a parity check starts
$stopScript    = "full path to the stop script";  # The full path to the script to run when a parity check stops

# Don't touch anything below

while (true) {
  $vars = parse_ini_file("/var/local/emhttp/var.ini");
  if ( $vars['mdState'] == "STOPPED" ) {
    break;
  }
  if ( ($vars['mdResyncPos'] != 0) && $vars ) {
    echo "Parity Check / Sync / Rebuild in progress.  Executing the start script ($startScript)";
    exec($startScript,$output);
    foreach ($output as $line) {
      echo $line."\n";
    }
    while (true) {
      $vars = parse_ini_file("var/local/emhttp/var.ini");
      if ( ($vars['mdResyncPos'] == 0) && $vars ) {
        echo "Parity Check / Sync / Rebuild finished.  Executing the stop script ($stopScript)";
        exec($stopScript,$output);
        foreach ($output as $line) {
          echo $line."\n";
        }
        break;
      } else {
        sleep($checkInterval);
      }
    }
  } else { 
    sleep($checkInterval);
  }  
}
?>
 

 

custom_script_parity_check_start_stop.zip

I would like to use this to pause several torrent dockers during parity checks using "docker pause <dockername>". Is there anyway to have the commands run in a set order?

Edited by wgstarks
Link to comment

The commands would be

docker pause binhex-sonarr

followed by

docker pause binhex-radarr

followed by

docker pause binhex-delugevpn

and then the reverse on parity completion. I guess I need to figure out how to script these commands though. Want to do something like CA Docker auto start except at parity start and finish.

 

Link to comment
8 hours ago, wgstarks said:

The commands would be

 


docker pause binhex-sonarr

 

followed by

 


docker pause binhex-radarr

 

followed by

 


docker pause binhex-delugevpn

 

and then the reverse on parity completion. I guess I need to figure out how to script these commands though. Want to do something like CA Docker auto start except at parity start and finish.

 

#!/bin/bash
docker pause binhex-sonarr
docker pause binhex-radarr
docker pause binhex-delugevpn

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.