Kodi Community Forum

Full Version: Starting XBMC after Mysql server is started
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I managed to configure MySQL and XBMC pretty well on my mac. However, when the mac starts, XBMC seems to launch before MySQL is on, resulting in the fact that my library is empty, until I restart XBMC. I was wondering if there was an apple script that could tell "if MySQL server is on, then open XBMC. If not, wait."
I'm a total noob with applescript so I don't really know how to write that. I would love some help! Thanks!
(2013-01-18, 21:30)Vonspiel Wrote: [ -> ]Hi,
I managed to configure MySQL and XBMC pretty well on my mac. However, when the mac starts, XBMC seems to launch before MySQL is on, resulting in the fact that my library is empty, until I restart XBMC. I was wondering if there was an apple script that could tell "if MySQL server is on, then open XBMC. If not, wait."
I'm a total noob with applescript so I don't really know how to write that. I would love some help! Thanks!

This might help. Did you install the StartupItems for MySQL?
I'm using MAMP, so I don't know if the StartupItems are included in it.
(2013-01-18, 23:31)Vonspiel Wrote: [ -> ]I'm using MAMP, so I don't know if the StartupItems are included in it.

This may resolve the issue for you: http://forum.mamp.info/viewtopic.php?p=661

Also, this may help as well: http://stackoverflow.com/questions/73267...em-startup
Thanks Winestock. However, I have no problem starting MAMP at startup. However, MAMP and XBMC starting at almost the same time, MAMP launches MySQL something like 2 or 3 seconds after XBMC launched. I just need a basic applescript that says if mysqld is running, then start XBMC... which I don't know how to write... because I suck at coding!
(2013-01-19, 00:15)Vonspiel Wrote: [ -> ]Thanks Winestock. However, I have no problem starting MAMP at startup. However, MAMP and XBMC starting at almost the same time, MAMP launches MySQL something like 2 or 3 seconds after XBMC launched. I just need a basic script that says if mysqld is running, then start XBMC... which I don't know how to write... because I suck at coding!

Open the activity monitor and look at the processes running to see if you can determine the name of the MAMP process. Once you have that you can use that to determine when the MAMP is running in a shell script. Something like this:

Code:
#!/bin/sh

# The MAMP process name.
processName=mysqld

while (true)
do
    # Check the process list for the MAMP process.
    ps -ea | grep ${processName} | grep -v grep 2>&1 >/dev/null

    # Has MAMP started running yet?
    if [ $? -eq 0 ]
    then
        # Stop looking as MAMP is now running.
        break
    fi

    sleep 10
done

# Start XBMC
open /Applications/XBMC.app

You will need to replace "processName=mysqld" with the proper name of the MAMP process. I think you get the idea from here.
Ha ha thanks!
The process name is also mysqld. However, when I want to save this script, AppleScript Editors tells me "Syntax Error - Expected end of line, etc. but found "while".
(2013-01-19, 00:42)Vonspiel Wrote: [ -> ]Ha ha thanks!
The process name is also mysqld. However, when I want to save this script, AppleScript Editors tells me "Syntax Error - Expected end of line, etc. but found "while".

The script is a shell script not an apple script. Copy the code into a text editor and save the script off with a .sh extension. Make sure the premissions on the shell script are 755 "chmod 755 name.sh". You then can execute it from within a LaunchAgent plist file.
My bad! Thanks!