0

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
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"
sshd_enable="YES"
ifconfig_em0="inet 192.168.1.3  netmask 255.255.255.0"
defaultrouter="192.168.1.1"
hostname="zeb2.om.cox.net"
webmin_enable="YES"
samba_enable="YES"
uuidd_enable="YES"
denyhosts_enable="YES"
inetd_enable="YES"
mysql_enable="YES"

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.

Thanks!!

Josh W.
  • 121
  • 6

2 Answers2

3

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?

Steve Wills
  • 685
  • 3
  • 6
  • rc.conf added, no rc.conf.local on my system – Josh W. Mar 03 '13 at 07: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 03 '13 at 07:21
  • I was asking that you share the contents of the rc.conf to check for anything odd there. – Steve Wills Mar 03 '13 at 20:41
  • I already updated my question above with the rc.conf contents – Josh W. Mar 04 '13 at 00:04
  • Well, there's nothing obvious. How about two more pieces of info, the pkg list, so I can see what versions of things you have installed, output of sh -x mysql-server start and maybe even a copy of the script for good measure. – Steve Wills Mar 04 '13 at 20:54
  • Update the question above with all 3 – Josh W. Mar 05 '13 at 15:40
  • Did you change root's shell? – Steve Wills Mar 05 '13 at 22:38
  • Forgot to ask one of the most important questions, what version on FreeBSD are you on? – Steve Wills Mar 06 '13 at 03:55
  • FreeBSD 9.0-RELEASE-p3 (output of uname is in the question above) I upgraded to 9.0 from 7.2 (I think, can't exactly recall the previous version it's been so long) – Josh W. Mar 06 '13 at 14:16
  • And yes, I changed root's shell. It's set to csh, but at the bottom of .cshrc I invoke bash as I prefer to work in bash. I did this because I once was hosed when a bash update failed leaving it unusable and when I had root's shell set to it, it caused me some grief until I was able to login in single user to fix it.. – Josh W. Mar 06 '13 at 14:19
  • 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 06 '13 at 16:41
-1

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).

vonbrand
  • 1,149
  • 2
  • 8
  • 16
  • Init scripts on FreeBSD are completely different than on Fedora. – Steve Wills Mar 02 '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 02 '13 at 23:02