DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2011-04-18 23:48:15

tinybilbo
Member
Registered: 2011-04-02
Posts: 36

Struggling to write a Start/Stop script in /init.d

Hi,

I've installed Sickbeard, Couchotato, Sabnzbd, and Pyload into Dhub's chrooted debian (on a USB stick), on an Alt-f 0.1b7 flashed 323.
At the moment I can start them by using the cli or a simple start script, in Alt-f's WebGui under Services/User.

I would like more flexibilty, and so that I can show my wife how to start/stop stuff from the WebGui.

I know that I need to write a Start/Stop script to go in /etc/init.d.
However I don't  really understand how to go about it, being new to any form of scripting.
I've looked at the other scripts in /etc/init.d, but can't seem to modify any of them to work with my apps/processes.
I'm not too sure if the fact that they are chrooted process, is what stumping me, or if it's because they are python processes...

All I simply need to type to run a process is;
python /mnt/sdc2/debian/debian/opt/pyload/pyLoadCore.py (the python command is symlinked to the deb command in /usr/bin).

Could someone help me out with either, writing the script (I'll adapt it for the other processes), or point me in the direction of a similar script, that I can learn from it.

I have googled about Linux script writing, as well as studied the other scripts, but without someone to help by asking questions to,
I'm getting nowhere.... slowly....

Any help would greatly appreciated...

Thanks

Offline

 

#2 2011-04-19 09:12:49

krackpot
Member
Registered: 2009-01-24
Posts: 44

Re: Struggling to write a Start/Stop script in /init.d

I'm also interested in getting the start/stop script in the web gui as well.

I've got the same setup as you, except I didn't put the chrooted debian from dhub into my USB stick (how did you do this btw?).

Hope you don't mind me threadjacking a little, but did you use dhub's sabnzbdplus package?


DNS-323 (B1) on Alt-F 0.1B7
2x2TB WD20EARS

Offline

 

#3 2011-04-19 12:25:35

tinybilbo
Member
Registered: 2011-04-02
Posts: 36

Re: Struggling to write a Start/Stop script in /init.d

krackpot wrote:

I'm also interested in getting the start/stop script in the web gui as well.

I've got the same setup as you, except I didn't put the chrooted debian from dhub into my USB stick (how did you do this btw?).

Hope you don't mind me threadjacking a little, but did you use dhub's sabnzbdplus package?

Hi Krackpot,

I installed sabnzbd int the debian chroot using apt-get for the dependancies and downloading sabnzb's source and running it.
I did'nt use Dhub's package, as I was having trouble installing it, because (I think) I was running the chroot from usb.

apt-get -y install unzip par2 python-dev python-cheetah python-cherrypy
1. Download the latest version ofSABnzbd SOURCE.    http://sourceforge.net/projects/sabnzbd … src.tar.gz
   to /mnt/sdc2/debian/debian/opt
2. Unzip.
   cd /mnt/sdc2/debian/debian/opt
   tar -zxvf /opt/SABnzbd-0.x.xx-src.tar.gz
3. Start the SABnzb in the foreground with the following command:
   /mnt/sdc2/debian/debian/opt/SABnzbd-0.x.xx-src SABnzbd.py
   When it stops listing text of what it just did, Stop the process with CTRL+C.
   This creates sabnzbd.ini
4. Edit /root/.sabnzbd/sabnzbd.ini
   and change
   host=localhost
   to
   host=<ip address of nas>
5. Start the process and run it.
   python  /mnt/sdc2/debian/debian/opt/SABnzbd-0.x.xx-src/SABnzbd.py -d -f ~/.sabnzbd/sabnzbd.ini
6. In web browser go to <the ip of your nas>:8080/sabnzbd

Running the chroot from usb was surprisingly simple, I installed it like normal, and manually moved the "debian" to sdc2 (usb stick) (/mnt/sdc2/debian/debian), and then;

1) Change chroot symlink
    cd mnt/sdc2/Alt-f
    ln -s /mnt/sdc2/debian
    rename it to chroot

2) Edit /etc/init.d/s25debian

    And add /mnt/sdc2/debian
    to the line "for i in /chroot/debian /mnt/sda2/debian /mnt/sda4/debian /mnt/md0/debian /mnt/sdb2/debian /mnt/sdb4/debian"

    So it becomes "for i in /chroot/debian /mnt/sda2/debian /mnt/sda4/debian /mnt/md0/debian /mnt/sdb2/debian /mnt/sdb4/debian /mnt/sdc2/debian"

   Do this twice within the file

Could you post any files/scripts that are to do with sabnzb in /etc/init.d todo with your install of dhub's sabnzb, I want to have a look at it, and can't get it installed to have a look...

