Adding to /System/Library/StartupItems

zerorex

Registered
I found the package for MySQL, and installed it with out a problem. Now I am trying to get it to start on boot. I come from a fairly strong FreeBSD background, and adding boot processes in FreeBSD is easy, but I'll be buggered if I can get it to work in OSX. I added a folder for mysql to the /System/Library/StartupItems, and copied the two files from the Apache dir. I modified them to start mysql, and then added a line to /etc/hostconfig that said:
MYSQLSERVER=-YES-
which should be the correct syntax, yet it still does not start on boot. If any one knows how to add startup items or knows of a place that can tell me how I would be much appreciative.

ZeroRex
 

BenW

Registered
Couldn't you just add it to the startup items list through the GUI? Or will that only work with GUI apps?
 

strobe

Puny Member
Your FreeBSD background is absolutely useless in this regard. You need to create a property list specifying when it ought to be started. I'll show you my StartupItem for my dnetc client as an example:

I have two files in a directory I labeled "DNetClient" which I put in the /System/Library/StartupItems directory. One called DNetClient and the other called StartupParameters.plist.

DNetClient file is the executable which contains:

#!/bin/sh

##
# start dnetc
##

su anarkhos -c "/Users/anarkhos/rc5-64/dnetc" >/dev/null &

It's a simple sh script which starts dnetc as a process belonging to "anarkhos"

StartupParameters.plist is a property list:
{
Description = "Distributed.net Client";
Provides = ("dnetc");
Requires = ("NetInfo");
OrderPreference = "None";
Messages =
{
start = "Launching dnetc";
stop = "Closing dnetc";
};
}

property lists can also be in XML or the binary format if you wish.

Here you can plainly see dnetc requires NetInfo. Why? because te user "anarkhos" doesn't exist until NetInfo has started. mySQL may require NetInfo, NFS, Network, and some other things. I wouldn't know, it depends on your setup.
 

zerorex

Registered
yep, here are the scripts i used

(these scripts are in /System/Library/StartupItems/Mysql

from MySQL (shell script)
-----------------------------
#!/bin/sh

##
# Start MySQL Server
##

./etc/rc.common
if [ "${MYSQLSERVER:=-NO-}" = "-YES-"]; then
ConsoleMessage "Starting Mysql Server"

safe_mysqld
fi

from StartupParameters.plist
--------------------------------
{
Description = "MySQL Server";
Provides = ("Database");
Required = ("Resolver");
Uses = ("Disks");
OrderPreference = ("None");
Messages =
{
start = "Starting MySQL Server";
stop = "Stopping MySQL Server";
};
}

and from /etc/hostconfig
-----------------------------

MYSQLSERVER=-YES-


This looks like it should work, but the mysqld is not started after boot up...

??


 

zerorex

Registered
Had to pull out the stuff that checked /etc/hostconfig, and make a change to the plist file.

For any one who will be doing this in the future, it appears that in the provides = ("somehting") box you need to say the name of the deamon that is provided...
 

JohnMurden

Registered
If someone wanted to put together a step-by-step on installing mySQl they would be doing the world (or me_) a great favor. I'm not afraid of CLI, just new.
 

jc658

Registered
Well I don't have time to post a complete list of instructions. But I did it with the standard release from www.mysql.com. It comes with installation instructions that are fairly easy to follow. There was one syntax error when I ran 'make' which was very easy to fix (just add 'int' in the parathesis). Then I ran 'make' again and continued following the instructions. Now I'm just trying to get it to start at startup

Jesse
 

PoweMACuser

Registered
Originally posted by strobe
Your FreeBSD background is absolutely useless in this regard. You need to create a property list specifying when it ought to be started. I'll show you my StartupItem for my dnetc client as an example:

I have two files in a directory I labeled "DNetClient" which I put in the /System/Library/StartupItems directory. One called DNetClient and the other called StartupParameters.plist.

DNetClient file is the executable which contains:

#!/bin/sh

##
# start dnetc
##

su anarkhos -c "/Users/anarkhos/rc5-64/dnetc" >/dev/null &

It's a simple sh script which starts dnetc as a process belonging to "anarkhos"

StartupParameters.plist is a property list:
{
Description = "Distributed.net Client";
Provides = ("dnetc");
Requires = ("NetInfo");
OrderPreference = "None";
Messages =
{
start = "Launching dnetc";
stop = "Closing dnetc";
};
}

property lists can also be in XML or the binary format if you wish.

Here you can plainly see dnetc requires NetInfo. Why? because te user "anarkhos" doesn't exist until NetInfo has started. mySQL may require NetInfo, NFS, Network, and some other things. I wouldn't know, it depends on your setup.

hi, have you found that after installed mySQL, mysql command line can't be used. According to the readme file, it should has the command line mysql --usr=root. It seems that mySQL is not installed. I want to download the source to compile it myself, how?
 

jpbjpbjpb

UNIX with an Apple GUI - Cool
You should be adding your startup directories to /Library/StartupItems, not /System/Library/StartupItems

Apple reserves /System for it's own use - if you add things to /System/Library/StartupItems, it's entirely possible that a future system update will step all over your startup entry.

If you don't have /Library/StartupItems, you can just mkdir it.

 
Top