I didn't have any initial luck with using the autorun.sh idea on the wiki. Another approach I'm trying is to make the MythTV install look like a QPKG, so it starts at boot and I can enable/disable from the web interface. I followed the
thread here for a manual QPKG instance. Here was my entry appended to /etc/config/qpkg.conf:
- Code: Select all
[MythTV]
Name = MythTV
Version = 0.24.1
Enable = TRUE
QPKG_File = Manual install
Date = 2012-03-06
Shell = /share/MD0_DATA/.qpkg/MythTV/MythTV.sh
Install_Path = /share/MD0_DATA/.qpkg/MythTV
Author = MythTV
Then I added a MythTV.sh script in the qpkg path specified above. I borrowed heavily from the TVHeadend QPKG for a template start/stop/restart script. Here's what I came up with:
- Code: Select all
#!/bin/sh
CONF=/etc/config/qpkg.conf
QPKG_NAME="MythTV"
QPKG_DIR=$(/sbin/getcfg $QPKG_NAME Install_Path -d "" -f $CONF)
QPKG_SCRIPT=$(/sbin/getcfg $QPKG_NAME Shell -d "" -f $CONF)
QPKG_LOGFILE="${QPKG_DIR}/${QPKG_NAME}.log"
function check_process_running() {
# Check if process is already running (ARM version)
PROCESS_RUNNING=0
for pid in $(/bin/pidof mythbackend); do
# Try to find if the process is MythTV
/bin/grep -q "mythbackend" /proc/$pid/cmdline
if [ $? == 0 ]; then
# Process found, save PID and exit loop
PROCESS_RUNNING=$pid
return 0
fi
done
# Process not found
return 1
}
function writelog_info() {
# Write a message on the QNAP log
/sbin/write_log "$1" 4
}
function writelog_warning() {
# Write a message on the QNAP log
/sbin/write_log "$1" 2
}
case "$1" in
start)
ENABLED=$(/sbin/getcfg $QPKG_NAME Enable -u -d FALSE -f $CONF)
if [ "$ENABLED" != "TRUE" ]; then
/bin/echo "$QPKG_NAME is disabled."
exit 1
fi
# Check if process is already running
check_process_running
if [ $? = 0 ]; then
/bin/echo "$QPKG_NAME is already running!"
exit 1
fi
# Start logging
exec > $QPKG_LOGFILE 2>&1
# Start MythTV
/bin/grep -q "/opt/lib" /etc/ld.so.conf
if [ $? != 0 ]; then
echo "/opt/lib" >> /etc/ld.so.conf
/sbin/ldconfig
fi
export HOME=/root
/share/MD0_DATA/.qpkg/Optware/bin/mythbackend &
/bin/echo "MythTV Backend started."
writelog_info "MythTV Backend started."
;;
stop)
# Stop the process
check_process_running
if [ $? != 0 ]; then
/bin/echo "$QPKG_NAME is NOT running!"
exit 1
fi
# Start logging
exec > $QPKG_LOGFILE 2>&1
# Kill the process
/bin/kill -15 $PROCESS_RUNNING
/bin/sleep 3
;;
restart)
$0 stop
$0 start
;;
showlog)
# Print the current MythTV logfile
/bin/echo "MythTV QPKG log created: $(/bin/date -r $QPKG_LOGFILE)"
/bin/cat $QPKG_LOGFILE
;;
status)
# Check if MythTV is running or not
check_process_running
if [ $? = 0 ]; then
/bin/echo "MythTV status: RUNNING."
exit 0
else
/bin/echo "MythTV status: STOPPED."
exit 1
fi
;;
*)
/bin/echo "MythTV QPKG"
/bin/echo "Usage: $0 {start|stop|restart|status|showlog}"
exit 1
;;
esac
exit 0
Good news is that the script works well for doing Enable/Disable from the webpage

