SageTV Community  

Go Back   SageTV Community > SageTV Products > SageTV Linux
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Linux Discussion related to the SageTV Media Center for Linux. Questions, issues, problems, suggestions, etc. relating to the SageTV Linux should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-03-2010, 12:00 AM
touchstone touchstone is offline
Sage User
 
Join Date: Mar 2008
Posts: 17
OpenSuSE 11.2 SageTV and SJQC initscripts

After recently switching to running Sage on a linux server after a couple years on Vista, I thought I'd share the following initscripts I've written for use with my OpenSuSE 11.2 x86_64 installation. The caveats are that they probably aren't suitable for someone who isn't at least comfortable with bash shell scripting and system administration, and I probably won't be able to give much support. There's no sanity-checking, either.

First, the sagetvserver initscript. In addition to providing a unified way to start/stop the SageTV daemon, it also provides for 1) running as a non-root user, and 2) specifying an alternate Java path (necessary if your main java is 64-bit). The main script is /etc/init.d/sagetvserver, settings in /etc/sysconfig/sagetvserver. An advantage of this script is that it doesn't require modifying any of the sagetv-supplied shell scripts.

If you want to run as a user other than root, you will have to first create the sagetv user, and make sure it has access to the sagetv install directory and to the video devices which it will use (perhaps by adding it to the video group). I'd also suggest disabling logins for the sagetv user and setting its login shell to /bin/false.

Code:
useradd --system -d <your sagetv directory> -s /bin/false -g video -c "SageTV user" <sagetv, or your sagetv username>
chown -R sagetv.video <your sagetv directory>
Note that you should only use a pre-existing group like "video" for sage if no other users have that membership, or you don't mind those users being able to do everything that Sage can.

/etc/init.d/sagetvserver
Code:
#! /bin/sh
### BEGIN INIT INFO
# Provides:          sagetvserver
# Required-Start:    $network $remote_fs dbus
# Required-Stop:     $network $remote_fs dbus
# Default-Start:     3 5
# Default-Stop:
# Short-Description: Launches SageTV server
# Description:       Launches SageTV server
### END INIT INFO


. /etc/rc.status
rc_reset

[[ -x $JAVA_HOME/bin/java ]] && SAGEJAVADIR=$JAVA_HOME
[[ -x /opt/sagetv/server/startsage ]] && SAGEPATH=/opt/sagetv/server
SAGEUSER=sagetv

. /etc/sysconfig/sagetvserver

case "$1" in
	start)
	   echo -n "Starting SageTV server "
	   touch /var/run/sagetv.pid && chown $SAGEUSER /var/run/sagetv.pid
	   sudo -u $SAGEUSER PATH=$SAGEJAVADIR:$PATH $SAGEPATH/startsage 2> /dev/null
	   rc_status -v
	   ;;
	stop)
		echo -n "Shutting down SageTV "
		$SAGEPATH/stopsage
		rc_status -v
		;;
	restart)
		$0 stop
		$0 start
		rc_status
		;;
	*)
		echo "Usage: $0 {start|stop|restart}"
		exit 1
		;;
esac
/etc/sysconfig/sagetvserver
Code:
#Enter the name of the user Sage should run as. Make sure the user has
#been created and has rights to the sagetv directory and the video devices
#Sage will use (perhaps by adding that user to the video group).
SAGEUSER=sagetv

#Replace with the directory where your 32-bit java executable is
SAGEJAVADIR=/opt/sagetv/java/jre1.6.0/bin

#Replace with the directory where the SageTV server is installed
SAGEPATH=/opt/sagetv/server
This is the initscript I've been using for the SJQ client. As it is very late I will leave configuration as an exercise for the reader. It also can run as a non-root user (if running on the same host as the SageTV server, the user most likely will be the one configured for sagetv above). Unlike the sagetvserver script above, this one sudoes the executable directly, rather than by calling the sjqc.sh script supplied with the client package, and may need to be modified if the java commandline used to launch sjqc changes.

/etc/init.d/sjqc
Code:
#! /bin/sh
### BEGIN INIT INFO
# Provides:          SageTV Job Queue Client Daemon
# Required-Start:    $network $remote_fs dbus sagetvserver
# Required-Stop:     $network $remote_fs dbus sagetvserver
# Default-Start:     3 5
# Default-Stop:
# Short-Description: Launches SJQ Client Daemon
# Description:       Launches SJQ Client Daemon
### END INIT INFO


. /etc/rc.status
rc_reset

[[ -x $JAVA_HOME/bin/java ]] && SJQJAVA=`dirname $JAVA_HOME`
SAGEUSER=sagetv
SJQBASE=/opt/sagetv/sjqc
SJQCCONFIGDIR=/etc/sjqc

. /etc/sysconfig/sjqc

JAVA=$SJQJAVA/bin/java

case "$1" in
	start)
	   echo -n "Starting SJQ Client Daemon "      
	      if [[ ! -x $JAVA ]]; then
                  echo "\$JAVA_HOME ($JAVA) does not appear to point to a valid JRE"
                  exit 1
           fi

	   sudo -u $SAGEUSER $JAVA -cp $SJQBASE/json.jar:$SJQBASE/sjqc.jar com.google.code.sagetvaddons.sjqc.TaskClient "$SJQCONFIGDIR" <&- &
	   sjqpid=$!
	   echo "Process started with PID $sjqpid"
	   echo $sjqpid > /var/run/sjqc.pid
	   # SJQC takes a few seconds to print out it's startup info
	   sleep 3
	   rc_status -v
	   ;;
	stop)
	   if [ -e /var/run/sjqc.pid ] ; then
   	     sjqpid=`cat /var/run/sjqc.pid`
             running=`ps --pid $sjqpid | grep java`
	   fi
   	   if [ "$running" = "" ]; then
             echo SageTV not currently running
             exit 1
           fi
           kill $sjqpid
	   rc_status -v
     	   ;;
	restart)
		$0 stop
		$0 start
		rc_status
		;;
	*)
		echo "Usage: $0 {start|stop|restart}"
		exit 1
		;;
esac
/etc/sysconfig/sjqc
Code:
# Replace with the effective user for SageTV, or a dedicated user
SAGEUSER=sagetv
#Replace with the directory where your 32-bit java executable resides
SJQJAVA=/opt/sagetv/java/jre1.6.0/bin
# The SJQ properties directory (/etc/sjqc is the default)
SJQCONFIGDIR=/etc/sjqc
# The directory where the SJQ client was installed
SJQBASE=/opt/sagetv/sjqc
Please post any corrections. Hope some people find this useful.

Last edited by touchstone; 05-03-2010 at 12:02 AM.
Reply With Quote
Reply

Tags
initscript, linux, rc.d, sjqc, start


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ATI vs Nvidia & SageTV - the quest for quality video in a SageTV Client brainbone Hardware Support 51 09-12-2010 01:21 PM
JAVA "Seeker" daemon error help Graygeek SageTV Software 4 01-24-2009 10:53 AM
libSage.so Exception OpenSuse 10.2 AMD 64 jaredljennings SageTV Linux 4 05-03-2008 09:58 AM
6.1.4: SageTV, Vista, & MVP work perfectly but only WITHOUT SageTV Service running! sjgore SageTV Beta Test Software 0 03-11-2007 11:25 AM
SageTV Releases SageTV Lite PVR Software for Windows Hardware OEMs dkardatzke Announcements 0 07-06-2005 09:43 AM


All times are GMT -6. The time now is 12:31 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.