[Plugin] CA User Scripts


Recommended Posts

When I enable this plugin the time between the unraid displays the console login and the autostart of VM is increased to 60+ seconds. Without this plugin it's around 5 seconds.

Is there anything that I should/can do to make this plugin "faster" to load?

 

Thanks

 

LE: I'm on 6.4.0, if it matters...

Edited by thomas
added unraid version
Link to comment
43 minutes ago, thomas said:

When I enable this plugin the time between the unraid displays the console login and the autostart of VM is increased to 60+ seconds. Without this plugin it's around 5 seconds.

Is there anything that I should/can do to make this plugin "faster" to load?

 

Thanks

 

LE: I'm on 6.4.0, if it matters...

Hope this question isn't too obvious. Do you have a script executing on startup?

Link to comment

I checked and I had one script being executed at startup of the array, I disabled it and now it's working properly.

The script was finding and deleting some temp files on the array, but my VMs are located on the cache drive (SSD) so I thought they won't be impacted by this...

 

If you have any scripts running at startup, the VMs will wait until the scripts are finished in order to load, or they are competing for resources (cpu,ram) and eventually will load?

 

Thanks

Link to comment
On 3/18/2017 at 11:11 AM, Squid said:

Any user who is capable enough to want to run a particular script at actual startup would also be capable enough to edit the go file themselves.

 

@Squid

 

I did a search trying to find any notes about the schedule options, most of them are clear. The only one that I do not understand is the one called "At First Array Start Only". Can you clarify that one for me? To me it would seem to run the script at the first array start after a server reboot/startup.

 

Also found the quoted statement above during my search and it may help answer my question. 

 

Thanks,

StanC

Link to comment
39 minutes ago, StanC said:

To me it would seem to run the script at the first array start after a server reboot/startup

correct

 

40 minutes ago, StanC said:

Also found the quoted statement above during my search and it may help answer my questio

To run a script before the array is started, (ie: very early in the boot up sequence), you manually edit the "go" file /boot/config/go and add your own script / commands in there.  Doing that via the plugin is not something I'm interested in doing / supporting

Link to comment
6 minutes ago, Squid said:

To run a script before the array is started, (ie: very early in the boot up sequence), you manually edit the "go" file /boot/config/go and add your own script / commands in there.  Doing that via the plugin is not something I'm interested in doing / supporting

 Thanks for the clarification. Just wanted to check on that, since ljm42 made a statement in the 6.4.0 Release Note thread 

about moving any customizations from the go file to User Script Plugin, so I thought I would check.

Link to comment

hello :)
everytime I try to run a script made with this plugin at a sheduled time, I get this error in systemLog

crond[1620]: failed parsing crontab for user root: SAT /usr/local/emhttp/plugins/user.scripts/startCustom.php /boot/config/plugins/user.scripts/scripts/BackupFelles/script > /dev/null 2>&1

If I run the backup script manually, it works just fine.

Link to comment
29 minutes ago, isvein said:

hello :)
everytime I try to run a script made with this plugin at a sheduled time, I get this error in systemLog


crond[1620]: failed parsing crontab for user root: SAT /usr/local/emhttp/plugins/user.scripts/startCustom.php /boot/config/plugins/user.scripts/scripts/BackupFelles/script > /dev/null 2>&1

If I run the backup script manually, it works just fine.

What is the SAT?  Cron entries tend to be purely numeric, and IIRC Slackware doesn't support day names.  Rather you'd be using 6

Link to comment
  • 2 weeks later...

I have a script set to run at parity start/stop. It fails since updating to 6.4 with this error-

Warning: parse_ini_file(var/local/emhttp/var.ini): failed to open stream: No such file or directory in /boot/scripts/docker_start_stop_parity/parity_test.php on line 24

Warning: parse_ini_file(var/local/emhttp/var.ini): failed to open stream: No such file or directory in /boot/scripts/docker_start_stop_parity/parity_test.php on line 24

Warning: parse_ini_file(var/local/emhttp/var.ini): failed to open stream: No such file or directory in /boot/scripts/docker_start_stop_parity/parity_test.php on line 24

Looks like var/local/emhttp/var.ini no longer exists if I'm reading this right. Is there something I can modify to get this working?

 

Link to comment
4 minutes ago, wgstarks said:

I have a script set to run at parity start/stop. It fails since updating to 6.4 with this error-


Warning: parse_ini_file(var/local/emhttp/var.ini): failed to open stream: No such file or directory in /boot/scripts/docker_start_stop_parity/parity_test.php on line 24

Warning: parse_ini_file(var/local/emhttp/var.ini): failed to open stream: No such file or directory in /boot/scripts/docker_start_stop_parity/parity_test.php on line 24

Warning: parse_ini_file(var/local/emhttp/var.ini): failed to open stream: No such file or directory in /boot/scripts/docker_start_stop_parity/parity_test.php on line 24

Looks like var/local/emhttp/var.ini no longer exists if I'm reading this right. Is there something I can modify to get this working?

 

You're missing the first forward slash in the script.  It should be /var/local/emhttp/var.ini

Edited by Squid
Link to comment
  • 2 weeks later...

Hi wonderful people! (I'm very happy as I thought my server was gone and this awesome forum helped me and it's up and working like a charm :D )

 

May I ask for help with the "delete.ds_store" script?

I have a share dedicated to Time Machine backups and I would love to have the opportunity to run this script on all my shares BUT the Time Machine one as I don't want to touch that one. I'm not an expert so I don't know exactly how I could edit the script to avoid it. Can maybe somebody here help me and others with the same setup?

