~ubuntu-branches/ubuntu/trusty/postfix/trusty-proposed

« back to all changes in this revision

Viewing changes to examples/chroot-setup/Solaris2

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2005-02-27 09:33:07 UTC
  • Revision ID: james.westby@ubuntu.com-20050227093307-cn789t27ibnlh6tf
Tags: upstream-2.1.5
ImportĀ upstreamĀ versionĀ 2.1.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
umask 022
 
4
PATH=/usr/bin:/sbin:/usr/sbin
 
5
 
 
6
# Create chroot'd area under Solaris 2.5.1 for postfix.
 
7
#
 
8
# Dug Song <dugsong@UMICH.EDU>
 
9
 
 
10
if [ $# -ne 1 ]; then
 
11
  echo "Usage: `basename $0` <directory>, e.g.: /var/spool/postfix" ; exit 1
 
12
fi
 
13
 
 
14
CHROOT=$1
 
15
  
 
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}
 
20
fi
 
21
if [ ! -d ${CHROOT} -o "${CHROOT}" = "/" -o "${CHROOT}" = "/usr" ]; then
 
22
  echo "$0: bad chroot directory ${CHROOT}"
 
23
  exit 2
 
24
fi
 
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}
 
29
 
 
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
 
34
fi
 
35
 
 
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 {} \;
 
43
 
 
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/*
 
58
 
 
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
 
63
)
 
64
 
 
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/*
 
74
 
 
75
exit 0