Date: Mon, 14 Jan 2002 08:18:15 +0100 From: dirk.meyer@dinoex.sub.org (Dirk Meyer) To: henk@wevers.org, freebsd-isp@freebsd.org, freebsd-stable@freebsd.org Subject: Re: jail() management scripts Message-ID: <AcJiXyzW83@dmeyer.dinoex.sub.org> References: <3C421228.9060904@wevers.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi Henk Wevers,
> If you have some scripts please mail me, then i will add then to the site.
you asked :)
I use some more jails, and create them in a configuration file.
kind regards Dirk
- Dirk Meyer, Im Grund 4, 34317 Habichtswald, Germany
#
# /usr/local/etc/jail.conf
#
# Format:
# dir hostname IP-Addr
#
jail1 name1.do.main 10.6.200.201
#jail2 inaktiv.do.main 10.6.200.202
#
# eof
/usr/local/etc/rc.d/jail.sh:
#!/bin/sh
# (c) 2002 Dirk Meyer, under FreeBSD License
#
# Thanks to:
# - Gregory Neil Shapiro for the "killjail" function.
# - Keith Farrar for the "list" and "restart" target.
#
case $1 in
start)
grep -v "^#" /usr/local/etc/jail.conf |
while read dir name ip
do
echo "starting ... ${ip} ${name}"
jail "${dir}" "${name}" "${ip}" /bin/sh /etc/rc
done
exit 0
;;
stop)
grep -v "^#" /usr/local/etc/jail.conf |
while read dir name ip
do
echo "stopping ... ${ip} ${name}"
pids=`grep -l " ${name}\$" /proc/*/status |
awk -F/ '{print $3}'`
kill -TERM $pids
done
exit 0
;;
list)
grep -v "^#" /usr/local/etc/jail.conf |
while read dir name ip
do
pids=`grep -l " ${name}\$" /proc/*/status |
awk -F/ '{print $3}'`
echo "processes for ${ip} ${name}:" $pids
done
exit 0
;;
restart)
sh $0 stop
seep 1
sh $0 start
;;
*)
echo "usage: `basename $0` {start|stop|list|restart}" >&2
exit 64
;;
esac
#
# eof
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AcJiXyzW83>
