source: trunk/dports/multimedia/mythtv-core.25/files/Myth_Stop_Start.applescript

Last change on this file was 98186, checked in by pixilla@…, 12 years ago

multimedia/mythtv-core.25:

  • Update to version 0.25.2-Fixes-20120918.
  • Blacklist llvm-gcc-4.2, macports-llvm-gcc-4.2, macports-clang-3.1, dragonegg-3.0 and dragonegg-3.1. Closes 35934.
  • Specify libpng and p5.12-datemanip dependencies.
  • Handle libdvdnav build conflict.
  • logrotate to manage myth log files.
  • Fix patching of internet content scripts.
  • Unambiguous qmake.
  • Respect distcc and ccache settings.
  • Fix directory permissions.
  • Force working themepainter for mythtv-setup.
File size: 3.5 KB
Line 
1(*  Applescript to stop/start Myth background apps
2For use with MacPorts install of Myth
3Author:  Craig Treleaven, ctreleaven at cogeco.ca
4Version: 0.25.2
5Modified: 2012Jul11 - new
6           2012Sep21 - log rotation
7
8NB - if mbe is running, we only stop it if it was launched under launchd
9*)
10set mysqld to " not running on this machine.  Is it on another machine on your network?"
11set rotatorStatus to ""
12set logrotButton to ""
13set mythbackend to ""
14set mythbackendButton to "Donno"
15set newline to "
16"
17set indent to space & space & space & space
18set myResult to ""
19
20repeat until (myResult contains "Close")
21        if (do shell script "sudo launchctl list" with administrator privileges) contains ".logrotate" then
22                set rotatorStatus to "runs daily"
23                set logrotButton to "Disable log rotation"
24        else
25                set rotatorStatus to "is not scheduled"
26                set logrotButton to "Schedule log rotation"
27        end if
28       
29        set processes to do shell script "ps -Ac"
30        if the processes contains "mysqld" then
31                set mysqld to " running."
32        end if
33       
34        if the processes contains "mythbackend" then
35                set mythbackend to " running."
36                set mythbackendButton to "Stop MythBackend"
37                try
38                        do shell script "mythshutdown --check"
39                on error
40                        set mythbackend to " running but busy with something.  Are you sure you want to shut down now?"
41                end try
42        else
43                set mythbackend to " not running."
44                set mythbackendButton to "Start MythBackend"
45        end if
46       
47        set myResult to display dialog newline & "Simple tool to start and stop Myth's background processes" & Â
48                newline & newline & newline & "Currently... " & Â
49                newline & newline & indent & "Log rotation " & rotatorStatus & Â
50                newline & newline & indent & "MySQL is" & mysqld & Â
51                newline & newline & indent & "MythBackend is" & mythbackend & newline & newline Â
52                with icon note with title Â
53                "Stop/Start Myth-related programs" buttons {logrotButton, mythbackendButton, "Close"} Â
54                default button "Close" -- cancel button "Close"
55        set myResult to button returned of myResult
56        if myResult contains "Start MythBackend" then
57                do shell script "sudo launchctl load -w /Library/LaunchDaemons/org.mythtv.mythbackend.plist" with administrator privileges
58        else if myResult contains "Stop MythBackend" then
59                if ((do shell script "sudo launchctl list" with administrator privileges) contains "mythbackend") then
60                        do shell script "sudo launchctl unload -w /Library/LaunchDaemons/org.mythtv.mythbackend.plist" with administrator privileges
61                        -- there is a longish delay while myth closes down.
62                else
63                        display alert " MythBackend appears not to have been started in the normal fashion.  Unable to shut down." message "Was mythbackend started directly from a command line session?" as warning
64                end if
65                set myResult to "Close"
66        else if myResult contains "Schedule log rotation" then
67                --check for existence of
68                if (FileExists("@PREFIX@/etc/logrotate.conf") and Â
69                        FileExists("@PREFIX@/etc/logrotate.d/logrotate.mythtv")) then
70                        do shell script "sudo launchctl load -w /Library/LaunchDaemons/org.macports.logrotate.plist" with administrator privileges
71                else
72                        display dialog "logrotate is not configured.  Please see http://www.mythtv.org/wiki/MacPorts for instructions." buttons {"Close"}
73                        set myResult to "Close"
74                end if
75        else if myResult contains "Disable log rotation" then
76                do shell script "sudo launchctl unload -w /Library/LaunchDaemons/org.macports.logrotate.plist" with administrator privileges
77        end if
78end repeat
79
80on FileExists(theFile) -- (String) as Boolean
81        tell application "System Events" to return (exists file theFile)
82end FileExists
Note: See TracBrowser for help on using the repository browser.