All pastes #1742381 Raw Edit

clueless

public text v1 · immutable
#1742381 ·published 2010-01-08 06:08 UTC
rendered paste body
#!/bin/bash ######################################################### This is a simple script to create a chroot# You'll have to run#	#	chroot /path/to/chroot </bin/bash>## after this script exits. # written by Norbert Varzariu <loomsen@googlemail.com>######################################################## has to be run as root, so lets check[[ $UID == 0 ]] && : || (echo "you have to be root";exit 1)_MNTPART=_CHROOTDIR=set -x function mount-defaults {mount "$_MNTPART" "$_CHROOTDIR"mount -t proc none $_CHROOTDIR/procmount -t sysfs none $_CHROOTDIR/sysmount --bind /dev $_CHROOTDIR/devmount --bind /dev/pts $_CHROOTDIR/dev/ptsmount --bind /dev/shm $_CHROOTDIR/dev/shm}function unchroot{umount $_CHROOTDIR/dev/shmumount $_CHROOTDIR/dev/ptsumount $_CHROOTDIR/devumount $_CHROOTDIR/sysumount $_CHROOTDIR/procumount $_CHROOTDIR}if [ "$1" == "" ]; then	echo "usage: \"$0\" /path/to/partition <path-to-chroot>"	exit $?else    	case "$1" in		/dev/[sh]d* )       		        _MNTPART="$1"             		if [ "$2" == "" ]; then _CHROOTDIR="/chroot"; else _CHROOTDIR="$2";fi			export _CHROOTDIR _MNTPART				        ;;		"clean"|"-c"|"--clean" )			[[ "$2" != "" ]] && _CHROOTDIR="$2" || _CHROOTDIR="/chroot"			unchroot			exit $?                                        ;;       	esac	mount-defaults	unset _CHROOTDIR _MNTPARTfiexit $?