Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Plugin] CA User Scripts

Featured Replies

After disabling a script I received the following error:

 

Warning: syntax error, unexpected '(' in Unknown on line 11 in /usr/local/emhttp/plugins/user.scripts/helpers.php on line 42 

 

This is on 6.3-rc4.

 

 

  • Replies 2.1k
  • Views 567.5k
  • Created
  • Last Reply

Top Posters In This Topic

Most Popular Posts

  • I could make up something long, convoluted, and technical as a reason why it doesn't do that but it would all be bs.  The simple answer is that when I did this, I never thought of that, and why it sti

  • Hi All - We have a fix and are publishing a Connect plugin update to fix it today. Thanks for letting us know.

  • @Squid I tried many commands and by that I found out that pkill does not kill (all) child processes: root@Thoth:/tmp# pgrep -f isleep2m | xargs --no-run-if-empty ps fp PID TTY STAT T

Posted Images

  • Author

After disabling a script I received the following error:

 

Warning: syntax error, unexpected '(' in Unknown on line 11 in /usr/local/emhttp/plugins/user.scripts/helpers.php on line 42 

 

This is on 6.3-rc4.

That showed up in the UI?  Can you show me the line that you're adding to the script

 

This occurred when I disabled Danioj's  Autovmbackup script.  It had been working fine when enabled to run weekly using the Dynamix Schedules plugin.

  • Author

This occurred when I disabled Danioj's  Autovmbackup script.  It had been working fine when enabled to run weekly using the Dynamix Schedules plugin.