, but isn't working so well for loading on boot. Here is the output when enabling the QPKG after boot, which works.
- Code: Select all
MythTV Backend started.
QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv failed for BOM: Bad file descriptor
QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv_open failed
QIconvCodec::convertToUnicode: using Latin-1 for conversion, iconv_open failed
2012-03-07 01:21:34.269 mythbackend version: [v0.24.1] www.mythtv.org
2012-03-07 01:21:34.271 Using runtime prefix = /opt
2012-03-07 01:21:34.282 Using configuration directory = /root/.mythtv
2012-03-07 01:21:34.284 Unable to read configuration file mysql.txt
2012-03-07 01:21:34.285 Empty LocalHostName.
2012-03-07 01:21:34.285 Using localhost value of ParrisNAS
2012-03-07 01:21:34.459 New DB connection, total: 1
2012-03-07 01:21:34.563 Connected to database 'mythconverg' at host: localhost
2012-03-07 01:21:34.727 Closing DB connection named 'DBManager0'
2012-03-07 01:21:34.730 Connected to database 'mythconverg' at host: localhost
2012-03-07 01:21:34.761 Current locale en_US
2012-03-07 01:21:34.772 Reading locale defaults from /opt/share/mythtv//locales/en_us.xml
2012-03-07 01:21:34.890 Current MythTV Schema Version (DBSchemaVer): 1264
2012-03-07 01:21:34.947 ThreadPool:HTTP: Initial 1, Max 25, Timeout 60000
2012-03-07 01:21:35.053 Enabling Upnpmedia rebuild thread.
2012-03-07 01:21:36.327 MythBackend: Starting up as the master server.
2012-03-07 01:21:36.404 New DB connection, total: 2
2012-03-07 01:21:36.406 Connected to database 'mythconverg' at host: localhost
2012-03-07 01:21:36.527 New DB connection, total: 3
2012-03-07 01:21:36.532 Connected to database 'mythconverg' at host: localhost
2012-03-07 01:21:37.139 New DB scheduler connection
2012-03-07 01:21:37.141 Connected to database 'mythconverg' at host: localhost
2012-03-07 01:21:37.210 Main::Registering HttpStatus Extension
2012-03-07 01:21:37.211 Enabled verbose msgs: important general
2012-03-07 01:21:37.280 AutoExpire: CalcParams(): Max required Free Space: 0.0 GB w/freq: 15 min
QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv failed for BOM: Bad file descriptor
2012-03-07 01:21:40.232 Reschedule requested for id -1.
2012-03-07 01:21:40.630 Scheduled 0 items in 0.4 = 0.12 match + 0.27 place
2012-03-07 01:21:40.665 Seem to be woken up by USER
QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv failed for BOM: Bad file descriptor
2012-03-07 01:21:45.077 UPnpMedia: BuildMediaMap - no VideoStartupDir set, skipping scan.
and here is the response when it tries to load automatically on boot:
- Code: Select all
QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv failed for BOM: Bad file descriptor
QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv_open failed
QIconvCodec::convertToUnicode: using Latin-1 for conversion, iconv_open failed
2012-03-07 01:17:04.244 mythbackend version: [v0.24.1] www.mythtv.org
2012-03-07 01:17:04.246 Using runtime prefix = /opt
2012-03-07 01:17:04.247 Using configuration directory = /root/.mythtv
2012-03-07 01:17:04.368 Unable to read configuration file mysql.txt
2012-03-07 01:17:04.369 Empty LocalHostName.
2012-03-07 01:17:04.369 Using localhost value of ParrisNAS
2012-03-07 01:17:05.000 New DB connection, total: 1
2012-03-07 01:17:05.030 Unable to connect to database!
2012-03-07 01:17:05.030 Driver error was [1/2002]:
QMYSQL: Unable to connect
Database error was:
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
...................................................................
2012-03-07 01:17:07.131 UPnPautoconf() - No UPnP backends found
2012-03-07 01:17:07.132 No UPnP backends found
No UPnP backends found
Would you like to configure the database connection now? [no]
[console is not interactive, using default 'no']
2012-03-07 01:17:07.132 Deleting UPnP client...
2012-03-07 01:17:08.171 Failed to init MythContext.
Any thoughts? I'm thinking that mysql is not fully loaded prior to the mythtv trying to run. If that's the case, how can I make sure mysql is good before loading mythtv?