[mythtv-users] mythbackend startscript broken on fedora 19
R. G. Newbury
newbury at mandamus.org
Mon Mar 3 21:28:08 UTC 2014
On 03/02/2014 07:13 AM, mythtvuser at vandrosthagen.net wrote:
> Hello there,
>
> Since last week i updated my mythtv setup to version 0.27 on fedora and
> all is well. It was verry scary because i am using iptv and on 0.25 en
> 0.26 it was really broken that is why i stayed on 0.24..;) But can say
> iptv is working like a charm in 0.27.
>
> But now my problem.. After i installed everyting all was working well
> the only failure i have is that mythbackend is not starting on boot. The
> problem i have with it is that if i start the script mythackend gets an
> error
>
> 2014-03-02 13:09:09.269457 N [25523/25523] thread_unknown
> mythdirs.cpp:55 (InitializeMythDirs) - Using runtime prefix = /usr
> 2014-03-02 13:09:09.269461 N [25523/25523] thread_unknown
> mythdirs.cpp:61 (InitializeMythDirs) - Read conf dir = /var/lib/mythtv
> 2014-03-02 13:09:09.269476 N [25523/25523] thread_unknown
> mythdirs.cpp:68 (InitializeMythDirs) - Using configuration directory =
> /var/lib/mythtv
> 2014-03-02 13:09:09.269537 I [25523/25523] CoreContext
> mythcorecontext.cpp:249 (Init) - Assumed character encoding: en_US.UTF-8
> 2014-03-02 13:09:09.269692 E [25523/25523] CoreContext
> mythdbparams.cpp:39 (IsValid) - DBHostName is not set in config.xml
> 2014-03-02 13:09:09.269703 E [25523/25523] CoreContext
> mythdbparams.cpp:39 (IsValid) - DBHostName is not set in config.xml
> 2014-03-02 13:09:09.269710 N [25523/25523] CoreContext
> mythcontext.cpp:504 (LoadDatabaseSettings) - Empty LocalHostName.
> 2014-03-02 13:09:09.269713 I [25523/25523] CoreContext
> mythcontext.cpp:512 (LoadDatabaseSettings) - Using localhost value of mythtv
> 2014-03-02 13:09:09.275498 E [25523/25523] CoreContext mythdbcon.cpp:216
> (OpenDatabase) - Unable to connect to database!
> 2014-03-02 13:09:09.275509 E [25523/25523] CoreContext mythdbcon.cpp:217
> (OpenDatabase) - Driver error was [1/1045]:
> QMYSQL: Unable to connect
> Database error was:
> Access denied for user 'mythtv'@'localhost' (using password: YES)
THIS is the problem. First make sure that you can access mysql from the
command line with a 'mysql -u mythtv -pmythtv mythconverg' (assuming
the usual defaults).
If that works, then check that the config.xml file in ~/.mythtv is correct.
Then make sure that mysqld.service works properly. Without mysql, myth
will not run, and that could be your problem.
Also you have no hostname set, so set one with 'hostname my-new-hostname'.
Also ensure that /etc/sysconfig/network has:
NETWORKING=yes
HOSTNAME=my-new-hostname
Also helps to edit /etc/hosts to add the hostname/ IP address
combination (and set your router to give a statix IP address.
One advantage and problem with systemd is that fact that it does things
in parallel and sometimes things are not yet set or ready. I run a
mythtv pre-start shell script to set everything which myth explicitly
needs and which might not yet be set. I also ensure that any detritus of
previous runs are removed (mainly for re-starts, whether intentional or
forced!)
***************************************************
#!/bin/bash
# pre-start.sh script for systemd (replacing /etc/init.d/mythbackend)
# turn off screensaver
/usr/bin/xset -dpms
/usr/bin/xset s off
# these are for mysql: not necessary to export although you can if you want
USERNAME="mythtv"
PASSWORD="mythtv"
export HOME=/home/mythtv
export MYTHTV_HOME=/home/mythtv
export LC_ALL=en_US.UTF-8
mkdir /var/log/mythtv
chown mythtv:mythtv /var/log/mythtv
mkdir /run/mythtv
chown mythtv:mythtv /run/mythtv
mkdir /run/lirc
chown mythtv:mythtv /run/lirc
# An 'is-running' check used to be performed by the old sysinit script
# Instead we will kill *any* running myth process.
# testing for presence of mythlogserver always started with mythbackend
but often orphaned
result=`ps -ae | grep mythlogserver`
out=`echo $result | awk '{ print $4}'`
if [ "$out" = "mythlogserver" ] ; then
sudo killall mythbackend > /dev/null 2&>1
sudo killall mythlogserver > /dev/null 2&>1
sudo killall mythcommflag > /dev/null 2&>1
sudo killall mythfrontend > /dev/null 2&>1
sudo rm -f /run/mythtv/backend.pid > /dev/null 2&>1
# echo "Killed existing processes"
fi
********************************************************
>
> But when i start mythbackend manual under the user mythtv with the
> command " /usr/bin/mythbackend --daemon --logpath /var/log/mythtv"
> everything is working fine.
>
> I saw during startup in the log that the script was looking for config
> in the /var/lib/mythtv so i thought ok the files like mysql.txt and
> config.xml are in my setup under /home/mythtv/.mythtv so decided to
> softlink the dir .mythtv to /var/lib/mythtv/.mythtv but no luck.. Still
> i get the error above.
If /var/lib/mythtv does not exist, then symlinking will fail. Create the
symlink so that /var/log/mythtv points into /home/mythtv. eg: ln -s
/home/mythtv/ /var/log/mythtv/
> Secondly the script i use is still an old startupscript because fedora
> decided to go to services.. I was wondering does anybody have an working
> services startup script or has figured out how to get the mythbackend
> script to run?
This is MY mythbackend.service script. There is at least one .service
script around which is Type=simple but I could never get it to work
properly and create a pid file. YMMV!
If you cannot get this to start, check the steps/scripts being run
*extremely* carefully from the command line. Systemd is *extremely*
sensitive to permissions and other errors. And unless you really know
what you are doing, turn disable selinux in /etc/selinux/config. It can
really mess up you day, and leaves no error messages! Thnigs just do not
work!
************************************************
[Unit]
Description=MythTV backend service
Wants=httpd.service
After=network.target mysqld.service
[Service]
Type=forking
#PIDFile=/var/log/mythtv/backend.pid : cannot use this line: not
allowed in [Service]
Environment=MYTHCONFDIR=/home/mythtv
Environment=HOME=/home/mythtv
Environment=MYTHBACKEND_USER=mythtv
#EnvironmentFile=/etc/sysconfig/mythbackend
User=mythtv
ExecStartPre=/usr/local/sbin/pre-start.sh
#ExecStart=/usr/local/bin/mythbackend --daemon --noupnp --loglevel emerg
--logpath /var/log/mythtv --pidfile /var/log/mythtv/backend.pid
# turn off logging
ExecStart=/usr/local/bin/mythbackend --daemon --noupnp --pidfile
/var/log/mythtv/backend.pid
[Install]
WantedBy=multi-user.target
*************************************************
--
R. Geoffrey Newbury
Barrister and Solicitor
Suite 106, 150 Lakeshore Road West
Mississauga, Ontario, L5H 3R2
t905-271-9600 f905-271-1638
newbury at mandamus.org
More information about the mythtv-users
mailing list