Check for updates.  (It was danioj's copyright message messing it up - tightened up the parsing on looking for my own variables within the comments)

Updated, thanks.

  • 2 weeks later...

I wonder if a brilliant guy here can do a simple script that does this :

 

1. Check WAN IP, if it changes from the hour before, run the following command :

2. Restart the ProFTPd plugin

 

I know it's strange, but I found out that even if i'm using a domain name that point to my dynamic IP (and update when it change), the ProFTPd service doesn't work with TLS encryption if it is not restarted on a IP change.

  • Author

I wonder if a brilliant guy here can do a simple script that does this :

 

1. Check WAN IP, if it changes from the hour before, run the following command :

2. Restart the ProFTPd plugin

 

I know it's strange, but I found out that even if i'm using a domain name that point to my dynamic IP (and update when it change), the ProFTPd service doesn't work with TLS encryption if it is not restarted on a IP change.

Everything but the actual command to restart ProFTPd.  (add the command where indicated)

#!/usr/bin/php
<?PHP
#description=Script to restart a service / bash command when the WAN IP changes
function download_url($url, $path = "", $bg = false){
  exec("curl --compressed --max-time 60 --silent --insecure --location --fail ".($path ? " -o '$path' " : "")." $url ".($bg ? ">/dev/null 2>&1 &" : "2>/dev/null"), $out, $exit_code );
  return ($exit_code === 0 ) ? implode("\n", $out) : false;
}

@unlink("/tmp/scriptNewIP");
download_url("http://ipecho.net/plain","/tmp/scriptNewIP");

$newIP=@file_get_contents("/tmp/scriptNewIP");
if ( ! $newIP ) {
  echo "failed to determine new IP\n";
  exit(0);
}
if ( is_file("/tmp/scriptOldIP") ) {
  $oldIP = @file_get_contents("/tmp/scriptOldIP");
  if ( $oldIP != $newIP ) {
    echo("WAN IP changed.  Restarting services\n");
# change within the quotes to whatever you need    
    exec("put the bash command here within the quotes");
  } else {
    echo "WAN IP has not changed\n";
  }
}
file_put_contents("/tmp/scriptOldIP",$newIP);
?>

Did I find an typo ?

 

Line 43 helpers.php

 

      $iniString .= $testString;

  • Author

Did I find an typo ?

 

Line 43 helpers.php

 

      $iniString .= $testString;

nope

Did I find an typo ?

 

Line 43 helpers.php

 

      $iniString .= $testString;

nope

 

Squid:

 

Just wondering what does the period do or mean?

 

Thanks Reed

 

Edit I found what it means brain fart!!!

I was looking at the Mover code at a specific threshold script, however I was trying to figure out how to move oldest folder from a Disk to another Disk at a specific threshold. I normally move the oldest folder from a specific folder simply to reduce Disk spin ups across my array. Has anybody ever worked on something like that or could you throw me a bone on how to modify what somebody else has already done into something of the sort that I have slapped together?

 

My reasoning is I move "All" my files from my windows machine to:

Disk3 then to Disk5 for archiving

Disk2 then to Disk4 for archiving

 

Here is what my Slapped together code that works if I manually run it, but I'd like to incorporate Threshold into it:

 

#!/bin/sh
OLD="disk3"
NEW="disk5"

MoveSearch="`ls -t /mnt/$OLD/Movies/All/ | tail -n 1`"

echo moving $MoveSearch
mv /mnt/$OLD/Movies/All/$MoveSearch /mnt/$NEW/Movies/All/
echo $MoveSearch move complete

/usr/local/emhttp/plugins/dynamix/scripts/notify -e "Recovering Space" -d "Moving $MoveSearch from $OLD to $NEW" -i "normal" -m "Moved $MoveSearch from $OLD to $NEW"

 

The OLD and NEW Variable isn't required, but I just decided a while back it was easier for me to just drop it in so I could wash, rinse and repeat without digging in the code often when I wanted to run on multiple disks and reduce the error factor. Maybe someday I'll get fancy with it, but figured if I had a threshold script I could just let it run often and not worry about it.

 

I attempted for simplicity sake to just make a call from the mover script to what I've done, but apparently I messed things up and it just doesn't work. I deleted what I did a while back and just remembered recently and figured why not just ask here.

  • Author

I was looking at the Mover code at a specific threshold script, however I was trying to figure out how to move oldest folder from a Disk to another Disk at a specific threshold. I normally move the oldest folder from a specific folder simply to reduce Disk spin ups across my array. Has anybody ever worked on something like that or could you throw me a bone on how to modify what somebody else has already done into something of the sort that I have slapped together?

 

My reasoning is I move "All" my files from my windows machine to:

Disk3 then to Disk5 for archiving

Disk2 then to Disk4 for archiving

 

Here is what my Slapped together code that works if I manually run it, but I'd like to incorporate Threshold into it:

 

#!/bin/sh
OLD="disk3"
NEW="disk5"

MoveSearch="`ls -t /mnt/$OLD/Movies/All/ | tail -n 1`"

echo moving $MoveSearch
mv /mnt/$OLD/Movies/All/$MoveSearch /mnt/$NEW/Movies/All/
echo $MoveSearch move complete

/usr/local/emhttp/plugins/dynamix/scripts/notify -e "Recovering Space" -d "Moving $MoveSearch from $OLD to $NEW" -i "normal" -m "Moved $MoveSearch from $OLD to $NEW"

 

The OLD and NEW Variable isn't required, but I just decided a while back it was easier for me to just drop it in so I could wash, rinse and repeat without digging in the code often when I wanted to run on multiple disks and reduce the error factor. Maybe someday I'll get fancy with it, but figured if I had a threshold script I could just let it run often and not worry about it.

 

I attempted for simplicity sake to just make a call from the mover script to what I've done, but apparently I messed things up and it just doesn't work. I deleted what I did a while back and just remembered recently and figured why not just ask here.

Since I can't stand bash, and have to look up everytime how to do math, variables, etc. what I'm going to suggest is use my threshhold mover script and simply change the two lines that state

exec("/usr/local/sbin/mover");

and change it to

exec("/boot/KizerScript/myMove.sh");

 

and change your echo commands to logger instead

 

where /boot/KizerScript/myMove.sh is your script location.

 

Or, alternatively if I think about it in the next week or so I'll pump together a script to move from a source to a destination if the free space on a share is less than X, and to move the files from eldest to newest

I'm up for anything. Lol

I'd like to keep it simple and effective and if everybody gets a benefit from it even better. ;)

 

I just slap things together and pray they work. Often the results are somewhat questionable, but things seem to get done. lol

 

As for the nofications they aren't really required just something I was tinkering with at the time.

  • 2 weeks later...

Is this similar to the dynamix cron where we just put the script we want to run in the config/plugins folder? Is there any sample on how to execute the script after array starts/mounts?

  • Author

Is this similar to the dynamix cron where we just put the script we want to run in the config/plugins folder? Is there any sample on how to execute the script after array starts/mounts?

Sample scripts come with the plugin.  Only thing is that at the moment scripts must be named "script" in their own folder.  But it'll take any script using any interpreter you choose.  To run it on array start, just set the schedule to be on array start

Is this similar to the dynamix cron where we just put the script we want to run in the config/plugins folder? Is there any sample on how to execute the script after array starts/mounts?

Sample scripts come with the plugin.  Only thing is that at the moment scripts must be named "script" in their own folder.  But it'll take any script using any interpreter you choose.  To run it on array start, just set the schedule to be on array start

Thanks I got it to work. I didn't see any sample scripts in the folder by default but that's okay. However my echos are not showing up in the console, is it because it runs > /dev/null 2>&1? If so, how do I change it?

  • 2 weeks later...

Would it be possible to set a custom cron schedule. I want to run a script every 5 minutes rather than every 1 hour (which seems to be the lowest frequency at the moment).

Would it be possible to set a custom cron schedule. I want to run a script every 5 minutes rather than every 1 hour (which seems to be the lowest frequency at the moment).

See this thread starting here for example.
  • Author

Would it be possible to set a custom cron schedule. I want to run a script every 5 minutes rather than every 1 hour (which seems to be the lowest frequency at the moment).

It's on the to do list.  When I did this originally, I was very surprised at the reception the plugin got, so certain design considerations I made at the time makes it a PITA to implement that.  I just gotta find some time.

See this thread starting here for example.

 

It's on the to do list.  When I did this originally, I was very surprised at the reception the plugin got, so certain design considerations I made at the time makes it a PITA to implement that.  I just gotta find some time.

 

Okay cool - i appreciate your work. I can live with 1 hour for now. I'll wait patiently for the support of custom schedules :)

  • Author

I'll wait patiently for the support of custom schedules :)

Testing the code tonight.  So release is tonight / tomorrow.  But it's a raw cron entry.  No dropdowns, etc when set to custom so you have the utmost flexibility.
  • Author

fresh_sweet_cron2.jpg

 

- Ability to set schedules to any arbitrary custom cron schedule.  If you don't know what cron is, see here:  https://en.wikipedia.org/wiki/Cron

 

You can enter in any cron expression for the utmost in flexibility.  Only enter in the expression.  The command to run will automatically be added.  As usual, the same flexibility in scripts apply.  Namely, any interpreter is allowed.  If no interpreter is specified, /bin/bash is assumed, EOL can be either Linux or Windows style.

Testing the code tonight.  So release is tonight / tomorrow.  But it's a raw cron entry.  No dropdowns, etc when set to custom so you have the utmost flexibility.

 

flexibility > user-friendliness

 

 

- Ability to set schedules to any arbitrary custom cron schedule.  If you don't know what cron is, see here:  https://en.wikipedia.org/wiki/Cron

 

You can enter in any cron expression for the utmost in flexibility.  Only enter in the expression.  The command to run will automatically be added.  As usual, the same flexibility in scripts apply.  Namely, any interpreter is allowed.  If no interpreter is specified, /bin/bash is assumed, EOL can be either Linux or Windows style.

 

Crisp 8)! That was quick! Already changed my first job to run every 5 minutes  :)

cron.jpg.89effb163baaccf73cb048d6a3965463.jpg

  • Author

Testing the code tonight.  So release is tonight / tomorrow.  But it's a raw cron entry.  No dropdowns, etc when set to custom so you have the utmost flexibility.

 

flexibility > user-friendliness

 

Damn near impossible to create a GUI that could possibly encompass all of the options that cron has.

I think the only thing I would ask for or suggest is a little popup or maybe something that can be explained when you click the help button that more or less says. "This is how you setup a basic custom Cron with maybe a few examples" I clicked on Custom and my Brain went into... Uh, How do I do this again. Lol

 

Yes I know Google is your friend, but just a minor suggestion and we all like being spoiled by you. ;)

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...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.