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 10-20-2010, 01:04 AM
michaeldjcox michaeldjcox is offline
Sage Fanatic
 
Join Date: Nov 2006
Location: Ipswich, Suffolk, United Kingdom
Posts: 829
Running as root or not

Hi,

I'm perfecting my WFE plugin for linux and noted from another thread that some people run sagetv as root (I guess this is what you get by default) and some people (following best practice) run sagetv as another user.

I've got my plugin working where everything runs as root. I know want to test where sagetv runs as a different user.

Is there a step by step guide for doing this anywhere?

Michael
__________________
Web Feed Encoder developer
SageTV Catchup developer
Reply With Quote
  #2  
Old 10-22-2010, 08:42 AM
kireol kireol is offline
Sage User
 
Join Date: Oct 2010
Location: Michigan
Posts: 14
Here's what I did

Code:
sudo useradd --system -d /opt/sagetv/server/ -s /bin/false -g video -c "sagetv" sagetv
sudo chown -R sagetv.video /opt/sagetv/server
The first line creates a new user; sagetv. sagetv will then be a new user and in group video. your capture card is in /dev/videoX where X is the number of the device. /dev/video0 is group video, so sagetv will have access to it.

The second line allows the sagetv user to write to the folders that sagetv is using.


hope this helps
Reply With Quote
  #3  
Old 10-22-2010, 11:40 AM
drewg drewg is offline
Sage Icon
 
Join Date: Aug 2007
Location: Richmond, VA
Posts: 1,042
Quote:
Originally Posted by kireol View Post
Here's what I did

Code:
sudo useradd --system -d /opt/sagetv/server/ -s /bin/false -g video -c "sagetv" sagetv
sudo chown -R sagetv.video /opt/sagetv/server
I did that as well, though I actually gave sage a shell.

There's also the matter of starting sagetv at system boot. I don't know what the .deb installs. I took the mythtv startup script and modified it to start sage back in the 8.04 days, and am still using it:
Code:
% cat /etc/init.d/sagetv
#!/bin/sh
### BEGIN INIT INFO
# Provides:          sagetv
# Required-Start:    $network $local_fs
# Required-Stop:     $network $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/Stop the SageTV server.
### END INIT INFO

PATH=/opt/jre/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/comskip
DAEMON=/home/sagetv/server/startsage
NAME="sagetv"
DESC="SageTV server"

test -x $DAEMON || exit 0

set -e

USER=sagetv
RUNDIR=/var/run/sagetv
#ARGS="--daemon --logfile /var/log/mythtv/mythbackend.log --pidfile $RUNDIR/$NAME.pid"
EXTRA_ARGS=""
NICE=0

ARGS="$ARGS $EXTRA_ARGS"

mkdir -p $RUNDIR
chown -R $USER $RUNDIR


case "$1" in
  start)
        echo -n "Starting $DESC: $NAME"
#       start-stop-daemon --start  \
#               --chuid $USER --nicelevel $NICE --exec $DAEMON -- $ARGS
        su - $USER -c /home/sagetv/server/startsage
        echo "."
        ;;
  stop)
        echo -n "Stopping $DESC: $NAME "
        /home/sagetv/server/stopsage
        echo "."
        ;;
  restart|force-reload)
        echo -n "Restarting $DESC: $NAME"
        /home/sagetv/server/stopsage
        echo "."
        sleep 3
#       start-stop-daemon --start  \
#               --chuid $USER --nicelevel $NICE --exec $DAEMON -- $ARGS
        su - $USER -c /home/sagetv/server/startsage
        echo "."
        ;;
  *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0

