[mythtv] making mythbackend be a daemon
Andrew Heybey
mythtv-dev@snowman.net
Sun Jan 5 03:10:59 EST 2003
--Nq2Wo0NMKNjxTN9z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
I do not (yet) have a computer dedicated to mythtv; I am playing with
it on the family computer. I wanted mythbackend to start up at boot
time so that programs would be recorded automagically in the
background. I also wanted multiple users to be able to run
mythfrontend to use mythtv.
So I made a few minor changes to the CVS version (as of about 30
December) and various changes to my system configuration and it seems
to work. I thought it might be of interest to other people so here is
what I did.
This is on Redhat 8.0; I am a Linux newbie (I usually run FreeBSD) so
I do not know how applicable the startup script and the configuration
stuff is to other distributions.
1. Apply the attached "mythbackend.diff" patch (just a couple of
changes). This patch makes mythbackend work even if there is no
DISPLAY since it no longer creates a widget. I haven't yet tried
to use daemon(3) but that would be the obvious next step.
2. Create a "tv" user and a "mythtv" group. Make the home directory
of "tv" be /usr/local/share/mythtv. Add users who will use
mythtv to the "mythtv" group.
3. "chown -R tv:mythtv ~tv" to give ownership of mythtv files to the
tv user and mythtv group. Do the same for your mythtv data
directory if it is not underneath /usr/local/share/mythtv.
4. "chmod g+w your_mythtv_data_directory" to let members of group
"mythtv" create and delete files in the directory where video data
is stored. (Not sure if this is actually required since I think
that files are only created/deleted by mythbackend which will be
running as the "tv" user.)
5. Change the lines dealing with sound and v4l in
/etc/security/console.perms as follows so that the devices have
permissions that allow mythbackend to access them. Permission 640
might suffice...
<console> 0660 <sound> 0660 root.mythtv
<console> 0660 <v4l> 0660 root.mythtv
6. Install the attached "mythtv.sh" script as /etc/init.d/mythtv (ie
rename it to remove the ".sh"). Do "chkconfig mythtv on". I had
to put "modprobe bttv" in the script to make sure that the bttv
module gets loaded. I am sure that this is the Wrong Thing to do,
but I don't understand enough about Linux yet to know the Right Thing.
7. Make sure that all the channel icons are readable by the "tv" user.
It seems to work for me, but YMMV. One thing I thought of while
writing this email is to set the mixer setting to the proper values in
the mythtv.sh script.
andrew
--Nq2Wo0NMKNjxTN9z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="mythbackend.diff"
Index: programs/mythbackend/main.cpp
===================================================================
RCS file: /var/lib/cvs/MC/programs/mythbackend/main.cpp,v
retrieving revision 1.4
diff -u -u -r1.4 main.cpp
--- programs/mythbackend/main.cpp 30 Dec 2002 07:40:55 -0000 1.4
+++ programs/mythbackend/main.cpp 5 Jan 2003 02:30:11 -0000
@@ -136,7 +136,7 @@
{
QApplication a(argc, argv);
- MythContext *context = new MythContext;
+ MythContext *context = new MythContext(false);
context->LoadSettingsFiles("backend_settings.txt");
QSqlDatabase *db = QSqlDatabase::addDatabase("QMYSQL3");
@@ -168,7 +168,9 @@
int statusport = context->GetNumSetting("StatusPort", 6544);
MainServer *ms = new MainServer(context, port, statusport, &tvList);
+#if 0
a.setMainWidget(ms);
+#endif
a.exec();
Index: programs/mythbackend/mainserver.h
===================================================================
RCS file: /var/lib/cvs/MC/programs/mythbackend/mainserver.h,v
retrieving revision 1.6
diff -u -u -r1.6 mainserver.h
--- programs/mythbackend/mainserver.h 30 Dec 2002 07:40:55 -0000 1.6
+++ programs/mythbackend/mainserver.h 5 Jan 2003 02:30:15 -0000
@@ -14,7 +14,7 @@
class MythContext;
class HttpStatus;
-class MainServer : public QVBox
+class MainServer : public QObject
{
Q_OBJECT
public:
--Nq2Wo0NMKNjxTN9z
Content-Type: application/x-sh
Content-Disposition: attachment; filename="mythtv.sh"
Content-Transfer-Encoding: quoted-printable
#!/bin/bash=0A#=0A# mythtv This shell script takes care of starting and sto=
pping the=0A# mythtv back end.=0A#=0A# 80 & 10 are (respectively) just bef=
ore & after mysqld since we require it.=0A# chkconfig: - 80 10=0A# descript=
ion: Mythtv backend.=0A# processname: mythtvbackend=0A=0A# Source function =
library.=0A. /etc/rc.d/init.d/functions=0A=0Amythprefix=3D"/usr/local/share=
/mythtv"=0Aprog=3D"mythbackend"=0Apath=3D"/usr/local/bin/$prog"=0Auser=3Dtv=
=0Alog=3D"$mythprefix/${prog}.log"=0A=0Astart(){=0A pid=3D`pidofproc $pr=
og`=0A if [ -n "$pid" ]; then=0A return 0=0A fi=0A =0A modprobe=
bttv=0A touch $log=0A chown $user $log=0A nohup su -s /bin/bash -=
$user -c "$path" 2>&1 > $log &=0A [ "$?" -eq 0 ] && success $"$prog sta=
rtup" || failure $"$prog startup"=0A}=0A=0Astop(){=0A killproc $prog=0A}=
=0A =0Arestart(){=0A stop=0A start=0A}=0A=0Acondrestart(){=0A p=
id=3D`pidofproc $prog`;=0A [ -n "$pid" ] && restart || :=0A}=0A=0A# See =
how we were called.=0Acase "$1" in=0A start)=0A start=0A ;;=0A stop=
)=0A stop=0A ;;=0A status)=0A status $prog=0A ;;=0A restart)=
=0A restart=0A ;;=0A condrestart)=0A condrestart=0A ;;=0A *)=
=0A echo $"Usage: $0 {start|stop|status|condrestart|restart}"=0A exit=
1=0Aesac=0A=0Aexit $?=0A
--Nq2Wo0NMKNjxTN9z--
More information about the mythtv-dev
mailing list