Fix up mix of man(7)/mdoc(7).
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / examples / chroot-setup / Solaris2
blob024492cc3c117edba218d432172b389c83b3c0ae
1 #!/bin/sh
3 umask 022
4 PATH=/usr/bin:/sbin:/usr/sbin
6 # Create chroot'd area under Solaris 2.5.1 for postfix.
8 # Dug Song <dugsong@UMICH.EDU>
10 if [ $# -ne 1 ]; then
11 echo "Usage: `basename $0` <directory>, e.g.: /var/spool/postfix" ; exit 1
14 CHROOT=$1
16 # If CHROOT does not exist but parent does, create CHROOT
17 if [ ! -d ${CHROOT} ]; then
18 # lack of -p below is intentional
19 mkdir ${CHROOT}
21 if [ ! -d ${CHROOT} -o "${CHROOT}" = "/" -o "${CHROOT}" = "/usr" ]; then
22 echo "$0: bad chroot directory ${CHROOT}"
23 exit 2
25 for dir in etc/default etc/inet dev usr/lib usr/share/lib/zoneinfo ; do
26 if [ ! -d ${CHROOT}/${dir} ]; then mkdir -p ${CHROOT}/${dir} ; fi
27 done
28 #chmod -R 755 ${CHROOT}
30 # AFS support.
31 if [ "`echo $CHROOT | cut -c1-4`" = "/afs" ]; then
32 echo '\tCreating memory resident /dev...'
33 mount -F tmpfs -o size=10 swap ${CHROOT}/dev
36 # Setup /etc files.
37 cp /etc/nsswitch.conf ${CHROOT}/etc
38 cp /etc/netconfig /etc/resolv.conf ${CHROOT}/etc
39 cp /etc/default/init ${CHROOT}/etc/default
40 cp /etc/inet/services ${CHROOT}/etc/inet/services
41 ln -s /etc/inet/services ${CHROOT}/etc/services
42 find ${CHROOT}/etc -type f -exec chmod 444 {} \;
44 # Most of the following are needed for basic operation, except
45 # for libnsl.so, nss_nis.so, libsocket.so, and straddr.so which are
46 # needed to resolve NIS names.
47 cp /usr/lib/ld.so /usr/lib/ld.so.1 ${CHROOT}/usr/lib
48 for lib in libc libdl libintl libmp libnsl libsocket libw \
49 nss_nis nss_nisplus nss_dns nss_files; do
50 cp /usr/lib/${lib}.so.1 ${CHROOT}/usr/lib
51 rm -f ${CHROOT}/usr/lib/${lib}.so
52 ln -s ./${lib}.so.1 ${CHROOT}/usr/lib/${lib}.so
53 done
54 cp /usr/lib/straddr.so.2 ${CHROOT}/usr/lib
55 rm -f ${CHROOT}/usr/lib/straddr.so
56 ln -s ./straddr.so.2 ${CHROOT}/usr/lib/straddr.so
57 chmod 555 ${CHROOT}/usr/lib/*
59 # Copy timezone database.
60 (cd ${CHROOT}/usr/share/lib/zoneinfo
61 (cd /usr/share/lib/zoneinfo; find . -print | cpio -o) | cpio -imdu
62 find . -print | xargs chmod 555
65 # Make device nodes. We need ticotsord, ticlts and udp to resolve NIS names.
66 for device in zero tcp udp ticotsord ticlts; do
67 line=`ls -lL /dev/${device} | sed -e 's/,//'`
68 major=`echo $line | awk '{print $5}'`
69 minor=`echo $line | awk '{print $6}'`
70 rm -f ${CHROOT}/dev/${device}
71 mknod ${CHROOT}/dev/${device} c ${major} ${minor}
72 done
73 chmod 666 ${CHROOT}/dev/*
75 exit 0