summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/firstboot.sh
blob: 8e3dc57403852fd461987f34c15ca1f8854d71b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
. ~/.configured
ATTEMPT=0

function try_smolt {
        ((ATTEMPT=ATTEMPT+1))
        WID=`xdotool search "mythfrontend" | head -1`
        xdotool windowfocus $WID
        status=$?
        if [ $status = 0 ]
        then
                sleep 2
                xdotool key "ctrl+alt+p"
                xdotool key "ctrl+alt+p"
                fb_status=0
                echo "FB=NO" > ~/.configured
        fi

        if [ $ATTEMPT = 200 ]
        then
                fb_status=0
        fi

}

function fix_lirc_socket {
  . /etc/systemconfig

  # Fix LircSocket in mythtv database
  SOCKET=`mysql -u mythtv -pmythtv -B --skip-column-names -h "${dbhost}" -D mythconverg -e \
         "SELECT data FROM settings WHERE value = 'LircSocket' AND hostname = '${hostname}';"`
    if [ "${SOCKET}" != "/var/run/lirc/lircd" ]; then
      mysql -u mythtv -pmythtv -B --skip-column-names -h "${dbhost}" -D mythconverg -e \
      "UPDATE settings SET data = '/var/run/lirc/lircd' WHERE value = 'LircSocket' AND hostname = '${hostname}';"
    else
      echo ">>>"
      echo ">>> ATTENTION! ATTENTION! ATTENTION!"
      echo ">>> Unable to connect the the MySQL database to make needed"
      echo ">>> changes to the LIRC socket."
      echo ">>> LIRC now uses /var/run/lirc/lircd and /dev/lirc is now"
      echo ">>> obsolete. Update your MythTV settings to reflect this."
      echo ">>>"
    fi
}


if [ ! -e /tmp/debug ]
then
	if [ ! -e /tmp/nomfe ]
	then
		if [ ! -e ~/.mythtv/pub-uuid ]
		then
			if [ x$FB != xNO ]
			then
				fb_status=4
				while [ $fb_status != 0 ]
				do
                    fix_lirc_socket
					try_smolt
					if [ $fb_status != 0  ]
					then
						sleep 1
					fi
				done
			fi
		fi
	fi
fi