0

This is CentOS 6.6 server with GUI. I have place my startup commands in /etc/rc.local The service running on this server are Docker and Nginx. So I have put Container start up command with port mapping in rc.local.

The Docker Containers are starting but on Server I am not getting GUI, only CLI is coming, if I comment all the commands in rc.local then GUI is coming after reboot.

The rc.local file contains...

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

sysctl net.ipv4.conf.all.forwarding=1
sleep 5
setenforce Permissive
sleep 5
iptables -F
sleep 5
service nginx stop
sleep 5
service nginx start
sleep 5
service docker stop
sleep 5
service docker start
sleep 5
docker stop $(docker ps -a -q)
sleep 5
docker rm $(docker ps -a -q)
sleep 5
docker run -p port:port/tcp -d memcached:latest
sleep 5
docker run -d  -v /mnt/path:/mnt/path -p port:port/tcp   imagename
sleep 5
docker run -d  -p port:port/tcp -p port:port/udp imagename
sleep 5
mount -t nfs 192.168.0.3:/mnt/path/ /mnt/path/
MadHatter
  • 79,770
  • 20
  • 184
  • 232
  • What is all that doing there? None of that belongs in rc.local! Set up your services and mount points in the normal method. – Michael Hampton Jul 02 '15 at 05:17
  • I want to achieve something which will automatically starts my services on reboot....the simplest thing which I found on google was to place in rc.local – nikhil singh Jul 02 '15 at 11:45
  • 90% of the tutorials in the Internet are wrong or have bad advice. You read one such page. You automatically start a service at boot by enabling it, e.g. `chkconfig nginx on`. – Michael Hampton Jul 02 '15 at 14:44
  • What if I want to start other things than any service like a docker container after reboot – nikhil singh Jul 03 '15 at 05:09
  • having same issue as http://serverfault.com/questions/482860/centos-stopped-loading-after-i-added-something-to-etc-rc-d-rc-local – nikhil singh Jul 03 '15 at 05:22

1 Answers1

1

Something in your rc.local isn't terminating. Execution of this file has to finish before the regular boot process completes, and X is started.

Since you say the docker containers all start up, my guess would be the mount line isn't completing for some reason. Confirm that it isn't, find out why, and fix it. Better yet, move all that stuff out of rc.local and into proper startup files, as Michael recommends, not least because all those sleeps will make boot take a minute longer than it should.

MadHatter
  • 79,770
  • 20
  • 184
  • 232