File: setup-chrootdir-template.sh

package info (click to toggle)
libpam-chroot 0.9-3
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 132 kB
  • ctags: 52
  • sloc: ansic: 740; sh: 104; makefile: 50
file content (48 lines) | stat: -rw-r--r-- 826 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh

# Copyright (C) 2002  Andres Salomon <dilinger@voxel.net>
#
# Template for setup-chrootdir-XX.sh scripts

PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin"
# Directories to include in the chroot go here
DIRECTORIES="bin dev "
# Files to copy over to the chroot are included here
FILES="bin/false lib/libc.so.6 lib/ld-linux.so.2"

if test -z "$1"; then
	echo "Usage: $0 <directory>" 1>&2
	exit 1
fi

id=`id -u`
if test "$id" -gt 0; then
	echo "Error: this script requires root (for mknod)!" 1>&2
	exit 1
fi

dir=$1
curdir=`pwd`

# Create directory structure
mkdir -p $dir
cd $dir
for d in $DIRECTORIES; do
	mkdir -p $d
done

# Add files
for f in $FILES; do
	cp /$f $f
done

# And devices..
if test -d dev; then
	cp /dev/MAKEDEV dev
	cd dev && ./MAKEDEV std && rm -f MAKEDEV
fi


cd $curdir

exit 0