How to stop/start Twonky 6 / 7 in a bash-script

DLNA, AirPlay, Chromecast, PS3, XBOX, iTunes, & other media players
crystalball
Starting out
Posts: 39
Joined: Tue Sep 25, 2012 8:04 am

How to stop/start Twonky 6 / 7 in a bash-script

Post by crystalball »

Is it possible to stop / start twonky in a bash script correctly?
ls -l /etc/init.d/twonky*
-rwxr-xr-x 1 admin administ 10112 Apr 20 14:02 /etc/init.d/twonkymedia.sh*
lrwxrwxrwx 1 admin administ 49 Sep 30 22:56 /etc/init.d/twonkymedia6.sh -> /share/HDA_DATA/.qpkg/TwonkyMedia/twonkymedia6.sh*
How must that be done with Twonky 6 and 7?

I noticed, when I change about 1000 playlists, but no mp3, the script which changes the playlists lasts 4 min. if the service is down, but 14 min. if the service is running. But I have no idea, if the scan takes longer at the end, when I stopped the service before.
User avatar
Briain
Experience counts
Posts: 1749
Joined: Tue Apr 20, 2010 11:56 pm
Location: Edinburgh (Scotland)

Re: How to stop/start Twonky 6 / 7 in a bash-script

Post by Briain »

Hi

/etc/init.d/twonkymedia6.sh stop
/etc/init.d/twonkymedia6.sh start

I think you can also use the ...sh restart (which effectively runs both the above).

Bri
TS-119, 1 X Seagate ~~ TS-219, 2 X Seagate (R1) ~~ TS-453A, 2 X 3 TB WD Red (R1) ~~ TS-659, 5 X 1 TB Hitachi Enterprise (R6)
APC Smart-UPS 750
crystalball
Starting out
Posts: 39
Joined: Tue Sep 25, 2012 8:04 am

Re: How to stop/start Twonky 6 / 7 in a bash-script

Post by crystalball »

Thanks, so it is done as with Linux "normally". Some other NAS-brands do it in a different way and I had big troubles with these other brands, so I changed to Qnap ;-) but I don't want to do something wrong again.
crystalball
Starting out
Posts: 39
Joined: Tue Sep 25, 2012 8:04 am

Re: How to stop/start Twonky 6 / 7 in a bash-script

Post by crystalball »

Unfortunately

Code: Select all

/etc/init.d/twonkymedia6.sh start
leads to problems, it does _not_ start the service again, maybe because of
PID file /tmp/mediaserver.pid not found, stopping server anyway...
So start stops the service. The webinterface says that the service is running, after stopping the service with the webinterface it can be started again with the webinterface.
User avatar
Briain
Experience counts
Posts: 1749
Joined: Tue Apr 20, 2010 11:56 pm
Location: Edinburgh (Scotland)

Re: How to stop/start Twonky 6 / 7 in a bash-script

Post by Briain »

I thought it worked in Twonky 6, but I've not tried Twonky 7, so I'll look tomorrow. I think the web interface possibly controls it via rpc calls:

http://NAS.ip.add:9000/rpc/stop
http://NAS.ip.add:9000/rpc/start
http://NAS.ip.add:9000/rpc/restart

These can be used with the actual NAS IP address, or the local loopback address.

Bri
TS-119, 1 X Seagate ~~ TS-219, 2 X Seagate (R1) ~~ TS-453A, 2 X 3 TB WD Red (R1) ~~ TS-659, 5 X 1 TB Hitachi Enterprise (R6)
APC Smart-UPS 750
crystalball
Starting out
Posts: 39
Joined: Tue Sep 25, 2012 8:04 am

Re: How to stop/start Twonky 6 / 7 in a bash-script

Post by crystalball »

I am using Twonky 6.0.39 (at the moment) with the QNAP-version, so I have the problems with Twonky 6.

So you mean I have to use wget instead of /ete/init.d with a bash-script? I would like to create stops and starts within a script.
User avatar
schumaku
Guru
Posts: 43579
Joined: Mon Jan 21, 2008 4:41 pm
Location: Kloten (Zurich), Switzerland -- Skype: schumaku
Contact:

Re: How to stop/start Twonky 6 / 7 in a bash-script

Post by schumaku »

Vaguely remember: Double check if your Twonky 6 is the firmware built-in Twonky or the QPKG-installed version. hese might use a different scriot - without resp. with the 6.
User avatar
schumaku
Guru
Posts: 43579
Joined: Mon Jan 21, 2008 4:41 pm
Location: Kloten (Zurich), Switzerland -- Skype: schumaku
Contact:

Re: How to stop/start Twonky 6 / 7 in a bash-script

Post by schumaku »

Briain wrote:I thought it worked in Twonky 6, but I've not tried Twonky 7, so I'll look tomorrow. I think the web interface possibly controls it via rpc call.
stop and restart appear to work ... start might be difficult with no service listening on port 9000 :lol:
crystalball
Starting out
Posts: 39
Joined: Tue Sep 25, 2012 8:04 am

Re: How to stop/start Twonky 6 / 7 in a bash-script

Post by crystalball »

What can I do?
80/tcp open http?
443/tcp open ssl/https?
|_sslv2: server still supports SSLv2
631/tcp open ipp CUPS 1.4
873/tcp open rsync (protocol version 30)
3493/tcp open tcpwrapped
8080/tcp open http-proxy?
8090/tcp open ssl/unknown
|_sslv2: server still supports SSLv2
9000/tcp open cslistener?
49152/tcp open upnp Portable SDK for UPnP devices 1.4.1 (kernel 2.6.33.2; UPnP 1.0)
4 services unrecognized despite returning data.
User avatar
schumaku
Guru
Posts: 43579
Joined: Mon Jan 21, 2008 4:41 pm
Location: Kloten (Zurich), Switzerland -- Skype: schumaku
Contact:

