User scripts question


Recommended Posts

HI,

 

is there a way to invoke an userscript automatically after the server goes to runlevel 3 ?

all commands in the "go Script" are runlevel 2 (i guess) non multiuser level

 

also a userscript just holds commands as in the terminal ?

thinking of making one to start sabnzbd / couchpotato and sickbeard as user nobody

all 3 programs have shutdown buttons in the gui so i doubt if it is usefull to make a stop script ?

 

I got it to run from terminal but would like it to boot automatically :)

 

 

 

Link to comment

Nobody  ???

 

ok will this work ?

 

#701-unmenu_user_script_Start_Sabnzbd
#define USER_SCRIPT_LABEL Start SABNZBD as Nobody
#define USER_SCRIPT_DESCR start Sabnzbd as user Nobody
#move to nobody
su nobody

#Sabnzbd startup
python /mnt/cache/.custom/sabnzbd/SABnzbd-0.5.6/SABnzbd.py -d -f /boot/config/SABnzbd.ini -s 192.168.1.130:9080 
exit

if i save this as 701-unmenu_user_script_Start_Sabnzbd.cgi and put it in the userscripts folder

it will not go automatically .. but at least there will be a button in userscripts i guess to start the thing ?

 

or am i misunderstanding the capabilities of the userscripts ?

Link to comment

Nobody  ???

 

ok will this work ?

 

#701-unmenu_user_script_Start_Sabnzbd
#define USER_SCRIPT_LABEL Start SABNZBD as Nobody
#define USER_SCRIPT_DESCR start Sabnzbd as user Nobody
#move to nobody
su nobody

#Sabnzbd startup
python /mnt/cache/.custom/sabnzbd/SABnzbd-0.5.6/SABnzbd.py -d -f /boot/config/SABnzbd.ini -s 192.168.1.130:9080 
exit

if i save this as 701-unmenu_user_script_Start_Sabnzbd.cgi and put it in the userscripts folder

it will not go automatically .. but at least there will be a button in userscripts i guess to start the thing ?

 

or am i misunderstanding the capabilities of the userscripts ?

That is how to create a button.  It will not press the button automatically.

 

You'll also want to add another button to kill the process, since it will keep the "cache" drive busy, and you'll not be able to stop the unRAID array until it is killed.

 

Joe L.

Link to comment

Thanks Joe for confirming ...

 

as i stated before it will not go automatically and i understand that :)

 

if i save this as 701-unmenu_user_script_Start_Sabnzbd.cgi and put it in the userscripts folder

[glow=red,2,300]it will not go automatically[/glow] .. but at least there will be a button in userscripts i guess to start the thing ?

 

but seems everybody is reluctant here to get around to do it automatically ...  i have been looking around to see if this is a bad subject or so... going around the one user level .. and i saw some mentioning from Tom in the road map of fixing a bug to not use a multiuser environment for logging into the OS ...  but i assume i am not breaking here any unwritten rules ?

 

If i am please let me know and i stop...

 

with Brit's start stop scripts i think there is a way around it ... but it requires a start-stop daemon script that i couldn't find yet for slack ...

and i guess i will need to learn how to make packages then to set this up ...

 

anyway i will make start / stop buttons for SABNZBD / Couchpotato and Sickbeard .. although you can stop them from their webpage ... and i will probably invoke that command to stop them ... it will let them shut down nicely and not "break" anything

Link to comment

Thanks Joe for confirming ...

 

as i stated before it will not go automatically and i understand that :)

 

if i save this as 701-unmenu_user_script_Start_Sabnzbd.cgi and put it in the userscripts folder

[glow=red,2,300]it will not go automatically[/glow] .. but at least there will be a button in userscripts i guess to start the thing ?

 

but seems everybody is reluctant here to get around to do it automatically ...  i have been looking around to see if this is a bad subject or so... going around the one user level .. and i saw some mentioning from Tom in the road map of fixing a bug to not use a multiuser environment for logging into the OS ...  but i assume i am not breaking here any unwritten rules ?

 

If i am please let me know and i stop...

 

with Brit's start stop scripts i think there is a way around it ... but it requires a start-stop daemon script that i couldn't find yet for slack ...

and i guess i will need to learn how to make packages then to set this up ...

 

anyway i will make start / stop buttons for SABNZBD / Couchpotato and Sickbeard .. although you can stop them from their webpage ... and i will probably invoke that command to stop them ... it will let them shut down nicely and not "break" anything

Version 5.X of unRAID will have events we can use to trigger start/stop scripts.    They exist in their very basic form in the 5.0beta2 release, but we are still working out the details/conventions of how to use them.

 

I have been using for about 8 months now a script to both automatically start add-on processes AFTER the array is online, and to automatically stop them BEFORE the array is stopped.

 

