[mythtv-users] Foolproof Mythbuntu start/restart irexec command

Joseph Fry joe at thefrys.com
Fri Aug 3 21:49:53 UTC 2012


>
>
> > So again, the logic for the script is "If it's it running, killall
>
>> mythfrontend.real (so Mythbuntu then restarts it) and if it's not
>> running at all start it." but I don't know how to write bash.
>>
>
> Hi;
>
> Run this with the FE running and not running. If the output
> matches what you expect, replace the echos with your restart
> and start-up commands.
>
> #!/bin/sh
>
> pgrep mythfrontend.real 2>&1 > /dev/null
>
> if [ $? -eq 0 ]; then
>     echo "Already running, put restart command here."
> else
>     echo "Not running, put your start-up command here"
> fi


This should work for the entire thing, just create the necessary rcexec
entry with this command, no script necessary (untested in rcexec):

   pidof mythfrontend.real && killall mythfrontend.real || mythfrontend &

I know it looks weird, but it really does work.

Boolean logic doesn't process any more than it has to in Bash... so in an
AND... if the left is false, then it doesn't check the right; in an OR, if
the left is true it doesn't check the right.

And Bash lets you use application exit codes as the values you your logic.
 So this basically replicates and if then else structure in one line.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mythtv.org/pipermail/mythtv-users/attachments/20120803/f2222196/attachment.html>


More information about the mythtv-users mailing list