Re: How to stop/start Twonky 6 / 7 in a bash-script

Post by schumaku »

crystalball wrote:What can I do?
About what? I just pointed out that
1. different scripts are used for firmware built-in Twonky 6 vs. QPKG Twony 6 most likley, and
2. the RPC can only work if there is a deamon - once stopped, there is no listender, so no Twonky RPC calls possible obviously to start. (edit: ...and we're talking of Twonky Web server based RPC commands here, nothing else)
crystalball
Starting out
Posts: 39
Joined: Tue Sep 25, 2012 8:04 am

Re: How to stop/start Twonky 6 / 7 in a bash-script

Post by crystalball »

So there is no chance to start twonky with a bash script?
User avatar
schumaku
Guru
Posts: 43579
Joined: Mon Jan 21, 2008 4:41 pm
Location: Kloten (Zurich), Switzerland -- Skype: schumaku
Contact:

Re: How to stop/start Twonky 6 / 7 in a bash-script

Post by schumaku »

Of course you can stop it - by calling the _correct_ script... why not?
Please - at least for yourself - answer the question I raised sosme posts back... QPKG of firmwae built-in. I?m convinced, you are using the wrong script - there is nothing else on the NAS to start/stop the DLNA server.
crystalball
Starting out
Posts: 39
Joined: Tue Sep 25, 2012 8:04 am

Re: How to stop/start Twonky 6 / 7 in a bash-script

Post by crystalball »

schumaku wrote:Vaguely remember: Double check if your Twonky 6 is the firmware built-in Twonky or the QPKG-installed version. hese might use a different scriot - without resp. with the 6.
How can I check this?
The webinterface says for Version 7, which i simply downloaded via the webinterface: Version: TwonkyServer Premium 7.0.9

I can _stop_ twonky, no problem, but I cannot _start_ it again.

Edit: I switched to Version 7. Going back to Version 6, means a scan for hours. But it is the same with Twonky 7:

Code: Select all

# /etc/init.d/twonkymedia.sh stop   
Shutting down UPnP MediaServer services: twonkymedia.kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]

Code: Select all

# /etc/init.d/twonkymedia.sh start
UPnP MediaServer is disabled. If the process still existed, try to run "/etc/init.d/twonkymedia.sh stop"
User avatar
schumaku
Guru
Posts: 43579
Joined: Mon Jan 21, 2008 4:41 pm
Location: Kloten (Zurich), Switzerland -- Skype: schumaku
Contact:

Re: How to stop/start Twonky 6 / 7 in a bash-script

Post by schumaku »

If you would be so nice and read the replies ie. that one http://forum.qnap.com/viewtopic.php?f=1 ... 13#p290532 ...would lead to the following solution:

[~] # ps -ef | grep onky
1570 admin 360 S /share/MD0_DATA/.qpkg/TwonkyMedia/twonkystarter -inif
1571 admin 62856 S /share/MD0_DATA/.qpkg/TwonkyMedia/twonkyserver -inifi
4584 admin 292 S grep onky
[~] # /etc/init.d/twonkymedia6.sh stop
Shutting down UPnP MediaServer services: twonkymedia.
[~] # ps -ef | grep onky
4635 admin 288 S grep onky
[~] # /etc/init.d/twonkymedia6.sh start
Starting UPnP MediaServer: (/share/MD0_DATA/.qpkg/TwonkyMedia/twonkystarter)
[~] # ps -ef | grep onky
4679 admin 360 S /share/MD0_DATA/.qpkg/TwonkyMedia/twonkystarter -inif
4680 admin 17320 S /share/MD0_DATA/.qpkg/TwonkyMedia/twonkyserver -inifi
5004 admin 288 S grep onky

I can ... find the difference please.

This script -_does_ work with both QPKG installed Twonky 6 and Twonky 7.

Doing anything different can and will lead to unexpected results.
crystalball
Starting out
Posts: 39
Joined: Tue Sep 25, 2012 8:04 am

Re: How to stop/start Twonky 6 / 7 in a bash-script

Post by crystalball »

Code: Select all

[~] # ps -ef | grep onky
16622 admin       412 S   /share/HDA_DATA/.qpkg/TwonkyMedia/twonkystarter -inifile /etc/config/twonkyvision-mediaserver6.ini 
16623 admin     87620 S   /share/HDA_DATA/.qpkg/TwonkyMedia/twonkyserver -inifile /etc/config/twonkyvision-mediaserver6.ini -
18342 admin       568 S   grep onky 
[~] # 
[~] # /etc/init.d/twonkymedia
twonkymedia.sh   twonkymedia6.sh  
[~] # /etc/init.d/twonkymedia.sh stop
Shutting down UPnP MediaServer services: twonkymedia.kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]

[~] # ps -ef | grep onky
18771 admin       568 R   grep onky 
[~] # 
[~] # /etc/init.d/twonkymedia.sh start
UPnP MediaServer is disabled. If the process still existed, try to run "/etc/init.d/twonkymedia.sh stop"
[~] # 
[~] # ps -ef | grep onky
18785 admin       568 R   grep onky 
Post Reply

Return to “Media Streaming”