My interesting problem is that when running some rc.d scripts they do not actually drop back to the root shell, but leave me at an intermediate shell as the user they're supposed to be running as.

A side effect is that the desired service doesn't actually start until I exit from this inner shell. See below:

[root@zeb2 /usr/local/etc/rc.d]# ./mysql-server  start
Starting mysql.
[mysql@zeb2 /usr/local/etc/rc.d]$ ps ax |grep mysql
 3352   0  S        0:00.01 /bin/sh ./mysql-server start
 3357   0  S        0:00.01 su -m mysql -c sh -c "/usr/sbin/daemon  -c -f /usr/local/bin/mysqld_safe --defaults-extra-file=/var/db/mysq
 3358   0  S        0:00.01 _su -m -c sh -c "/usr/sbin/daemon  -c -f /usr/local/bin/mysqld_safe --defaults-extra-file=/var/db/mysql/my.
 3364   0  R+       0:00.00 grep mysql
[mysql@zeb2 /usr/local/etc/rc.d]$ exit
[root@zeb2 /usr/local/etc/rc.d]# ps ax |grep mysql
 3366  ??  Ss       0:00.02 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/var/db/mysql/my.cnf --user=mysql --datadir=/var/d
 3636  ??  S        0:00.13 [mysqld]
 3639   0  S+       0:00.00 grep mysql
[root@zebes2 /usr/local/etc/rc.d]#

It's almost like there is some wierdness with the su command that is the problem. This doesn't happen on every port I've installed, but happens for both MySQL and SABNzbd. This also causes a problem if the server needs to reboot and I've left the service enabled in rc.conf as it will enter the inner shell and hang the boot until I can login locally and type exit.

[root@zeb2 /usr/local/etc/rc.d]# uname -a
FreeBSD xxx.xxx.xxx.net 9.0-RELEASE-p3 FreeBSD 9.0-RELEASE-p3 #0: Tue Jun 12 01:47:53 UTC 2012     root@i386-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  i386

Updated with rc.conf output below

[root@zeb2 /usr/bin]# cat /etc/rc.conf |grep -v '#'
syslogd_flags="-a dd-wrt.om.cox.net:* -vv"
ifconfig_em0="inet  netmask"

Update 2 with outputs requested

Output of sh -x mysql-server start

Package List

Contents of mysql-server

Update 3 with answer!

@Steve Wills got me looking in the right direction. The ultimate cause was because I was invoking the bash shell from the end of .cshrc for the root account. This file must get parsed when running su through the rc.d scripts and the added reference to another shell explains why it would sit and wait for me to exit. After removing the reference, the rc.d scripts began working as expected.



Can you share your /etc/rc.conf and/or /etc/rc.conf.local? Perhaps there's something in there that you've set that's causing this. Also, try running it as "service mysql-server start" and see if the same thing happens?

  • rc.conf added, no rc.conf.local on my system – Josh W. Mar 3 '13 at 7:19
  • running 'service mysql-server start' gave me the same exact behavior, I've got to quit the inner shell to get it to complete.. – Josh W. Mar 3 '13 at 7:21
  • I was asking that you share the contents of the rc.conf to check for anything odd there. – Steve Wills Mar 3 '13 at 20:41
  • I already updated my question above with the rc.conf contents – Josh W. Mar 4 '13 at 0:04
  • 1
    And there's your problem. Don't do that. Don't change root's shell. Don't use root's shell. Use your own shell and sudo. – Steve Wills Mar 6 '13 at 16:41

The su(1) command changes into the user given or runs the command given as the given user. Without looking at the script, there is no way of knowing what is going on. Presumably the script just doesn't end, or keeps around waiting for something. Perhaps the script is broken, perhaps it is waiting fr something that just takes a long time (more than your patience). Is there some wrapper you are supposed to use to run those scripts? (My Fedora had system start some-service for this).

  • Init scripts on FreeBSD are completely different than on Fedora. – Steve Wills Mar 2 '13 at 22:59
  • @SteveWills I know, I ran BSD systems for many years. That is why I asked if there is a wrapper of sorts. Other that that, I don't see where my answer is wrong. You answer essentially the same... – vonbrand Mar 2 '13 at 23:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.