# Services Sequence in rc.conf



## lezde716 (May 20, 2011)

```
May 20 14:25:22 nwtf-proxy01 snort[961]: FATAL ERROR: database: mysql_error: Can't connect to local MySQL server through socket
 '/tmp/mysql.sock' (2)
```

I got this error at boot. I notice that the snort service start first before mysql. But in my rc.conf is the sequence below.


```
# SQUID Configuration
# squid_enable="YES"

# MYSQL SERVICE 
mysql_enable="YES"

# SNORT Configuration
snort_enable="YES"

# WEB SERVICE 
apache22_enable = "YES"
apache22_http_accept_enable="YES"
```

How do I change the sequence so the system will first read the mysql and then the snort?

This is the sequence shown in rcorder:


```
rcorder: requirement `LOGIN' in file `/usr/local/etc/rc.d/squid' has no providers.
/usr/local/etc/rc.d/squid
rcorder: requirement `DAEMON' in file `/usr/local/etc/rc.d/snort' has no providers.
/usr/local/etc/rc.d/snort
rcorder: requirement `DAEMON' in file `/usr/local/etc/rc.d/snmptrapd' has no providers.
/usr/local/etc/rc.d/snmptrapd
rcorder: requirement `DAEMON' in file `/usr/local/etc/rc.d/snmpd' has no providers.
/usr/local/etc/rc.d/snmpd
rcorder: requirement `SERVERS' in file `/usr/local/etc/rc.d/pure-ftpd' has no providers.
rcorder: requirement `NETWORKING' in file `/usr/local/etc/rc.d/pure-ftpd' has no providers.
/usr/local/etc/rc.d/pure-ftpd
rcorder: requirement `LOGIN' in file `/usr/local/etc/rc.d/mysql-server' has no providers.
```

Please help.


----------



## SirDice (May 20, 2011)

The order in /etc/rc.conf is irrelevant.

Add the MySQL requirement to the snort rc file.


----------



## lezde716 (May 23, 2011)

SirDice said:
			
		

> The order in /etc/rc.conf is irrelevant.
> 
> Add the MySQL requirement to the snort rc file.



Thank you SirDice for the reply. I don't understand what you mean. But I did the changes below in the snort rc.d. I change the 
	
	



```
mysql-server="YES"
```
 to NO in rc.conf file.


```
# PROVIDE: snort
# REQUIRE: DAEMON mysql-server
# BEFORE: LOGIN
# KEYWORD: shutdown
```

`"./usr/local/etc/rc.d/mysql-server onestart"`

This is error is gone:

```
snort[961]: FATAL ERROR: database: mysql_error: Can't connect to local MySQL server through socket
 '/tmp/mysql.sock' (2)
```

I think my problem is solved. Any idea?


----------



## SirDice (May 23, 2011)

That's the wrong way to solve it. Look at the rc script for MySQL. Look at the remarks at the top, look for the "PROVIDE". Note what it says. Then edit the rc file for snort and add that to the list of "REQUIRE". 

That should make sure MySQL is started before snort.


----------



## phoenix (May 24, 2011)

And double-check the ordering like so:
`$ rcorder /etc/rc.d/* /usr/local/etc/rc.d/*`


----------



## lezde716 (May 24, 2011)

Yes, it's fine now. Here is the current order:


```
rcorder: requirement `LOGIN' in file `/usr/local/etc/rc.d/squid' has no providers.
/usr/local/etc/rc.d/squid
rcorder: requirement `LOGIN' in file `/usr/local/etc/rc.d/mysql-server' has no providers.
/usr/local/etc/rc.d/mysql-server
rcorder: requirement `DAEMON' in file `/usr/local/etc/rc.d/snort' has no providers.
```


----------



## mix_room (May 24, 2011)

```
/usr/local/etc/rc.d/mysql-server.sh

# PROVIDE: mysql
# REQUIRE: LOGIN
# KEYWORD: shutdown
```

So you should add 


```
REQUIRE: mysql
```
to snort.sh.


----------

