Ive tried and tried - Cant get to run at startup

Linux and UNIX specific discussions
Post Reply
tododo
Posts: 6
Joined: Sat Jan 03, 2009 10:45 am
AV Hardware: running Ubuntu Ibex

Ive tried and tried - Cant get to run at startup

Post by tododo » Fri Feb 13, 2009 6:26 pm

Hi
Guys please can sombody offer me some advise
Im using twonky version 4.49 (using the unzipped version) on ubuntu hardy

All is well apart from the fact that I cant get twonky to run at boot

Well thats kind of a lie....I can get it running on boot up as root user using a simple init.d script (running /media/500GbShare/Twonkymedia/twonkymediaserver) updated to all run levels however the http://localhost:9000 doesnt display at all

If I restart the process all is fine.....it then runs the process as a user I think ie

1000 6419 6299 0 16:54 pts/0 00:00:00 /media/500GbShare/Twonkymedia/twonkymediaserver (notice the 1000 - not sure what that is)

Can anyone offer any advise ...ive tried using the script that come with twonky also and that seems to not work as well (see below)

Basically everything i try fails...if anybody can help id be very grateful
Thanks in adavnce

Code: Select all

#!/bin/sh
#
# MediaServer Control File written by Itzchak Rehberg
# Modified for fedora/redhat by Landon Bradshaw <phazeforward@gmail.com>
# Adapted to TwonkyMedia 3.0 by TwonkyVision GmbH
# Adapted to TwonkyMedia 4.0 by TwonkyVision GmbH
# Adapted to TwonkyMedia 5.0 by PacketVideo
#
# This script is intended for SuSE and Fedora systems.
#
#
################################################## #############################
#
### BEGIN INIT INFO
# Provides: twonkyserver
# Required-Start: $network $remote_fs
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: TwonkyMedia UPnP server
### END INIT INFO
#
# Comments to support chkconfig on RedHat/Fedora Linux
# chkconfig: 345 71 29
# description: TwonkyMedia UPnP server
#
#================================================= =================[ Setup ]===

WORKDIR1="/media/500GbShare/Twonkymedia/"
WORKDIR2="`dirname $0`"
PIDFILE=/var/run/mediaserver.pid

#================================================= ================[ Script ]===

# Source function library.
if [ -f /etc/rc.status ]; then
# SUSE
. /etc/rc.status
rc_reset
else
# Reset commands if not available
rc_status() {
case "$1" in
-v)
true
;;
*)
false
;;
esac
echo
}
alias rc_exit=exit
fi


if [ -x "$WORKDIR1" ]; then
WORKDIR="$WORKDIR1"
else
WORKDIR="$WORKDIR2"
fi

DAEMON=twonkymedia
TWONKYSRV="${WORKDIR}/${DAEMON}"

cd $WORKDIR

case "$1" in
start)
if [ -e $PIDFILE ]; then
PID=`cat $PIDFILE`
echo "TwonkyMedia server seems already be running under PID $PID"
echo "(PID file $PIDFILE already exists). Checking for process..."
running=`ps --no-headers -o "%c" -p $PID`
if ( [ "${DAEMON}"=="${running}" ] ); then
echo "Process IS running. Not started again."
else
echo "Looks like the daemon crashed: the PID does not match the daemon."
echo "Removing flag file..."
rm $PIDFILE
$0 start
exit $?
fi
exit 0
else
if [ ! -x "${TWONKYSRV}" ]; then
echo "TwonkyMedia server not found".
rc_status -u
exit $?
fi
echo -n "Starting $TWONKYSRV ... "
"$TWONKYSRV" -D
rc_status -v
fi
;;
stop)
if [ ! -e $PIDFILE ]; then
echo "PID file $PIDFILE not found, stopping server anyway..."
killall -s TERM twonkymedia
rc_status -u
exit 3
else
echo -n "Stopping Twonky MediaServer ... "
PID=`cat $PIDFILE`
kill -s TERM $PID
rm -f $PIDFILE
rc_status -v
fi
;;
reload)
if [ ! -e $PIDFILE ]; then
echo "PID file $PIDFILE not found, stopping server anyway..."
killall -s TERM twonkymedia
rc_status -u
exit 3
else
echo -n "Reloading Twonky server ... "
PID=`cat $PIDFILE`
kill -s HUP $PID
rc_status -v
fi
;;
restart)
$0 stop
$0 start
;;
status)
if [ ! -e $PIDFILE ]; then
running="`ps ax --no-headers | grep -e twonkymedia | grep -v grep | grep -v twonkymedia.sh | cut -d ' ' -f 1`"
if [ "${running}" == "" ]; then
echo "No TwonkyMedia server is running"
else
echo "A TwonkyMedia server seems to be running with PID ${running}, but no PID file exists."
echo "Probably no write permission for ${PIDFILE}."
fi
exit 0
fi
PID=`cat $PIDFILE`
running=`ps --no-headers -o "%c" -p $PID`
if ( [ "${DAEMON}"=="${running}" ] ); then
echo "TwonkyMedia server IS running."
else
echo "Looks like the daemon crashed: the PID does not match the daemon."
fi
;;
*)
echo ""
echo "TwonkyMedia server"
echo "------------------"
echo "Syntax:"
echo " $0 {start|stop|restart|reload|status}"
echo ""
exit 3
;;
esac