It was described in, and attached to this post: http://lime-technology.com/forum/index.php?topic=5686.0

 

I use it to start and stop two processes on my servers.  It works perfectly.  It monitors the tail end of the syslog to learn when unRAID is attempting to stop the array and then terminates the add-ons as defined in /etc/rc.d/unraid.d

 

It is the way I developed before any add-on events existed.  It may help you until 5.0 matures a bit more and a convention for add-on START/STOP scripts can be coded based on the 5.0 event handling.

 

The discussion regarding 5.X event handling is here, if you want to read all about it: http://lime-technology.com/forum/index.php?topic=7101.0

 

Joe L.

Link to comment

Sacredagent, please post the code for the shutdown buttons as well if you end up implementing them.  I would like this myself but haven't made time to do it yet and won't bother if you already have them finished.  I normally use the shutown buttons on the sab/sickbeard/couchpotatoh webpages directly but occasionally I am having a problem with them and the web pages won't render properly to allow me to shut them down, buttons in my userscripts would be really convenient as I could just hit stop on transmission/sab/sickbeard/couchpotato all at once before shutting down my array.

 

Even better at some point I will figure out how to make the array stop button call those scripts automatically so I don't need to when I just want to stop the array but even once that is done there will be times that I will want to stop or start those services without stopping the array. 

Link to comment

hi

 

this is an example of the startup button that works

 

#701-unmenu_user_script_Start_Sabnzbd
#define USER_SCRIPT_LABEL Start SABNZBD as Nobody
#define USER_SCRIPT_DESCR start Sabnzbd as user Nobody
#move to nobody and start SABNZBD
su nobody -c "python /path/to/where/you/have/SABnzbd.py -d -f /boot/config/SABnzbd.ini -s IP:port"

 

first line is the anm that i gave it in unmenu

701-unmenu_user_script_Start_Sabnzbd.cgi

 

and last line you need to adapt to your setup

 

for couchpotato and sickbeard they are the same .. just adapt path and startup command

 

the stop button i need to test yet

 

i was thinking something in the lines of

 

#702-unmenu_user_script_Stop_Sabnzbd
#define USER_SCRIPT_LABEL Stop SABNZBD
#define USER_SCRIPT_DESCR Stop Sabnzbd
#stopping SABNZBD
wget -q -delete-after http://ip:port/sabnzbd/api?mode=shutdown&apikey=your apikey here

again first line is the name as to what to save it

702-unmenu_user_script_Stop_Sabnzbd.cgi

 

last line is the one to adapt to your setup

 

basicly it is just a line that go's to your same stop button as the webinterface

be aware didn't have the time to test this yet

i am at work for the moment so no access to my unraid

 

Link to comment

hi

 

this is an example of the startup button that works

 

#701-unmenu_user_script_Start_Sabnzbd
#define USER_SCRIPT_LABEL Start SABNZBD as Nobody
#define USER_SCRIPT_DESCR start Sabnzbd as user Nobody
#move to nobody and start SABNZBD
su nobody -c "python /path/to/where/you/have/SABnzbd.py -d -f /boot/config/SABnzbd.ini -s IP:port"

 

 

Hi sacretagent,

 

Ii tried creating that button too but it didn't seem to work. 

 

I tried running the command in by itself and the su command doesn't seem to work.  It's a recognised command but if  do a "whoami" after running su - nobody i'm still root.  Is it working fine on your set?

 

I'm running 5.0 beta 2

Link to comment

hi Yep it works but you need to have this in your go script

 

#!/bin/bash

# Start the Management Utility

/usr/local/sbin/emhttp &

/boot/unmenu/uu

 

cd /boot/packages && find . -name '*.auto_install' -type f -print | sort | xargs -n1 sh -c

 

[glow=red,2,300]#sleep for 15 seconds

sleep 15

 

#Sab/sickbeard/couchpotato dependencies

installpkg /boot/custom/packages/SABnzbdDependencies-2.2-i486-unRAID.tgz

 

#give nobody shell access

usermod -s /bin/bash nobody[/glow]

 

#create sshd lastlog

touch /var/log/lastlog

 

 

i posted my complete GO script

but the lines for sab/couchpotato and sickbeard running as nobody are the ones glowing

 

now be aware i know the startup buttons all work

 

still busy messing with the stop buttons ....

there is a syntax error in the stop line and i need to google a bit more to figure it out

 

i also want to test if i add the startup line

su nobody -c "python /path/to/where/you/have/SABnzbd.py -d -f /boot/config/SABnzbd.ini -s IP:port"

 

to the go script if it will start automatically at boot...

 

but since i am away till tomorrow will i not be able to test that till friday ...

 

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.