I am writing a program that does server management on remote systems. While I can run almost all commands using the:
$ chroot <directory> /bin/bash -c <command>
format and get the results back, starting and stopping the services or getting their status aren't possible because of the systemctl restrictions.
I have tried the options offered in these:
They're either long winding or not a simple solution like the one chroot /bin/bash -c offers.
I'm on a CentOS machine with systemctl 2.19 and there is no --shell option via machinectl. Is there a simple chroot <> /bin/bash like shortcut to run start/stop/restart the services running inside the chroot environment?
For e.g., OpenLDAP's solserver service runs inside the chroot. How do I get the output of systemctl status solserver from the host without logging into the container?