[clug] init.d for chroot

jm jeffm at ghostgun.com
Wed Jul 12 04:44:54 UTC 2017


Due to a package clash between one version of a program used to support
other hosts that has to run on this host and the one used to support
this host I've set up a chrooted environment. I'm to the stage where I'm
trying to start it from an init.d script - This is a CentOS 6 (yes, 6)
box. The init.d script needs to start supervisord within the chroot
which will then watch over the few processes that need to run chrooted
for this to work. The problem here is that I can't work out how to get
the pid of the chrooted process to record it later for the stop part of
the script. I can't kill it be name via killproc as there is already a
supervisord process on the host.

The the key parts of the script in skeleton form at the moment is,

start () {
  echo -n $"Starting chrootname supervisord: "
  chroot /chrootpath /usr/bin/supervisord -c /etc/supervisord.conf
  # Store pid of supervisord
  RETVAL=$?
  echo
  [ $RETVAL -eq 0 ] && touch /var/lock/subsys/chrootname-supervisord
}

stop () {
  echo -n $"Stopping chrootenv supervisord: "
  # Get stored pid and kill process
}

Does anyone have any experience with scripts like this or thoughts on
how to do this? I'm currently think about putting a wrapper around
supervisor that runs in the chroot env to record the pid in the chroot env.

Jeff.





More information about the linux mailing list