source: src-qt4/xtrafiles/local/share/pcbsd/scripts/mythtv.sh @ 1620346

9.1-release9.2-releasereleng/10.0releng/10.0.1releng/10.0.2
Last change on this file since 1620346 was 1620346, checked in by Kris Moore <kris@…>, 15 months ago

Initial import of PC-BSD /current/ SVN repo

  • Property mode set to 100755
File size: 2.0 KB
Line 
1#!/bin/sh
2# Script to start mythtv and init
3
4SCRIPT="/usr/local/share/pcbsd/scripts/mythtv.sh"
5
6# Make sure we are running as root
7as_root() {
8        if [ "`id -u`" != "0" ] ; then
9                echo "ERROR: Must be run as root!"
10                exit
11        fi
12}
13
14check_init()
15{
16        if [ ! -e "/var/log/mythinit.log" -o "$1" = "init" ] ; then
17                pc-su xterm -e ${SCRIPT} doinit
18        fi
19}
20
21do_init() 
22{
23        as_root
24        echo "Starting mysql-server..."
25        /usr/local/etc/rc.d/mysql-server stop >/dev/null 2>/dev/null
26        killall -9 mysqld >/dev/null 2>/dev/null
27        killall -9 mysqld_safe >/dev/null 2>/dev/null
28        /usr/local/etc/rc.d/mysql-server start >/dev/null 2>/dev/null
29
30        # Do we need a password?
31        echo "?;" | mysql --user=root >/dev/null 2>/dev/null
32        if [ $? -eq 0 ] ; then PASS="" ; else PASS="-p" ; fi
33       
34        echo "Creating mysql database / user..."
35        mysql --user=root $PASS < /usr/local/share/mythtv/database/mc.sql
36
37        echo "Preparing to start mythtv setup..."
38        do_setup
39
40        echo "Starting MythTV backend..."
41        /usr/local/etc/rc.d/mythbackend stop >/dev/null 2>/dev/null
42        /usr/local/etc/rc.d/mythbackend start >/dev/null 2>/dev/null
43        echo "MythTV configured `date`" > /var/log/mythinit.log
44
45        echo "Finished! Press ENTER to continue."
46        read tmp
47        exit 0
48}
49
50# Run the setup program
51do_setup() 
52{
53        as_root
54        mythtv-setup
55        /usr/local/etc/rc.d/mythbackend stop >/dev/null 2>/dev/null
56        /usr/local/etc/rc.d/mythbackend start >/dev/null 2>/dev/null
57}
58
59check_setup()
60{
61        if [ "$1" = "setup" ] ; then
62                pc-su xterm -e ${SCRIPT} dosetup
63        fi
64}
65
66check_installed()
67{
68        which mythfrontend >/dev/null 2>/dev/null
69        if [ $? -ne 0 ] ; then
70                echo "ERROR: MythTV is not installed!" 
71                exit 1
72        fi
73};
74
75check_backend()
76{
77        # Lets check if the backend is running
78        ps -awwxc | grep mythbackend >/dev/null 2>/dev/null
79        if [ $? -ne 0 ] ; then
80                zenity --question --text "The mythbackend daemon is not running. Do you wish to re-run the configuration? "
81                if [ $? -eq 1 ] ; then
82                        exit 1
83                fi
84                check_setup setup
85                exit 0
86        fi
87};
88
89check_installed
90
91case $1 in
92        doinit) do_init ; exit 0 ;;
93        dosetup) do_setup ; exit 0 ;;
94        *) ;;
95esac
96
97check_init $1
98check_setup $1
99check_backend
100
101mythfrontend
Note: See TracBrowser for help on using the repository browser.