rc_exit
The above starts the proccess as the following

root 5422 1 0 17:15 ? 00:00:00 /media/500GbShare/Twonkymedia//twonkymedia -D
root 5423 5422 0 17:15 ? 00:00:00 /media/500GbShare/Twonkymedia//twonkymediaserver -D

Any ideas anybody??

HornedBeast
Posts: 33
Joined: Mon Apr 21, 2008 3:17 pm
AV Hardware: XBOX 360
Linksys Router
Linux, Ubuntu Server 8.04.

Re: Ive tried and tried - Cant get to run at startup

Post by HornedBeast » Thu Feb 19, 2009 11:28 am

Hello,

Running this should put the script in the right place for you:

Code: Select all

sudo update-rc.d twonkyserver start 45 2 3 4 5 . stop 55 0 1 6 .
I also advise seeing the revised version of this thread, here: http://www.twonkyforum.com/viewtopic.ph ... &sk=t&sd=a

Hope that helps and fixes your problem.

Regards,

HB
Last edited by HornedBeast on Thu Feb 19, 2009 11:29 am, edited 1 time in total.

modernlife
Posts: 3
Joined: Fri Jan 30, 2009 11:22 am
AV Hardware: PS3

Re: Ive tried and tried - Cant get to run at startup

Post by modernlife » Thu Feb 19, 2009 11:29 am

I think I had to do the following:

Code: Select all

update-rc.d -f twonkymedia.sh remove
Edit the top of twonkymedia.sh to read:

Code: Select all

# Default-Start: 2 3 5
# Default-Stop: 0 1 6
Finally:

Code: Select all

update-rc.d twonkymedia.sh defaults

HornedBeast
Posts: 33
Joined: Mon Apr 21, 2008 3:17 pm
AV Hardware: XBOX 360
Linksys Router
Linux, Ubuntu Server 8.04.

Re: Ive tried and tried - Cant get to run at startup

Post by HornedBeast » Thu Feb 19, 2009 11:32 am

Ahhh, thats another elegant solution to the problem. Both seem to work quite happily. I wish the SH had these values by default.

They could easily add an "If" clause for Ubuntu in case it causes problems for Red Hat users.

Cheers for this!

HB

tododo
Posts: 6
Joined: Sat Jan 03, 2009 10:45 am
AV Hardware: running Ubuntu Ibex

Re: Ive tried and tried - Cant get to run at startup

Post by tododo » Fri Feb 20, 2009 6:56 pm

Ive already added the script to all default run levels

Its starts as root (see below)

The 1000 is me starting it manually so that it works


griffithsl@griffithsl-desktop:/etc/init.d$ ps -ef | grep twonk
root 5424 1 0 Feb19 ? 00:00:00 /media/500GbShare/Twonkymedia//twonkymedia -D
root 5425 5424 0 Feb19 ? 00:00:01 /media/500GbShare/Twonkymedia//twonkymediaserver -D
1000 25464 1 0 17:51 pts/1 00:00:00 /media/500GbShare/Twonkymedia/twonkymedia
1000 25465 25464 0 17:51 pts/1 00:00:00 /media/500GbShare/Twonkymedia/twonkymediaserver

HornedBeast
Posts: 33
Joined: Mon Apr 21, 2008 3:17 pm
AV Hardware: XBOX 360
Linksys Router
Linux, Ubuntu Server 8.04.

Re: Ive tried and tried - Cant get to run at startup

Post by HornedBeast » Mon Feb 23, 2009 11:40 am

Hello,

Have you tried changing this line (about 1/3 of the way down your init.d script):

Code: Select all

"$TWONKYSRV" -D
rc_status -v
... to...

Code: Select all

"$TWONKYSRV" -D -ip whatever.your.local.ip.is
rc_status -v
... for example...

Code: Select all

"$TWONKYSRV" -D -ip 192.168.1.2
rc_status -v

That fixed mine for me when I couldn't access it via the http://localhost:9000.

Let us know if that doesn't fix it either!

Post Reply