Link to comment
17 minutes ago, almarma said:

Hi wonderful people! (I'm very happy as I thought my server was gone and this awesome forum helped me and it's up and working like a charm :D )

 

May I ask for help with the "delete.ds_store" script?

I have a share dedicated to Time Machine backups and I would love to have the opportunity to run this script on all my shares BUT the Time Machine one as I don't want to touch that one. I'm not an expert so I don't know exactly how I could edit the script to avoid it. Can maybe somebody here help me and others with the same setup?

You can modify the path in the script to point to a specific share.

Example:

replace

/mnt/user

 

with this

/mnt/user/media

 

This would scan your “media” share.

 

This way you can just scan the shares that you want to.

Link to comment
3 minutes ago, wgstarks said:

You can modify the path in the script to point to a specific share.

Oh! That sounds very interesting! Just to be sure I don't mess up things. Lets say I want to apply it in two shares, one called MEDIA and another called WORK.

This is the default content:

#!/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 "{}" \;

Can I have two lines like so?

#!/bin/bash
echo "Searching for (and deleting) .DS_Store Files"
echo "This may take a awhile"
find /mnt/user/MEDIA -maxdepth 9999 -noleaf -type f -name ".DS_Store" -exec rm "{}" \;
find /mnt/user/WORK -maxdepth 9999 -noleaf -type f -name ".DS_Store" -exec rm "{}" \;

Do the final ; symbol should be used for each line or only for the end of the script?

 

Thank you for your help :)

Link to comment
14 minutes ago, almarma said:

Oh! That sounds very interesting! Just to be sure I don't mess up things. Lets say I want to apply it in two shares, one called MEDIA and another called WORK.

This is the default content:


#!/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 "{}" \;

Can I have two lines like so?


#!/bin/bash
echo "Searching for (and deleting) .DS_Store Files"
echo "This may take a awhile"
find /mnt/user/MEDIA -maxdepth 9999 -noleaf -type f -name ".DS_Store" -exec rm "{}" \;
find /mnt/user/WORK -maxdepth 9999 -noleaf -type f -name ".DS_Store" -exec rm "{}" \;

Do the final ; symbol should be used for each line or only for the end of the script?

 

Thank you for your help :)

I am not much of a coder but I think that will work. Perhaps someone much more knowledgeable ( @Squid) could confirm that.

Link to comment
  • 3 weeks later...

Can someone help me get an rsync user script working?  I followed the below process for setting up ssh keys between two unRAID servers so that I can rsync between them without having to enter a password (ie. in a script).  But even after doing this, it still prompts for a password when running rsync.

 

What am I missing?

 

 

1. Test rsync over ssh (with password):

Do a rsync to make sure it asks for the password for your account on the remote server, and successfully copies the files to the remote server.

The following example will synchronize the local folder /home/test to the remote folder /backup/test (on 192.168.200.10 server).

This should ask you for the password of your account on the remote server.

rsync -avz -e ssh /home/test/ [email protected]:/backup/test/

2. ssh-keygen generates keys.

Now setup ssh so that it doesn’t ask for password when you perform ssh. Use ssh-keygen on local server to generate public and private keys.

$ ssh-keygen

Enter passphrase (empty for no passphrase):

Enter same passphrase again: Note: When it asks you to enter the passphrase just press enter key, and do not give any password here.

3. ssh-copy-id copies public key to remote host

Use ssh-copy-id, to copy the public key to the remote host.

ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.200.10

Note: The above will ask the password for your account on the remote host, and copy the public key automatically to the appropriate location. If ssh-copy-id doesn’t work for you, use the method we discussed earlier to setup ssh password less login.

4. Perform rsync over ssh without password

Now, you should be able to ssh to remote host without entering the password.

ssh 192.168.200.10

Perform the rsync again, it should not ask you to enter any password this time.

rsync -avz -e ssh /home/test/ [email protected]:/backup/test/
Link to comment

Hello all! Would anyone be able to cast their eyes over a couple of scripts I have ‘adapted’ for my download setup?

 

The first one I don’t think there is a problem with, it should move Handbrake converted files from one directory to another where a media manager can pick them up:

 

Quote

#!/bin/bash

 

if [ -f /var/run/mymover.pid ]; then

 if ps h `cat /var/run/mymover.pid` | grep mymover.sh ; then

   echo "mymover already running, sorry."

   exit 0

 fi

fi

 

echo $$ >/var/run/mymover.pid

 

echo "Moving files from $1 to $2"

(cd "/mnt/user/downloads/Complete/"; find -depth -print \( ! -exec fuser -s '{}' \; -exec rsync -i -qdIWRpEAXogt --numeric-ids --inplace --remove-source-files {} "/mnt/user/downloads/Import/" \; \))

 

# Prune empty directories from source dir

find "/mnt/user/downloads/Complete/" -type d -empty -prune -exec rmdir --ignore-fail-on-non-empty {} \;

 

# Prune empty directories from destination dir

find "/mnt/user/downloads/Import/" -type d -empty -prune -exec rmdir --ignore-fail-on-non-empty {} \;

 

sync

 

rm /var/run/mymover.pid

 

echo "Moving all done."

 

The next one, is supposed to delete the original files after they have been copied.

 

 The last time I tried it, it looked like it was removing files from all directories which was not the desired effect.

 

Quote

#!/bin/bash

 

find /mnt/user/downloads/Import -atime +1 -type f -exec ls -l {} \;

 

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.