Initial add of defaria.com
[clearscm.git] / defaria.com / Computers / code / adm / bin / pdl-config
1 #!/usr/bin/ksh
2 ################################################################################
3 #
4 # File:         pdl-config
5 # Description:  ADL system configuration script
6 #               To run this script you must have the pdl-config.src parameter
7 #               file located in root. It is important that the source parameter
8 #               file be read and understood before running the script.
9 #               See below for useful comments.
10 # Author:       Kevin Lister - kel@cup.hp.com
11 # Date          3.11.99
12 # Language:     Korn Shell
13 #
14 # (c) Copyright 1991, Hewlett-Packard Company, all rights reserved.
15 #
16 # Revision History
17 # 3.25.99 kel  Changed the name of the Clearcase install script in shell
18 #              archive, so it had to be changed here as well. Added an
19 #              eclipse install script to the shell archive, so a line to
20 #              to remove it if Clearcase is not installed had to be added
21 #              here as well.
22 # 4.1.99  kel  Added code to determine if the installed system is going to have
23 #              a graphics console. If yes, then the /etc/dt/config/Xservers
24 #              file needs to have the console server line uncommented.
25 #              Also added absolute paths to the unix commands.
26 # 6.22.99 kel  Added "bufpages 0" to the kernel config function. This is
27 #              required if dynamic buffer cache sizes are being used.
28 #
29 ################################################################################
30 # Useful (hopefully) Comments Section
31 #
32 # This script will configure a system to operate nicely in the ADL
33 # infrastructure. This script requires the pdl-config.src file in order to
34 # run. The pdl-config.src file contains variables that determine exactly
35 # what type of optional software to install, which patch bundle to install,
36 # configures various system files, etc.
37 #
38 # Here is a brief description of what this script will do:
39 #
40 #  1) Check that the script is run as root
41 #  2) Check that the architecture is correct. The script will run on most
42 #     hardware. The architecture is really only important when trying to
43 #     determine which 100Mbit drivers to install.
44 #  3) Sources the input parameter source file.
45 #  4) Determine if script is run intereactive or not.
46 #  5) Determine if 100Mbit drivers are to be installed
47 #  6) If intereactive, greet the user and display the parameter settings.
48 #  7) Modify the kernel system file located in /stand/system
49 #  8) Download the shell archive file from the anonymous ftp server and unpack.
50 #     The shell archive contains many files and symlinks and will not be
51 #     listed here. See the README in the ahell archive build area and the shell
52 #     archive itself for more details. One can also look through the "root"
53 #     directory that is used to build the archive to see which files and
54 #     symlinks are included.
55 #  9) Modify the /etc/rc.config.d files. (turn off unused stuff)
56 # 10) Modify the /etc/issue, /etc/gettydefs and /etc/motd files.
57 # 11) Modify miscellaneous files.
58 # 12) Perform miscellaneous setup procedures:
59 #     a) Run /net/bismol/App/admin/bin/setup
60 #     b) Run /usr/local/bin/ninstall -h bismol lp adm net3
61 #     c) Run /usr/adm/netdist/netdaemon.dy
62 #     d) Run /usr/sbin/catman -w
63 # 13) Set the system up for ClearCase installation upon automatic reboot.
64 # 14) Install optional software and patches from the specified depot server.
65 #
66 # END of Useful Comments Section
67 ################################################################################
68 #
69 ##
70 ### Variables
71 ##
72 #
73
74 SRC_FILE=/pdl-config.src
75
76 BASE=${0##*/}
77 HOST=`/bin/uname -n`
78 ARCH=`/bin/uname -m`
79 OS=`/bin/uname -r | /usr/bin/cut -c 3-4`
80 integer INDEX=0
81
82 #
83 ##
84 ### Functions
85 ##
86 #
87
88 function error {
89   print -u2 "\t$BASE: Error: $1"
90 }
91
92 function warning {
93   print -u2 "\t$BASE: Warning: $1"
94 }
95
96 function display {
97   print "\t$1"
98 }
99
100 function usage {
101   display "\t$BASE [-usage]"
102   display "        -usage:         Print this usage message"
103   display " "
104   error "$1"
105   exit 1
106 }
107
108 function step {
109   let INDEX=INDEX+1
110   display "\tStep #$INDEX: $@"
111 }
112
113 function get_shar {
114 step "Get shell archive from ftp server and unpack"
115   cd /
116   ftp -n $FTP_SERVER <<@EOD
117 user $FTP_USER $FTP_PASSWD
118 cd $SHAR_DIR
119 get $SHAR_FILE
120 quit
121 @EOD
122 if [ $? -ne 0 ]; then
123   error "Unable to ftp $SHAR_FILE from $FTP_SERVER"
124   exit 1
125 fi
126 sh $SHAR_FILE >> $LOGFILE 2>&1
127 if [ $? -ne 0 ]; then
128   error "Cannot unpack shell archive."
129   exit 1
130 fi
131 /bin/rm -f $SHAR_FILE
132 }
133
134 function clearcase_setup {
135   if [ "$CLEARCASE" = "no" ]; then
136     /bin/rm -f /sbin/rc3.d/S998install_clearcase
137     /bin/rm -f /sbin/rc3.d/S999install_eclipse
138   fi
139 }
140
141 function chk_uid {
142   if [ $(id -u) -ne 0 ]; then
143     error "Must be root to execute this command... Exiting!"
144     exit 1
145   fi
146 }
147
148 function chk_arch {
149   case $ARCH in
150     9000/7[1-3]*|9000/755|9000/7[7-8]*|9000/8**)
151       continue
152     ;;
153
154     *)
155       warning "\tUnknown machine type $ARCH, Exiting!"
156       exit 1
157     ;;
158   esac
159 }
160
161 function read_src {
162   if [ -a $SRC_FILE ]; then
163     . $SRC_FILE
164     case "$CLEARCASE" in
165       y|Y|yes|YES|Yes|1)
166         CLEARCASE=yes
167         ;;
168       *)
169         CLEARCASE=no
170         ;;
171     esac
172     case "$SWINSTALL" in
173       y|Y|yes|YES|Yes|1)
174         SWINSTALL=yes
175       ;;
176       *)
177         SWINSTALL=no
178      ;;
179     esac
180   else
181     error "Source file does not exist!"
182     exit 1
183   fi
184 }
185
186 function set_mode {
187   case "$INTERACTIVE" in
188     y|Y|yes|YES|Yes|1)
189       INTERACTIVE=yes
190     ;;
191     *)
192       INTERACTIVE=no
193     ;;
194   esac
195 }
196
197 function fast_enet {
198   if [ "_$ENET_DRVRS" = "_" ]; then
199     FAST_ENET=no
200   else
201     FAST_ENET=yes
202   fi
203 }
204
205 function mod_kernel {
206   step "Modify /stand/system file."
207   grep -v -E 'maxswapchunks|default_disk_ir|nstrpty' /stand/system \
208   > /stand/system.new
209   /bin/mv /stand/system /stand/system.orig
210   /bin/mv /stand/system.new /stand/system
211
212   case $ARCH in
213     9000/7[1-5]*)
214       echo "bufpages         0" >> /stand/system
215       echo "create_fastlinks 1" >> /stand/system
216       echo "dbc_max_pct     25" >> /stand/system
217       echo "default_disk_ir 1" >> /stand/system
218       echo "fs_async        1" >> /stand/system
219       echo "maxdsiz         (256*1024*1024)" >> /stand/system
220       echo "maxfiles        256" >> /stand/system
221       echo "maxfiles_lim    2048" >> /stand/system
222       echo "maxssiz         (80*1024*1024)" >> /stand/system
223       echo "maxswapchunks   4096" >> /stand/system
224       echo "maxuprc         500" >> /stand/system
225       echo "maxusers        150" >> /stand/system
226       echo "netmemmax       0" >> /stand/system
227       echo "nfile           7000" >> /stand/system
228       echo "nflocks         400" >> /stand/system
229       echo "ninode          20000" >> /stand/system
230       echo "nproc           1500" >> /stand/system
231       echo "npty            512" >> /stand/system
232       echo "nstrpty         512" >> /stand/system
233       echo "semmns          200" >> /stand/system
234       if [ "$OS" = "10" ]; then
235         echo "large_ncargs_enabled 1" >> /stand/system
236       fi
237     ;;
238
239     9000/7[7-8]*|9000/8**)
240       echo "bufpages         0" >> /stand/system
241       echo "create_fastlinks 1" >> /stand/system
242       echo "dbc_max_pct     25" >> /stand/system
243       echo "default_disk_ir 1" >> /stand/system
244       echo "fs_async        1" >> /stand/system
245       echo "maxdsiz         (512*1024*1024)" >> /stand/system
246       echo "maxfiles        256" >> /stand/system
247       echo "maxfiles_lim    2048" >> /stand/system
248       echo "maxssiz         (80*1024*1024)" >> /stand/system
249       echo "maxswapchunks   4096" >> /stand/system
250       echo "maxuprc         1000" >> /stand/system
251       echo "maxusers        256" >> /stand/system
252       echo "netmemmax       0" >> /stand/system
253       echo "nfile           14000" >> /stand/system
254       echo "nflocks         800" >> /stand/system
255       echo "ninode          40000" >> /stand/system
256       echo "nproc           3000" >> /stand/system
257       echo "npty            512" >> /stand/system
258       echo "nstrpty         512" >> /stand/system
259       echo "semmns          400" >> /stand/system
260       if [ "$OS" = "10" ]; then
261         echo "large_ncargs_enabled 1" >> /stand/system
262       fi
263     ;;
264
265     *)
266       warning "Unknown machine model $ARCH!"
267       warning "Leaving kernel parameters as default"
268       /bin/mv /stand/system.orig /stand/system
269     ;;
270   esac
271 } # mod_kernel
272
273 function greet {
274   display "\tADL System Configuration script."
275   display
276   display "\tYou are about to install and modify various system files,"
277   display "\tinstall system patches, install optional software and,"
278   display "\tif you elected to do so, install ClearCase 3.2."
279   display
280   display "\tIf you wish to modify the parameters below exit the install"
281   display "\tand modify the parameters in the $SRC_FILE file."
282   display
283   display "\tMachine Name:\t\t\t$MACHINE_NAME"
284   display "\tMachine Usage:\t\t\t$MACHINE_USAGE"
285   display "\tMacine Location:\t\t$LOCATION"
286   display "\tOwner's Fullname:\t\t$OWNER_NAME"
287   display "\tOwner's Email:\t\t\t$OWNER_EMAIL"
288   display "\tOwner's Extension:\t\t$OWNER_EXTENSION"
289   display "\tInstall ClearCase?:\t\t$CLEARCASE"
290   display "\tInstall 100Mbit Drivers?:\t$FAST_ENET"
291   if [ "$SWINSTALL" = "yes" ]; then
292     display "\tThe following products will be installed from $DEPOT:"
293     display "\t$PRODUCTS"
294     display
295   else
296     display
297   fi
298   if [ "$INTERACTIVE" = "yes" ]; then
299     display "\tContinue installation with these parameters (Y|n)?\c"
300     display
301     answer=y
302     read answer
303     case "$answer" in
304       y|Y|yes|Yes|YES|"")
305         continue
306       ;;
307       *)
308         display
309         display "\tYou have chosen NOT to run the $BASE setup script...
310 Exiting"
311         exit 1
312       ;;
313     esac
314   fi
315 } # greet
316
317 function mod_rc_files {
318   /usr/sbin/ch_rc -ap AUDIO_SERVER=0 >> $LOGFILE 2>&1
319   /usr/sbin/ch_rc -ap LIST_TEMPS=0 >> $LOGFILE 2>&1
320   /usr/sbin/ch_rc -ap CLEAR_TMP=1 >> $LOGFILE 2>&1
321   /usr/sbin/ch_rc -ap HPARRAY_START_STOP=0 >> $LOGFILE 2>&1
322   /usr/sbin/ch_rc -ap NIS_CLIENT=1 >> $LOGFILE 2>&1
323   /usr/sbin/ch_rc -ap NIS_DOMAIN=pdl >> $LOGFILE 2>&1
324   /usr/sbin/ch_rc -ap START_LLBD=0 >> $LOGFILE 2>&1
325   /usr/sbin/ch_rc -ap NTPDATE_SERVER=cupertino.ntp.hp.com >> $LOGFILE 2>&1
326   /usr/sbin/ch_rc -ap XNTPD=1 >> $LOGFILE 2>&1
327   /usr/sbin/ch_rc -ap NETTL=0 >> $LOGFILE 2>&1
328   /usr/sbin/ch_rc -ap NUM_NFSIOD=16 >> $LOGFILE 2>&1
329   /usr/sbin/ch_rc -ap VTDAEMON_START=0 >> $LOGFILE 2>&1
330   if [ "$OS" = "10" ]; then
331     /usr/sbin/ch_rc -ap WAIT_FOR_NIS_SERVER=FALSE >> $LOGFILE 2>&1
332   fi
333 }
334
335 function mod_etc_files {
336   step "/etc files setup"
337   print "+auto.master" > /etc/auto_master
338   /bin/chmod 644 /etc/auto_master
339   /bin/chown root:root /etc/auto_master
340
341   sed "s/GenericSysName/$MACHINE_NAME/" /etc/issue > /etc/issue-new
342   /bin/mv /etc/issue /etc/issue-orig
343   /bin/mv /etc/issue-new /etc/issue
344
345   sed "s/Console Login:/$MACHINE_NAME Console Login:/" /etc/gettydefs \
346     > /etc/gettydefs-new
347   /bin/mv /etc/gettydefs /etc/gettydefs-orig
348   /bin/mv /etc/gettydefs-new /etc/gettydefs
349
350   /bin/banner $MACHINE_NAME > /etc/motd
351   /bin/uname -a >> /etc/motd
352   cat >> /etc/motd <<:END
353
354 *******************************************************************************
355 * This is a private system operated for the Hewlett-Packard Company
356 business. *
357 * Authorization from HP management is required to use this system.
358 *
359 * Use by unauthorized persons is prohibited.
360 *
361
362 *******************************************************************************
363 For System Support: Mon-Fri 8:00-5:00 Email (site-ux@cup.hp.com)
364 Phone: t-447-1212 After hours/weekend Pre-arrange: t-447-0629
365
366 -------------------------------------------------------------------------------
367 Usage:    $MACHINE_USAGE
368 Owner:    $OWNER_NAME ($OWNER_EMAIL) Phone: $OWNER_EXTENSION
369 Location: $LOCATION
370
371 -------------------------------------------------------------------------------
372 :END
373
374   sed "s/Root user/Root\@$HOST/" /etc/passwd > /tmp/passwd-new
375   /bin/mv /tmp/passwd-new /etc/passwd
376 } # mod_etc_files
377
378 function mod_misc_files {
379   step "Miscellaneous file setup"
380   /bin/rm -f /var/adm/cron/at.allow
381   /bin/rm -f /var/adm/cron/cron.allow
382   /bin/chmod 644 /dev/lan*
383   case "$WORKSTATION" in
384     y|Y|yes|YES|Yes|1)
385       WORKSTATION=yes
386     ;;
387     *)
388       WORKSTATION=no
389     ;;
390   esac
391   if [ "$WORKSTATION" = "yes" ]; then
392     /bin/sed -e "s/#  \*/   \*/" Xservers > /tmp/Xservers-new
393     /bin/mv /tmp/Xservers-new /etc/dt/config/Xservers
394     /bin/chmod 444 /etc/dt/config/Xservers
395     /bin/chown root:other /etc/dt/config/Xservers
396   fi
397 }
398
399 function misc_setup {
400   step "Setup Application Server"
401   /net/bismol/App/admin/bin/setup >> $LOGFILE 2>&1
402
403   step "Ninstalling lp, adm and net3 packages"
404   /usr/local/bin/ninstall -h bismol lp adm net3 >> $LOGFILE 2>&1
405
406   step "Run netdaemon.dy"
407   /usr/adm/netdist/netdaemon.dy >> $LOGFILE 2>&1
408
409   step "Create the whatis database"
410   /usr/sbin/catman -w >> $LOGFILE 2>&1
411 }
412
413 function inst_sw {
414   if [ "$SWINSTALL" = "yes" ]; then
415     step "Installing Patches and Optional Software, be patient!"
416     /usr/sbin/swinstall -s $DEPOT -x $OPTIONS $PRODUCTS $ENETDRVR >>
417 $LOGFILE 2>&1
418   else
419     step "Rebuilding kernel with new parameters."
420     /usr/sbin/mk_kernel -v -o /stand/vmunix >> $LOGFILE 2>&1
421     step "Rebooting the system..."
422     cd /
423     /usr/sbin/shutdown -ry 0
424   fi
425 }
426
427 #
428 ##
429 ### Main
430 ##
431 #
432
433 chk_uid
434 chk_arch
435 read_src
436 set_mode
437 fast_enet
438 greet
439 mod_kernel
440 get_shar
441 mod_rc_files
442 mod_etc_files
443 mod_misc_files
444 misc_setup
445 clearcase_setup
446 inst_sw