From owner-freebsd-hackers@FreeBSD.ORG Sat May 22 18:18:36 2004 Return-Path: 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 668E016A4CE for ; Sat, 22 May 2004 18:18:36 -0700 (PDT) Received: from siue.dnsalias.net (11spidialup76.famvid.com [208.5.212.76]) by mx1.FreeBSD.org (Postfix) with ESMTP id D266A43D39 for ; Sat, 22 May 2004 18:18:34 -0700 (PDT) (envelope-from wgrim@siue.edu) Received: from siue.edu (persephone.bsdaemon.org [192.168.0.101]) by siue.dnsalias.net (Postfix) with ESMTP id E7892233D10 for ; Sat, 22 May 2004 20:19:32 -0500 (CDT) Message-ID: <40AFFC24.6050501@siue.edu> Date: Sat, 22 May 2004 20:19:32 -0500 From: "William M. Grim" Organization: SIUE User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031107 Debian/1.5-3 X-Accept-Language: en MIME-Version: 1.0 To: hackers@freebsd.org References: <40AFF8B3.40009@siue.edu> In-Reply-To: <40AFF8B3.40009@siue.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: Jails: An rc.d script X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 May 2004 01:18:36 -0000 Very odd, my jails.sh script was not allowed to pass or something. So, I'm pasting it into this email. #!/bin/sh # # Start the jails at boot-up. # The only jails it can start properly are the ones in directories labelled # with an IP address. JAILBASE=/usr/local/var/jail LS="/bin/ls" JLS="/usr/sbin/jls" AWK="/usr/bin/awk" GREP="/usr/bin/grep" HOST="/usr/bin/host" MOUNT="/sbin/mount" UMOUNT="/sbin/umount" SH="/bin/sh" JAIL="/usr/sbin/jail" KILLALL="/usr/bin/killall" start_jails() { for JAILIP in `${LS} -1 ${JAILBASE}`; do ${MOUNT} -t devfs devfs ${JAILBASE}/${JAILIP}/dev ${MOUNT} -t procfs proc ${JAILBASE}/${JAILIP}/proc JAILHOST=`${HOST} ${JAILIP} | ${AWK} '{ print $5; }'` ${JAIL} ${JAILBASE}/${JAILIP} ${JAILHOST} ${JAILIP} ${SH} /etc/rc done } stop_jails() { echo "Even though you are stopping the jails, the JID may show up" echo "when doing \`jls\`. This is most likely because some connections" echo "are waiting to timeout." for JID in `${JLS} | ${GREP} -v JID | ${AWK} '{ print $1; }'`; do ${KILLALL} -j ${JID} echo "Killing JID: ${JID}" done for JAILIP in `\ls -1 ${JAILBASE}`; do ${UMOUNT} -f ${JAILBASE}/${JAILIP}/proc ${UMOUNT} -f ${JAILBASE}/${JAILIP}/dev done } case "$1" in start) start_jails ;; restart) stop_jails sleep 1 start_jails ;; stop) stop_jails ;; esac Thanks again, and sorry for the confusion. William M. Grim wrote: > Hi! > > I've written an rc.d script that can start/stop/restart jails, if they > follow a certain pattern of setup. I'm strongly considering the > placement of this in ports or base (ports seems most appropriate). > > Basically, if you have jails in /usr/local/var/jail/, my script > can start it up automatically, as long as the IP is reachable by > `host` (I know, it requires a little more work to remove this > dependency for 192.168. addresses, etc). > > However, I was wondering if anyone would want to test it? All you > have to do is take my attached script and place it in > /usr/local/etc/rc.d/. If you have your jails located somewhere else, > then edit the JAILBASE= line in the script. > > I would appreciate any constructive criticism about this script so > that I can make it better. If you have any improvements you make, > feel free to send them to me as well. I'll attempt to make it better > over time and to write a man page for it. > > Many thanks. > >------------------------------------------------------------------------ > >_______________________________________________ >freebsd-hackers@freebsd.org mailing list >http://lists.freebsd.org/mailman/listinfo/freebsd-hackers >To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" > > -- William Michael Grim Student, Southern Illinois University at Edwardsville Unix Network Administrator, SIUE, Computer Science dept. Phone: (217) 341-6552 Email: wgrim@siue.edu