Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Jan 2002 16:25:35 PST
From:      Keith Farrar <farrar@parc.xerox.com>
To:        Henk Wevers <henk@wevers.org>
Cc:        freebsd-isp@freebsd.org, <freebsd-stable@freebsd.org>
Subject:   Re: jail() management scripts
Message-ID:  <Pine.WNT.4.41.0201131606510.1352-100000@dilbert.homenat.farrar.org>
In-Reply-To: <3C421228.9060904@wevers.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 13 Jan 2002, Henk Wevers wrote:
>
> I have added some perl scripts to make management to a multiple jail
> enviorement somewhat more easy.
> http://jailnotes.cg.nu/scripts/
>
> If you have some scripts please mail me, then i will add then to the site.
>
> Henk Wevers

#!/bin/sh
## @(#) Startup a jail chroot environment -Keith Farrar <farrar@parc.xerox.com>
## @(#)  jailbait.parc.xerox.com:/usr/local/etc/rc.d/jail-script.sh
## Conventions:
## My jails have neither console nor network logins, so I feed the
##  shell argument of this script to manage jailed accounts and services.
## In normal usage, I create one instance of this script per jailed
##  service, named /usr/local/etc/rc.d/jail-${JAILIPPADDR}.sh
## Each jail file system is rooted at /local/jail/${JAILIPPADR}/
##	-keith


JAILHOSTNAME="jailbait.parc.xerox.com"
JAILIPPADDR="10.10.10.11"
JAILTOPDIR="/local/jail"

case "$1" in
start)
        echo  Starting jail-${JAILIPPADDR}
        /usr/sbin/jail ${JAILTOPDIR}/${JAILIPPADDR} \
		${JAILHOSTNAME} ${JAILIPPADDR} \
                   /bin/sh /etc/rc
        ;;

shell)
        echo  Starting jail-${JAILIPPADDR}
        /usr/sbin/jail ${JAILTOPDIR}/${JAILIPPADDR} \
		${JAILHOSTNAME} ${JAILIPPADDR} \
                   /bin/tcsh
        ;;

##      Jailed procs are in the output of the command:
##      "egrep $JAILHOSTNAME /proc/*/status | awk -F/ '{print $3}'"

list)
        pids=`/usr/bin/egrep $JAILHOSTNAME /proc/*/status | /usr/bin/awk -F/ '{print $3}'`
        echo Jailed process PIDs: $pids
        ;;

stop)
        echo  Stopping jail-${JAILIPPADDR}
        pids=`/usr/bin/egrep $JAILHOSTNAME /proc/*/status | /usr/bin/awk -F/ '{print $3}'`
        /bin/kill -TERM $pids
        ;;

restart)
        /bin/sh $0 stop
        sleep 1
        /bin/sh $0 start
        ;;

*)
        echo "Usage: `basename $0` {start|stop|restart|shell|list}" >&2
        ;;
esac

exit 0


| Keith Farrar | Xerox Palo Alto Research Center (PARC) | Palo Alto, CA |


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-isp" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.WNT.4.41.0201131606510.1352-100000>