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