#!/bin/sh # jailsetup.sh 0.2.1 (10/Dec/2003). http://jbc.fi/ # Jail setup script for FreeBSD 5.1-RELEASE # By JB Consulting Oy Ab / Jani Reinikainen [ jani (at) jbc (dot) fi ] # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. if [ x"$1" = x ] then echo Usage: $0 [ip] echo example: $0 10.0.0.20 exit fi D=/var/jail/$1 if [ -f $D ]; then echo Error: A file has the same name as the destination. exit fi if [ ! -d /usr/src/sys ]; then echo Error: Cannot find sources at /usr/src/! Are they installed? exit fi # There's a lot of unneccessary stuff compiled in by default. # Let's discard some we don't need. See man make.conf(5). if [ ! -f /etc/make.jail.conf ]; then cat < /etc/make.jail.conf CFLAGS= -O -pipe COPTFLAGS= -O -pipe NO_KERBEROS=true NO_BIND=true NO_FORTRAN=true NO_CVS=true NO_I4B=true NO_IPFILTER=true NO_LPR=true NO_MAILWRAPPER=true NO_MAKEDEV=true NO_OBJC=true NO_SENDMAIL=true NO_SHAREDOCS=true NO_X=true NO_GDB=true NO_MODULES=true NO_TCSH=true NOMAN=true NOGAMES=true NOINFO=true NOPROFILE=true EOF fi if [ ! -d $D ]; then /bin/mkdir -p $D fi # http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html # "You can speed up the ``make world'' process, and possibly save yourself # some dependency headaches by removing /usr/obj as well." if [ -d /usr/obj ]; then cd /usr/obj chflags -R noschg * rm -rf * fi # Make the jail. See man jail(8). cd /usr/src make -j4 world DESTDIR=$D __MAKE_CONF="/etc/make.jail.conf" cd etc make distribution DESTDIR=$D NO_MAKEDEV=yes __MAKE_CONF="/etc/make.jail.conf" mount_devfs devfs $D/dev cd $D ln -sf dev/null kernel chmod 666 $D/dev/null touch $D/etc/fstab mkdir $D/usr/ports cp /etc/resolv.conf $D/etc/resolv.conf cp /stand/sysinstall $D/stand/sysinstall # Genereate $D/etc/rc.conf cat < $D/etc/rc.conf rpcbind_enable="NO" cron_enable="NO" syslogd_enable="NO" inetd_enable="NO" sendmail_enable="NONE" network_interfaces="" EOF