% ls -l /etc/rc*.d/* | grep sagetv
lrwxrwxrwx 1 root root  16 Sep  5 15:14 /etc/rc0.d/K99sagetv -> ../init.d/sagetv*
lrwxrwxrwx 1 root root  16 Sep  5 15:14 /etc/rc1.d/K99sagetv -> ../init.d/sagetv*
lrwxrwxrwx 1 root root  16 Sep  5 15:12 /etc/rc2.d/S99sagetv -> ../init.d/sagetv*
__________________
Server HW: AMD Ryzen Threadripper 2990WX 32-Core
Server SW: FreeBSD-current, ZFS, linux-oracle-jdk1.8.0, sagetv-server_9.2.2_amd64
Tuner HW: HDHR
Client: Nvidia Shield (HD300, HD100 in storage)
Reply With Quote
  #4  
Old 10-22-2010, 11:58 AM
kireol kireol is offline
Sage User
 
Join Date: Oct 2010
Location: Michigan
Posts: 14
Quote:
Originally Posted by drewg View Post
I did that as well, though I actually gave sage a shell.

There's also the matter of starting sagetv at system boot. I don't know what the .deb installs. I took the mythtv startup script and modified it to start sage back in the 8.04 days, and am still using it:
Code:
% cat /etc/init.d/sagetv
#!/bin/sh
### BEGIN INIT INFO
# Provides:          sagetv
# Required-Start:    $network $local_fs
# Required-Stop:     $network $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/Stop the SageTV server.
### END INIT INFO

PATH=/opt/jre/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/comskip
DAEMON=/home/sagetv/server/startsage
NAME="sagetv"
DESC="SageTV server"

test -x $DAEMON || exit 0

set -e

USER=sagetv
RUNDIR=/var/run/sagetv
#ARGS="--daemon --logfile /var/log/mythtv/mythbackend.log --pidfile $RUNDIR/$NAME.pid"
EXTRA_ARGS=""
NICE=0

ARGS="$ARGS $EXTRA_ARGS"

mkdir -p $RUNDIR
chown -R $USER $RUNDIR


case "$1" in
  start)
        echo -n "Starting $DESC: $NAME"
#       start-stop-daemon --start  \
#               --chuid $USER --nicelevel $NICE --exec $DAEMON -- $ARGS
        su - $USER -c /home/sagetv/server/startsage
        echo "."
        ;;
  stop)
        echo -n "Stopping $DESC: $NAME "
        /home/sagetv/server/stopsage
        echo "."
        ;;
  restart|force-reload)
        echo -n "Restarting $DESC: $NAME"
        /home/sagetv/server/stopsage
        echo "."
        sleep 3
#       start-stop-daemon --start  \
#               --chuid $USER --nicelevel $NICE --exec $DAEMON -- $ARGS
        su - $USER -c /home/sagetv/server/startsage
        echo "."
        ;;
  *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0

% ls -l /etc/rc*.d/* | grep sagetv
lrwxrwxrwx 1 root root  16 Sep  5 15:14 /etc/rc0.d/K99sagetv -> ../init.d/sagetv*
lrwxrwxrwx 1 root root  16 Sep  5 15:14 /etc/rc1.d/K99sagetv -> ../init.d/sagetv*
lrwxrwxrwx 1 root root  16 Sep  5 15:12 /etc/rc2.d/S99sagetv -> ../init.d/sagetv*

This is mine

Code:
#! /bin/sh

SAGEJAVADIR=/opt/jre/bin/java
SAGEPATH=/opt/sagetv/server
SAGEUSER=sagetv


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
           ;;
        stop)  
                echo -n "Shutting down SageTV "
                $SAGEPATH/stopsage
                ;;
        restart)
                $0 stop
                $0 start
                ;;
        *)
                echo "Usage: $0 {start|stop|restart}"
                exit 1
                ;;
esac
Reply With Quote
  #5  
Old 10-22-2010, 10:17 PM
RocKKer RocKKer is offline
Sage Advanced User
 
Join Date: Dec 2005
Posts: 196
Here is the .deb package startup script:

Code:
#! /bin/sh
### BEGIN INIT INFO
# Provides:          sagetv
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Short-Description: SageTV Server
# Description:       This is the init script for the SageTV service
#                    that handles clients and recordings.
### END INIT INFO
#
# Author:       Jean-Francois Thibert <jeanfrancois@sagetv.com>.
#
# Version:      @(#)sagetv  6.5  Jan-2009
#

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="SageTV Server"
NAME=sagetv
SCRIPTNAME=/etc/init.d/$NAME

# Gracefully exit if the package has been removed.
test -x /opt/sagetv/server/startsage || exit 0

#
#       Function that starts the daemon/service.
#
d_start() {
        nohup /opt/sagetv/server/startsage
}

#
#       Function that stops the daemon/service.
#
d_stop() {
        /opt/sagetv/server/stopsage
}

case "$1" in
  start)
        echo -n "Starting $DESC: $NAME"
        d_start
        echo "."
        ;;
  stop)
        echo -n "Stopping $DESC: $NAME"
        d_stop || true
        echo "."
        ;;
  restart|force-reload)
        echo -n "Restarting $DESC: $NAME"
        d_stop || true
        sleep 3
        d_start
        echo "."
        ;;
  *)
        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
        exit 3
        ;;
esac

exit 0
__________________
SageTV Server v9.2.2, Ubuntu Server 18.04.4 x64, Java 1.8.0_252, Xeon E5-2690, 32GB, 6X6TB WD Red - Software Raid 6, 2X HDHR3 (OTA), 3X HD-200
Reply With Quote
  #6  
Old 10-25-2010, 09:54 AM
michaeldjcox michaeldjcox is offline
Sage Fanatic
 
Join Date: Nov 2006
Location: Ipswich, Suffolk, United Kingdom
Posts: 829
Thanks guys
__________________
Web Feed Encoder developer
SageTV Catchup developer
Reply With Quote
Reply


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
Show root import folders Oats SageMC Custom Interface 3 09-06-2009 10:29 PM
ERROR:Root element is missing. enterpryse SageTV EPG Service 3 01-22-2009 12:47 PM
Server only run as root Kevintimm SageTV Beta Test Software 8 05-23-2008 05:51 PM
Richard Dawkins - Root of All Evil Steve2112 The SageTV Community 2 12-09-2007 07:46 PM
Files in root of C? obrian93 SageTV Software 2 03-30-2006 09:17 PM


All times are GMT -6. The time now is 05:10 PM.


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