[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Problem with chrooted Etch



andy baxter wrote:


#!/bin/bash
#
# testing-shell - start a root shell chrooted to the testing release.
#                 must be run as root

JAIL_ROOT=/jail # modify this to point to your chrooted directory.
PROGRAM=$0

if [ `id -u` -ne 0 ] ; then
  echo "Must be run as root"
  exit
  fi

if [ `ps ax | grep $PROGRAM | grep -v grep | wc -l` -gt 2 ] ; then
  # n.b. -gt 2 above is because the process forks so you get 2 lines
in the output.
  echo "${PROGRAM##*/} seems to be running already - not preparing the
chrooted system."
else
  echo "Preparing the chrooted system..."
  mount /dev $JAIL_ROOT/dev -o bind
correction - should be -'... -o rbind'
  mount proc -t proc $JAIL_ROOT/proc
  mount /tmp/.X11-unix $JAIL_ROOT/tmp/.X11-unix -o bind
  cp /tmp/.X0-lock $JAIL_ROOT/tmp
  fi
cp /etc/hosts $JAIL_ROOT/etc/hosts
echo "--- entering chrooted system --->"
echo

chroot $JAIL_ROOT /bin/bash

if [ `ps ax | grep $PROGRAM | grep -v grep | wc -l` -gt 2 ] ; then
  echo "${PROGRAM##*/} still running - not taking down chrooted system."
else
  # last one out clean up...
  echo "Taking down the chrooted system..."
  umount $JAIL_ROOT/dev
  umount $JAIL_ROOT/proc
  umount $JAIL_ROOT/tmp/.X11-unix
  rm $JAIL_ROOT/tmp/.X0-lock
  fi
echo "<--- returned to root system ---"
echo






Reply to: