[mythtv] Help needed for RPM Fusion package modernizaton

R. G. Newbury newbury at mandamus.org
Wed Jul 18 17:44:43 UTC 2012


On 07/18/2012 10:47 AM, Gary Buhrmaster wrote:
> On Wed, Jul 18, 2012 at 6:54 AM, Daniel Thor Kristjansson
> <danielk at cuymedia.net>  wrote:
> ....
>>>> 2. Right now on sysv systems both HOME and MTYHCONFDIR are being set
>>
>>
>> Dunno about this. MYTHCONFDIR is used both to locate configuration
>> files and as a location for caches. It would make a lot of sense
>> to allow caches to go somewhere else.
>
> sysv scripts are mostly dead for Fedora (EOL for F15 has
> already happened).  Ignore them, let then die in piece.
>
> In my opinion, the defaults should be to run as a "regular user",
> with no need to read/write to system directories.  The mythtv
> user should be created if it does not exist.  HOME should
> not need to be set in the systemd scripts when the User=mythtv
> line exists in the systemd script.  Any configuration that is
> required for operation commonly created in /etc, /usr,
> should be copied to the (RPM created, if does not exist) mythtv
> user's .mythrv/ directory, using the RPM standards of "...rpmnew"
> if the configuration already exists and is different than the file
> you are trying to install (to the normal/correct name if the
> file does not exist).  The mythtv user should be added to the
> video and audio groups if the mythtv user is created by the RPM.
> The startup scripts should specify the user mythtv as the user
> to run the backend.  Create an appropriate /etc/limit.d/90-mythtv.conf
> file to set the audio group for rtprio.
>
> An individual can always override all of these things in their
> copy of the service file that they place in /etc/systemd/system
> (and/or modify the ~mythtv/.mythtv/ files, as needed).
>

And I will add, that the RPM should also create the /var/log/mythtv 
folder, and chown it to mythtv as well as /run/mythtv (or 
/var/run/mythtv) for the pid file

I have found that systemd has problems with creating /run, so I am using 
/var/log/mythtv/ for the pid file. Also systemd has problems running 
/etc/rc.d/rc.local so you cannot be sure that everything properly exists 
on reboot if it used to be set there.

I run a pre-start script in the service file, to make sure that 
everything is correct. I think it now needs to be type=forking, 
otherwise the mythlogserver process becomes an orphan (with type=simple) 
and a blocker to any restart. (systemctl may fail to start the backend 
with any visible error message)

This is the pre-start.sh, but everything in it needs to be in the 
install too I think.

# *****************************************************************
#!/bin/bash
# pre-start.sh script for systemd (replacing /etc/init.d/mythbackend)

USERNAME="mythtv"
PASSWORD="mythtv"

# in this case a non-usual home for mythtv user
export HOME=/var/log/mythtv
export MYTHTV_HOME=/var/log/mythtv

# UTF encoding needed by myth
export LC_ALL=en_US.UTF-8

# Check for user, create if missing, create HOME too
RESULT=""
# if user exists, will be in /etc/passwd file
RESULT=`grep "$USERNAME" /etc/passwd`;
if [ "$RESULT" == ""  ]; then
      echo "Mythtv user not found, user account will be created"
      useradd -m -d "$HOME" -G mysql -p "$PASSWORD" -U "$USERNAME" 2>&1
      usermod -a -G audio,video mythtv 2>&1;
#  else
#     echo "User exists, no action taken";
fi

# Required sanity checks

if [ ! -x /var/log/mythtv ]; then
     # make logging folder
     mkdir -p -m 755 /var/log/mythtv
     chown -hR mythtv:mythtv /var/log/mythtv
fi
# make pid folder  even if using /var/log/mythtv
# sudo as may be called by mythtv user
sudo mkdir -p -m 755 /var/run/mythtv
sudo chown -hR mythtv:mythtv /var/run/mythtv

# and again to be sure
sudo mkdir -p -m 755 /run/mythtv
sudo chown -hR mythtv:mythtv /run/mythtv


# ******************
# below here, only for the pre-start script to clean up
# any existing errors on a restart.


# An 'is-running' check
# Kill any running process as a start has been initiated

$  the 'proper' pidfile
if [ -e /run/mythtv/backend.pid ]; then
     sudo rm -f /run/mythtv/backend.pid
fi
# the alternate pidfile
if [ -e /var/log/mythtv/backend.pid ]; then
     sudo rm -f /var/log/mythtv/backend.pid
fi

sudo killall mythlogserver 2&>1
sudo killall mythbackend 2&>1

#    echo "Now ready to start mythbackend,service

# ********************************************





More information about the mythtv-dev mailing list