Thanks

Offline

 

#4 2011-04-20 22:30:33

bjby
Member
Registered: 2009-02-22
Posts: 265

Re: Struggling to write a Start/Stop script in /init.d

everything looks like a nail to a hammer, anyway.

Monit service manager is a service supervisor. It comes with a web-ui to stop and start the services it supervises. It is not all that hard to configure. I can share the simple config I have setup. Maybe overkill for what you are looking. Shouldnt be hard to install from debian or optware.

http://mmonit.com/monit/screenshots/ima … hots/3.png

Last edited by bjby (2011-04-20 22:36:27)

Offline

 

#5 2011-04-20 23:34:41

tinybilbo
Member
Registered: 2011-04-02
Posts: 36

Re: Struggling to write a Start/Stop script in /init.d

bjby wrote:

everything looks like a nail to a hammer, anyway.

Monit service manager is a service supervisor. It comes with a web-ui to stop and start the services it supervises. It is not all that hard to configure. I can share the simple config I have setup. Maybe overkill for what you are looking. Shouldnt be hard to install from debian or optware.

http://mmonit.com/monit/screenshots/ima … hots/3.png

Thanks for that...
I think I read about it, in another thread, except I did'nt realise you could control the services as well.
Might be just what I need.

Offline

 

#6 2011-04-24 00:51:17

krackpot
Member
Registered: 2009-01-24
Posts: 44

Re: Struggling to write a Start/Stop script in /init.d

Thanks for the reply tinybilbo. I've got the latest 0.5.6 running now. I may eventually move towards a USB stick, but will try to get everything running properly for now.

Going to try sickbeard and couchpotato now that I've got SABnzbd working the way I want.

Have you tried Monit that bjby suggested?


DNS-323 (B1) on Alt-F 0.1B7
2x2TB WD20EARS

Offline

 

#7 2011-04-24 02:02:56

tinybilbo
Member
Registered: 2011-04-02
Posts: 36

Re: Struggling to write a Start/Stop script in /init.d

krackpot wrote:

Thanks for the reply tinybilbo. I've got the latest 0.5.6 running now. I may eventually move towards a USB stick, but will try to get everything running properly for now.

Going to try sickbeard and couchpotato now that I've got SABnzbd working the way I want.

Have you tried Monit that bjby suggested?

Not yet, I've been trying to get an init.d script going that will add sabnzb,(or the any the other apps),
directly into the Alt-f WebGui, But I know bugger all about scripting - so it's an uphill struggle.

I can write a simple init.d script that works from the command line in the chroot (start,stop,status),
however I need to write another script that wraps around the first one, that adds it into the Webgui.
I can only get the start and stop part going, and not the status - in wrapper script...

I'll have a crack for a couple more days, and if I get nowhere, I'll have a look at mmonit

*edit*

Just installed monit, will try to configure it tomorrow.

bjby wrote:

.
...I can share the simple config I have setup...

bjby

I'll take you up on that offer the config, if you don't mind... smile

Thanks

Last edited by tinybilbo (2011-04-24 02:13:40)

Offline

 

#8 2011-04-24 08:43:15

bjby
Member
Registered: 2009-02-22
Posts: 265

Re: Struggling to write a Start/Stop script in /init.d

Its pretty well documented and straightforward. /etc/monit/monitrc contains a lot of examples which is commented out. I had little problem with webui since default setup only allowed access via localhost.

#/etc/monit/monitrc
...
#
## Monit has an embedded web server which can be used to view status of
## services monitored and manage services from a web interface. See the
## Monit Wiki if you want to enable SSL for the web server.
#
set httpd port 2812
     allow 192.168.0.20       
     allow localhost
...
#Simple example of setting up monitoring for a service     
  check process fancontrol with pidfile /var/run/fancontrol.pid
    start program = "/etc/init.d/fancontrol start" with timeout 260 seconds
    stop program  = "/etc/init.d/fancontrol stop"
...

Offline

 

#9 2011-04-24 22:41:13

tinybilbo
Member
Registered: 2011-04-02
Posts: 36

Re: Struggling to write a Start/Stop script in /init.d

bjby wrote:

Its pretty well documented and straightforward. /etc/monit/monitrc contains a lot of examples which is commented out. I had little problem with webui since default setup only allowed access via localhost.
...

Thanks for that,

Sometimes you can't see the wood for the trees with these sample config files...
So it made it much easier to see a working config.
Very easy to set up in the end.

Also its going to be very useful for monitoring the apps I use, so that I can spread the load over my two Nas's properly.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB