]>
git.saurik.com Git - apple/network_cmds.git/blob - newclient.tproj/newclient.csh
3 # Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
5 # @APPLE_LICENSE_HEADER_START@
7 # "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
8 # Reserved. This file contains Original Code and/or Modifications of
9 # Original Code as defined in and that are subject to the Apple Public
10 # Source License Version 1.0 (the 'License'). You may not use this file
11 # except in compliance with the License. Please obtain a copy of the
12 # License at http://www.apple.com/publicsource and read it before using
15 # The Original Code and all software distributed under the License are
16 # distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 # EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 # INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 # FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
20 # License for the specific language governing rights and limitations
23 # @APPLE_LICENSE_HEADER_END@
28 # NetBoot client building script.
30 # Copyright (c) 1988, NeXT, Inc.
33 # "newclient -p DISKTYPE TEMPLATE DEST" Standalone Private
34 # "newclient [-s SERVER] CLIENT-1 ... CLIENT-n" Clients
40 set path
=(/bin
/usr
/bin
/usr
/ucb
/usr
/etc
/etc
)
42 set CLIENTDIR
=${TESTDIR}/clients
43 set template
=${TESTDIR}/usr
/template
/client
44 set HOSTFILE
=${TESTDIR}/etc
/hosts
45 set BOOTPTAB
=${TESTDIR}/etc
/bootptab
47 # We are the default server
51 if ( `whoami` != root
) then
52 echo "You must be root to run $0"
56 # Preliminary argument checkout
57 if ( $#argv < 1 ) then
61 # Switches must be at argv[1]
62 foreach arg
( $argv[2-] )
63 if ( x
$arg =~ x
-* ) then
69 if ( $argv[1] == -p || $argv[1] == -P ) then
70 if ( $#argv != 4 ) then
77 if ( $argv[1] == -P ) then
83 # Check that the disk type is valid
84 if ( ! -e $template/etc
/fstab.
$disktype ) then
85 echo "Unknown disk type" $disktype
88 else if ( $argv[1] == -s ) then
89 if ( $#argv < 3 ) then
95 else if ( $argv[1] =~
-* ) then
99 # Make sure we have a template to work with
100 if ( ! -d $template ) then
101 echo "New client template $template does not exist"
105 # Process the private partition if that is the mode we are in.
106 if ( $?PrivateMode
) then
108 echo "$dest already exists"
112 # Create the destination directory
113 echo -n "Creating ${dest}..."
116 chown root.staff
$dest
117 if ( $status != 0 ) then
123 # Copy the template into it
124 echo -n "Copying ${template} into ${dest}..."
125 (cd $template; tar cf
- .
)|(cd $dest; tar xpBf
-)
128 # Make the device files
129 echo -n "Making devices in ${dest}/dev..."
130 (cd ${dest}/dev
; /usr
/etc
/MAKEDEV NeXT
)
133 # Customize the fstab file
134 echo -n "Installing fstab.$disktype as ${dest}/etc/fstab..."
135 cp -p $dest/etc
/fstab.
${disktype} $dest/etc
/fstab
136 if ( $status != 0 ) then
142 # Touch the first 16 Meg of the swapfile
143 echo -n "Preallocating swapfile blocks..."
144 (cd ${dest}/vm
; /bin
/rm -f swapfile
; /usr
/etc
/mkfile
$swapsize swapfile
)
151 # If we get here, then we are building a list of clients
155 foreach client
( $argv[*] )
156 if ( $server == localhost
) then
157 echo "This machine can't be a server until it is given a hostname"
160 set dest
=$CLIENTDIR/$client
162 if (! -f /private
/tftpboot
/mach
) then
163 echo Installing
/private
/tftpboot
/mach
164 cp -p /mach
/private
/tftpboot
/mach
166 if (! -f /private
/tftpboot
/boot
) then
167 echo Installing
/private
/tftpboot
/boot
168 cp -p /usr
/standalone
/boot
/private
/tftpboot
/boot
171 # Check for already existing client directory
173 echo $dest already exists
177 # Create the destination directory
178 echo -n "Creating $dest..."
180 chown root
:staff
$dest
181 if ( $status != 0 ) then
187 # Copy the template into it.
188 echo -n "Copying $template into ${dest}..."
189 (cd $template; tar cf
- .
)|(cd $dest; tar xpBf
-)
192 # Make the device files
193 echo -n "Making devices in ${dest}/dev..."
194 (cd $dest/dev
; /usr
/etc
/MAKEDEV NeXT
)
197 # Customize the fstab file
198 echo -n "Installing fstab.client as ${dest}/etc/fstab..."
199 cp -p $dest/etc
/fstab.client
$dest/etc
/fstab
200 sed -e "s/SERVER/$server/g" -e "s/CLIENT/$client/g" $dest/etc
/fstab.client
> $dest/etc
/fstab
201 if ( $status != 0 ) then
207 # Set up a symbolic link to the kernel
209 if (-f ${dest}/tftpboot
/mach
) then
210 echo -n "Removing ${dest}/tftpboot/mach "
211 rm ${dest}/tftpboot
/mach
215 echo -n "Linking /tftpboot/mach to /sdmach "
216 ln -s /sdmach
${dest}/tftpboot
/mach
219 # Touch the first 16 Meg of the swapfile
220 echo -n "Creating swapfile..."
221 (cd ${dest}/vm
; /bin
/rm -f swapfile
; /usr
/etc
/mkfile
8k swapfile
)
229 echo "Usage: $0 -p DISKTYPE TEMPLATE DEST"
230 echo " $0 [-s SERVER] CLIENT CLIENT ..."