[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Rebooting jails


I'm currently looking for a standardized way to 'reboot' jails from within. 'shutdown' is a simple one, just issue 'kill -TERM -1' and you're done.

Now, rebooting generally involves starting up the jail afterwards.

One way that works from a shell started via jexec would be to 'kill -TERM -1' all processes and execve into whatever is supposed to be the kickoff command, e.g. /bin/sh /etc/rc. However, doing this from a shell that has been run from sshd results in killing the sshd and thus the shell trying to restart the jail.

Another way would be to have a daemon waiting in the host system that is checking jids in /var/run/jail_*.id say all 5 Minutes and if pgrep returns anything than 0, the jail is being restarted (you may combine that with some conditions, say having a file '/.rebootme' under jail's root directory).

This approach is more a watchdog than a reboot mechanism, you would need to do unintuitive stuff like adding a line to crontab (where it would even run if no jails are active, which sucks). One could use an 'at +5m $prefix/bin/watchdog' in the script that starts the jail in the first place which calls itself the same way.

All this is annoying to track, a watchdog script sleeping in the background would more easily be visible in ps. And, waiting for the host system to finally rerun to jail may cost many boring admin-5min-periods.

Maybe someone can help me out with a cool idea.