From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 24 17:45:08 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9097116A4DD for ; Mon, 24 Jul 2006 17:45:08 +0000 (UTC) (envelope-from erdgeist@erdgeist.org) Received: from elektropost.org (elektropost.org [80.237.196.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9951A43D45 for ; Mon, 24 Jul 2006 17:45:07 +0000 (GMT) (envelope-from erdgeist@erdgeist.org) Received: (qmail 90589 invoked by uid 0); 24 Jul 2006 17:44:08 -0000 Received: from erdgeist.org (erdgeist@erdgeist.org@80.237.196.15) by elektropost.org with AES256-SHA encrypted SMTP; 24 Jul 2006 17:44:08 -0000 Date: Mon, 24 Jul 2006 19:44:07 +0200 (CEST) From: Dirk Engling To: freebsd-hackers@freebsd.org Message-ID: <20060724192149.O46542@erdgeist.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: ezjail@erdgeist.org Subject: Rebooting jails X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Jul 2006 17:45:08 -0000 Hello, 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. Regards erdgeist