#!/bin/sh
Technorati 的標籤:
FreeBSD Jail export mroot2=/home/mroot2 # the New mroot
export mroot=/home/mroot # the Origin mroot
export opt=opt # The MountPoint to sew skel with mroot
if [ ! -d $mroot2 ]; then mkdir $mroot2 ; fi
cd /usr/src
make installworld DESTDIR=$mroot2
cd $mroot2
chflags 0 /home/mroot2/var
rm -rfv etc home root tmp var usr/local usr/X11R6 usr/ports
if [ ! -d $opt ]; then mkdir $mroot2/$opt ;fi
for dirs in etc home root tmp var
do
echo " ln -s /opt/$dirs $dirs"
ln -s $opt/$dirs $dirs
done
ln -s ../$opt/usr-local usr/local
ln -s ../$opt/usr-X11R6 usr/X11R6
ln -s ../$opt/usr-ports usr/ports
cd /
ls /var/run | grep jail | sed -e 's/jail_//g' -e 's/\.id//g' |xargs > /tmp/jlist$$
/etc/rc.d/jail stop `cat /tmp/jlist$$`
for mounted in `cat /etc/fstab | grep nullfs | grep -v ^# | awk '{print $2 }' | sort -r `
do
echo umount $mounted
umount $mounted
done
echo " You should make sure the FileSystem Umount properly."
cat /etc/fstab
echo " Now a Subshell for you th Umount Filesystem manually."
echo " If this fails too, you might take a reboot, "
echo " and Move mroot2 to mroot by hand."
/bin/sh
df
echo " You should have made sure the FileSystem Umounted properly."
echo " Or press [Ctrl C] to stop in 7 seconds"
sleep 8
mv $mroot $mroot.bak
mv $mroot2 $mroot
mount -a
/etc/rc.d/jail start `cat /tmp/jlist$$`
rm /tmp/jlist.$$
echo “ Take a check. “