-
Notifications
You must be signed in to change notification settings - Fork 11
/
create_guestldom.sh
4608 lines (3786 loc) · 130 KB
/
create_guestldom.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/ksh
#
# **** Note: The main code starts after the line containing "main:" ****
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2006-2009 Bernd Schemmer All rights reserved.
# Use is subject to license terms.
#
# Notes:
#
# - use "create_guestldom.sh {-v} {-v} -h" to get the usage help
#
# - replace "create_guestldom.sh" with the name of your script
# - change the parts marked with "???" and "??" to your need
#
# - use "create_guestldom.sh -H 2 >create_guestldom.sh.doc" to get the documentation
#
# - this is a Kornshell script - it may not function correctly in other shells
# - the script was written and tested with ksh88 but should also work in ksh93
#
##
# -----------------------------------------------------------------------------
##
## create_guestldoms.sh - create Guest LDoms
##
## Author: Bernd Schemmer ([email protected])
##
## Version: see variable ${__SCRIPT_VERSION} below
## (see variable ${__SCRIPT_TEMPLATE_VERSION} for the template
## version used)
##
## Supported OS: Solaris and others
##
##
## Description
##
## ???
##
## Configuration file
##
## This script supports a configuration file called <scriptname>.conf.
## The configuration file is searched in the working directory,
## the home directory of the user executing this script and /etc
## (in this order).
##
## The configuration file is read before the parameter are read.
##
## See the variable __CONFIG_PARAMETER below for the possible entries in
## the config file.
##
## Predefined parameter
##
## see the subroutines ShowShortUsage and ShowUsage
##
## Note: The current version of the script template can be found here:
##
## http://bnsmb.de/solaris/scriptt.html
##
##
## Credits
## wpollock (http://wikis.sun.com/display/~wpollock)
## -- http://wikis.sun.com/display/BigAdmin/A+Script+Template+and+Useful+Techniques+for+ksh+Scripts?focusedCommentId=12517624#comment-12517624
##
## Source for the function PrintWithTimeStamp:
## Bernd Fingers blog:
## http://blogs.sun.com/blogfinger/entry/prepend_command_output_lines_with
##
##
## History:
## ??.??.2007 v0.0.0.1 /bs
## initial release
##
## script template History
## -----------------------
## 1.22.0 08.06.2006 /bs (BigAdmin Version 1)
## public release; starting history for the script template
##
## 1.22.1 12.06.2006 /bs
## added true/false to CheckYNParameter and ConvertToYesNo
##
## 1.22.2. 21.06.2006 /bs
## added the parameter -V
## added the use of environment variables
## added the variable __NO_TIME_STAMPS
## added the variable __NO_HEADERS
## corrected a bug in the function executeCommandAndLogSTDERR
## added missing return commands
##
## 1.22.3 24.06.2006 /bs
## added the function StartStop_LogAll_to_logfile
## added the variable __USE_TTY (used in AskUser)
## corrected an spelling error (dev/nul instead of /dev/null)
##
## 1.22.4 06.07.2006 /bs
## corrected a bug in the parameter error handling routine
##
## 1.22.5 27.07.2006 /bs
## corrected some minor bugs
##
## 1.22.6 09.08.2006 /bs
## corrected some minor bugs
##
## 1.22.7 17.08.2006 /bs
## add the CheckParameterCount function
## added the parameter -T
## added long parameter support (e.g --help)
##
## 1.22.8 07.09.2006 /bs
## added code to save the env variable LANG and set it temporary to C
##
## 1.22.9 20.09.2006 /bs
## corrected code to save the env variable LANG and set it temporary to C
##
## 1.22.10 21.09.2006 /bscontent/sunsolve/archives/082007.html
## cleanup comments
## the number of temporary files created automatically is now variable
## (see the variable __NO_OF_TEMPFILES)
## added code to install the trap handler in all functions
##
## 1.22.11 19.10.2006 /bs
## corrected a minor bug in AskUser (/c was not interpreted by echo)
## corrected a bug in the handling of the parameter -S (-S was ignored)
##
## 1.22.12 31.10.2006 /bs
## added the variable __REQUIRED_ZONE
##
## 1.22.13 13.11.2006 /bs
## the template now uses TMP or TEMP if set for the temporary files
##
## 1.22.14 14.11.2006 /bs
## corrected a bug in the function AskUser (the default was y not n)
##
## 1.22.15 21.11.2006 /bs
## added initial support for other Operating Systems
##
## 1.22.16 05.07.2007 /bs
## enhanced initial support for other Operating Systems
## Support for other OS is still not fully tested!
##
## 1.22.17 06.07.2007 /bs
## added the global variable __TRAP_SIGNAL
##
## 1.22.18 01.08.2007 /bs
## __OS_VERSION and __OS_RELEASE were not set - corrected
##
## 1.22.19 04.08.2007 /bs
## wrong function used to print "__TRAP_SIGNAL is \"${__TRAP_SIGNAL}\"" - fixed
##
## 1.22.20 12.09.2007 /bs
## the script now checks the ksh version if running on Solaris
## made some changes for compatibility with ksh93
##
## 1.22.21 18.09.2007 /bs (BigAdmin Version 2)
## added the variable __FINISHROUTINES
## changed __REQUIRED_ZONE to __REQUIRED_ZONES
## added the variable __KSH_VERSION
## reworked the trap handling
##
## 1.22.22 23.09.2007 /bs
## added the signal handling for SIGUSR1 and SIGUSR2 (variables __SIGUSR1_FUNC and __SIGUSR2_FUNC)
## added user defined function for the signals HUP, BREAK, TERM, QUIT, EXIT, USR1 and USR2
## added the variables __WARNING_PREFIX, __ERROR_PREFIX, __INFO_PREFIX, and __RUNTIME_INFO_PREFIX
## the parameter -T or --tee can now be on any position in the parameters
## the default output file if called with -T or --tee is now
## /var/tmp/${0##*/}.$$.tee.log
##
## 1.22.23 25.09.2007 /bs
## added the environment variables __INFO_PREFIX, __WARNING_PREFIX,
## __ERROR_PREFIX, and __RUNTIME_INFO_PREFIX
## added the environment variable __DEBUG_HISTFILE
## reworked the function to print the usage help :
## use "-h -v" to view the extented usage help and use "-h -v -v" to
## view the environment variables used also
##
## 1.22.24 05.10.2007 /bs
## another minor fix for ksh93 compatibility
##
## 1.22.25 08.10.2007 /bs
## only spelling errors corrected
##
## 1.22.26 19.11.2007 /bs
## only spelling errors corrected
##
## 1.22.27 29.12.2007 /bs
## improved the code to create the lockfile (thanks to wpollock for the info; see credits above)
## improved the code to create the temporary files (thanks to wpollock for the info; see credits above)
## added the function rand (thanks to wpollock for the info; see credits above)
## the script now uses the directory name saved in the variable $TMPDIR for temporary files
## if it's defined
## now the umask used for creating temporary files can be changed (via variable __TEMPFILE_UMASK)
##
## 1.22.28 12.01.2008 /bs
## corrected a syntax error in the show usage routine
## added the function PrintWithTimestamp (see credits above)
##
## 1.22.29 31.01.2008 /bs
## there was a bug in the new code to remove the lockfile which prevented
## the script from removing the lockfile at program end
## if the lockfile already exist the script printed not the correct error
## message
##
##
## 1.22.30 28.02.2008 /bs
## Info update: executeCommandAndLog does NOT return the RC of the executed
## command if a logfile is defined
## added inital support for CYGWIN
## (tested with CYGWIN_NT-5.1 v..1.5.20(0.156/4/2)
## Most of the internal functions are NOT tested yet in CYGWIN
## GetCurrentUID now supports UIDs greater than 254; the function now prints the UID to STDOUT
## Corrected bug in GetUserName (only a workaround, not the solution)
## now using printf in the AskUserRoutine
##
## 1.22.30 28.02.2008 /bs
## The lockfile is now also deleted if the script crashes because of a syntax error or something like this
##
## 1.22.31 18.03.2008 /bs
## added the version number to the start and end messages
## an existing config file is now removed (and not read) if the script is called with -C to create a config file
##
## 1.22.32 04.04.2008 /bs
## minor changes for zone support
##
## 1.22.33 12.02.2009 /bs
## disabled the usage of prtdiag due to the fact that prtdiag on newer Sun machines needs a long time to run
## (-> __MACHINE_SUBTYPE is now always empty for Solaris machines)
## added the variable __CONFIG_FILE_FOUND; this variable contains the name of the config file
## read if a config file was found
## added the variable __CONFIG_FILE_VERSION
## ----------------
## Version variables
##
## __SCRIPT_VERSION - the version of your script
##
# Note: CYGWIN ksh does not like typeset -r
##
typeset __SCRIPT_VERSION="v0.0.0.1"
##
## __SCRIPT_TEMPLATE_VERSION - version of the script template
##
typeset __SCRIPT_TEMPLATE_VERSION="1.22.33 12.02.2009"
##
## ----------------
##
## Predefined return codes:
##
## 1 - show usage and exit
## 2 - invalid parameter found
##
## 210 - 237 reserved for the runtime system
## 238 - unsupported Operating system
## 239 - script runs in a not supported zone
## 240 - internal error
## 241 - a command ended with an error (set -e is necessary to activate this trap)
## 242 - the current user is not allowed to execute this script
## 243 - invalid machine architecture
## 244 - invalid processor type
## 245 - invalid machine platform
## 246 - error writing the config file
## 247 - include script not found
## 248 - unsupported OS version
## 249 - Script not executed by root
## 250 - Script is already running
##
## 251 - QUIT signal received
## 252 - User break
## 253 - TERM signal received
## 254 - unknown external signal received
##
## ----------------
## Used environment variables
##
#
# The variable __USED_ENVIRONMENT_VARIABLES is used in the function ShowUsage
#
__USED_ENVIRONMENT_VARIABLES="
## __DEBUG_CODE
## __RT_VERBOSE_LEVEL
## __QUIET_MODE
## __VERBOSE_MODE
## __VERBOSE_LEVEL
## __OVERWRITE_MODE
## __USER_BREAK_ALLOWED
## __NO_TIME_STAMPS
## __NO_HEADERS
## __USE_COLORS
## __USE_RBAC
## __TEE_OUTPUT_FILE
## __INFO_PREFIX
## __WARNING_PREFIX
## __ERROR_PREFIX
## __RUNTIME_INFO_PREFIX
## __DEBUG_HISTFILE
"
#
# binaries and scripts used in this script:
#
# basename cat cp cpio cut date dd dirname expr find grep id ln ls nawk prtdiag pwd
# reboot rm sed sh tee touch tty umount uname who zonename
#
# /usr/bin/pfexec
# /usr/ucb/whoami or $( whence whoami )
# /usr/openwin/bin/resize or $( whence resize )
#
# AIX: oslevel
#
# -----------------------------------------------------------------------------
# variables for the trap handler
__FUNCTION="main"
# alias to install the trap handler
#
# Note: The statement LINENO=${LINENO} is necessary to use the variable LINENO in the trap command
#
alias __settrap="
LINENO=\${LINENO}
trap 'GENERAL_SIGNAL_HANDLER SIGHUP \${LINENO} \${__FUNCTION}' 1
trap 'GENERAL_SIGNAL_HANDLER SIGINT \${LINENO} \${__FUNCTION}' 2
trap 'GENERAL_SIGNAL_HANDLER SIGQUIT \${LINENO} \${__FUNCTION}' 3
trap 'GENERAL_SIGNAL_HANDLER SIGTERM \${LINENO} \${__FUNCTION}' 15
trap 'GENERAL_SIGNAL_HANDLER SIGUSR1 \${LINENO} \${__FUNCTION}' USR1
trap 'GENERAL_SIGNAL_HANDLER SIGUSR2 \${LINENO} \${__FUNCTION}' USR2
"
##
## ----------------
## ##### general hints
##
## Do not use variable names beginning with __ (these are reserved for
## internal use)
##
# -----------------------------------------------------------------------------
## __KSH_VERSION - ksh version (either 88 or 93)
##
__KSH_VERSION=88 ; f() { typeset __KSH_VERSION=93 ; } ; f ;
# save the language setting and switch the language temporary to C
#
__SAVE_LANG="${LANG}"
LANG=C
export LANG
# -----------------------------------------------------------------------------
## ##### constants
##
## __TRUE - true (0)
## __FALSE - false (1)
##
# Note: CYGWIN ksh does not like typeset -r
##
typeset __TRUE=0
typeset __FALSE=1
## ----------------
## __OS - Operating system (e.g. SunOS)
##
__OS="$( uname -s )"
case ${__OS} in
CYGWIN* ) set +o noclobber
;;
* )
:
;;
esac
## ----------------
## internal variables
##
## __TRAP_SIGNAL - current trap caught by the trap handler
## This is a global variable that can be used in the exit routines
##
__TRAP_SIGNAL=""
# -----------------------------------------------------------------------------
## __USE_RBAC - set this variable to ${__TRUE} to execute this script
## with RBAC
## default is ${__FALSE}
##
## Note: You can also set this environment variable before starting the script
##
__USE_RBAC=${__USE_RBAC:=${__FALSE}}
SCRIPT_USER="$( echo $SSH_ORIGINAL_USER | tr "=" " " | cut -f 5 -d " " )"
SCRIPT_USER_MSG="${__COLOR_REVERSE}${SCRIPT_USER}${__COLOR_OFF}"
# -----------------------------------------------------------------------------
## __TEE_OUTPUT_FILE - name of the output file if called with the parameter -T
## default: var/tmp/$( basename $0 ).$$.tee.log
##
## Note: You can also set this environment variable before starting the script
##
__TEE_OUTPUT_FILE="${__TEE_OUTPUT_FILE:=/var/tmp/${0##*/}.$$.tee.log}"
## -----------------------------------------------------------------------------
## name of the config file read
##
__CONFIG_FILE_FOUND=""
# -----------------------------------------------------------------------------
# use the parameter --tee to automatically call the script and pipe
# all output to tee
if [ "${__PPID}"x = ""x ] ; then
__PPID=$PPID ; export __PPID
if [[ \ $*\ == *\ -T* || \ $*\ == *\ --tee\ * ]] ; then
echo "Saving STDOUT and STDERR to \"${__TEE_OUTPUT_FILE}\" ..."
exec $0 $@ 2>&1 | tee -a "${__TEE_OUTPUT_FILE}"
__MAINRC=$?
echo "STDOUT and STDERR saved in \"${__TEE_OUTPUT_FILE}\"."
exit ${__MAINRC}
fi
fi
[ "${__PPID}"x = ""x ] && __PPID=$PPID ; export __PPID
# -----------------------------------------------------------------------------
#
# Set the variable ${__USE_RBAC} to ${__TRUE} to activate RBAC support
#
# Allow the use of RBAC to control who can access this script. Useful for
# administrators without root permissions
#
if [ "${__USE_RBAC}" = "${__TRUE}" ] ; then
if [ "$_" != "/usr/bin/pfexec" -a -x /usr/bin/pfexec ]; then
/usr/bin/pfexec $0 $*
exit $?
else
echo "${0%%*/} ERROR: /usr/bin/pfexec not found or not executable!" >&2
exit 238
fi
fi
if [[ \ $*\ == *\ -q* || \ $*\ == *\ --quiet\ * ]] ; then
__NO_HEADERS=${__TRUE}
__QUIET=${__TRUE}
fi
# -----------------------------------------------------------------------------
##
## ##### defined variables that may be changed
##
## __DEBUG_CODE - code executed at start of every sub routine
## Note: Use always "__DEBUG_CODE="eval ..." if you want to use variables or aliases
## Default debug code : none
##
# __DEBUG_CODE=""
## __FUNCTION_INIT - code executed at start of every sub routine
## (see the hints for __DEBUG_CODE)
## Default init code : install the trap handlers
##
if [[ ${__OS} == CYGWIN* || "${BASH_VERSION}"x != ""x ]] ; then
__FUNCTION_INIT=""
else
__FUNCTION_INIT=" eval __settrap"
fi
##
## sample debug code:
## __DEBUG_CODE=" eval echo Entering the subroutine \${__FUNCTION} ... "
##
## Note: Use an include script for more complicate debug code, e.g.
## __DEBUG_CODE=" eval . /var/tmp/mydebugcode"
##
## __CONFIG_PARAMETER
## The variable __CONFIG_PARAMETER contains the configuration variables
##
## The defaults for these variables are defined here. You
## can use a config file to overwrite the defaults.
##
## Use the parameter -C to create a default configuration file
##
## Note: The config file is read and interpreted via ". configfile"
## therefore you can also add some code her
##
__CONFIG_PARAMETER="__CONFIG_FILE_VERSION=\"${__SCRIPT_VERSION}\"
"'
# extension for backup files
DEFAULT_BACKUP_EXTENSION=".$$.backup"
# number of threads per core for various machine types
#
MACHINE_TYPE="$( uname -a 2>/dev/null | cut -f 7 -d " " )"
case ${MACHINE_TYPE} in
"SUNW,SPARC-Enterprise-T5220" )
THREADS_PER_CORE=8
;;
"SUNW,SPARC-Enterprise-T5220" )
THREADS_PER_CORE=8
;;
"SUNW,Sun-Fire-T200" )
THREADS_PER_CORE=4
;;
"SUNW,Sun-Fire-T100" )
THREADS_PER_CORE=4
;;
* )
THREADS_PER_CORE=8
;;
esac
# base directory for the Guest LDom image files
DEFAULT_DISKDIR="/ldoms"
# size of the file for the Guest LDom boot disk
DEFAULT_BOOT_DISK_IMG_SIZE="60g"
# ldm binary
DEFAULT_LDM="/opt/SUNWldm/bin/ldm"
# list ldoms only? (parameter -L/+L)
DEFAULT_LIST_LDOMS=${__FALSE}
# create the image file if it does not exist? (parameter -i/+i)
DEFAULT_CREATE_IMAGE_FILE=${__TRUE}
# service domain
DEFAULT_SERVICE_DOMAIN="primary"
# vdisk server to use
DEFAULT_VDISK_SERVER_SWITCH="primary-vds0"
# Bind the Guest LDoms? (Parameter -b/+b)
DEFAULT_BIND_LDOMS=${__TRUE}
# default action: only print the commands to create the Guest LDom (parameter -x/+x)
#
DEFAULT_PREFIX="echo"
# List of LDoms to create (no default, parameter -d)
#
DEFAULT_GUEST_LDOMS=""
# Ouput file for the commands (do not execute them) (parameter -s)
#
DEFAULT_OUTPUT_SCRIPT=""
# -------------------------------------
# # # Guest LDom Definitions start here
i=0
# NOTE: The next line is always the first line of a Guest LDom Definition!!!!
# (( i=i+1 ))
# sample definition for a Guest LDom
# Note: unused variables shoud be left blank or undefined
# mandatory variable
GUEST_LDOM_NAME[$i]="template"
GUEST_LDOM_CORES[$i]="1"
GUEST_LDOM_MAU[$i]="0"
GUEST_LDOM_MEMORY[$i]="6G"
GUEST_LDOM_HOSTID[$i]=""
GUEST_LDOM_MACADDRESS[$i]=""
# Note: The file will be created in the directory ${DEFAULT_DISKDIR}/${LDOM_NAME}/rootdisk
# To use another directory use a fully qualified filename here
#
GUEST_LDOM_IMAGEFILE[$i]="${GUEST_LDOM_NAME[$i]}_rootdisk.img"
GUEST_LDOM_IMAGEFILE_OPTIONS[$i]=""
GUEST_LDOM_IMAGEFILE_VDISKSERVER_OPTIONS[$i]=""
GUEST_LDOM_NETWORK_ADAPTER0_SWITCH[$i]=""
GUEST_LDOM_NETWORK_ADAPTER0_MAC_ADDRESS[$i]=""
GUEST_LDOM_NETWORK_ADAPTER0_OPTIONS[$i]=""
GUEST_LDOM_NETWORK_ADAPTER1_SWITCH[$i]=""
GUEST_LDOM_NETWORK_ADAPTER1_MAC_ADDRESS[$i]=""
GUEST_LDOM_NETWORK_ADAPTER1_OPTIONS[$i]=""
GUEST_LDOM_NETWORK_ADAPTER2_SWITCH[$i]=""
GUEST_LDOM_NETWORK_ADAPTER2_MAC_ADDRESS[$i]=""
GUEST_LDOM_NETWORK_ADAPTER2_OPTIONS[$i]=""
GUEST_LDOM_NETWORK_ADAPTER3_SWITCH[$i]=""
GUEST_LDOM_NETWORK_ADAPTER3_MAC_ADDRESS[$i]=""
GUEST_LDOM_NETWORK_ADAPTER3_OPTIONS[$i]=""
GUEST_LDOM_NETWORK_ADAPTER4_SWITCH[$i]=""
GUEST_LDOM_NETWORK_ADAPTER4_MAC_ADDRESS[$i]=""
GUEST_LDOM_NETWORK_ADAPTER4_OPTIONS[$i]=""
GUEST_LDOM_NETWORK_ADAPTER5_SWITCH[$i]=""
GUEST_LDOM_NETWORK_ADAPTER5_MAC_ADDRESS[$i]=""
GUEST_LDOM_NETWORK_ADAPTER5_OPTIONS[$i]=""
GUEST_LDOM_NETWORK_ADAPTER6_SWITCH[$i]=""
GUEST_LDOM_NETWORK_ADAPTER6_MAC_ADDRESS[$i]=""
GUEST_LDOM_NETWORK_ADAPTER6_OPTIONS[$i]=""
GUEST_LDOM_NETWORK_ADAPTER7_SWITCH[$i]=""
GUEST_LDOM_NETWORK_ADAPTER7_MAC_ADDRESS[$i]=""
GUEST_LDOM_NETWORK_ADAPTER7_OPTIONS[$i]=""
# Note: Do NOT use blanks in the value for the variables!
GUEST_LDOM_OBP_VARIABLES[$i]="
auto-boot\?=false
boot-device=/virtual-devices@100/channel-devices@200/disk@0
"
GUEST_LDOM_VCONSOLE_PORT[$i]=""
GUEST_LDOM_VCONSOLE_GROUP[$i]=""
GUEST_LDOM_VCONSOLE_SERVICE[$i]=""
GUEST_LDOM_PREINSTALL_SCRIPT[$i]=""
GUEST_LDOM_POSTINSTALL_SCRIPT[$i]=""
# end of Guest LDom definitions
# -------------------------------------
# no of Guest LDoms defined
#
NO_OF_DEFINED_GUEST_LDOMS=$i
# Note:
# The following environment variables are available in the
# preinstall and postinstall scripts:
#
# GUEST_LDOM_CORES
# GUEST_LDOM_CREATED
# GUEST_LDOM_HOSTID
# GUEST_LDOM_IMAGEFILE
# GUEST_LDOM_IMAGEFILE_OPTIONS
# GUEST_LDOM_IMAGEFILE_VDISKSERVER_OPTIONS
# GUEST_LDOM_MACADDRESS
# GUEST_LDOM_MAU
# GUEST_LDOM_MEMORY
# GUEST_LDOM_NAME
# GUEST_LDOM_NETWORK_ADAPTER0_MAC_ADDRESS
# GUEST_LDOM_NETWORK_ADAPTER0_OPTIONS
# GUEST_LDOM_NETWORK_ADAPTER0_SWITCH
# GUEST_LDOM_NETWORK_ADAPTER1_MAC_ADDRESS
# GUEST_LDOM_NETWORK_ADAPTER1_OPTIONS
# GUEST_LDOM_NETWORK_ADAPTER1_SWITCH
# GUEST_LDOM_NETWORK_ADAPTER2_MAC_ADDRESS
# GUEST_LDOM_NETWORK_ADAPTER2_OPTIONS
# GUEST_LDOM_NETWORK_ADAPTER2_SWITCH
# GUEST_LDOM_NETWORK_ADAPTER3_MAC_ADDRESS
# GUEST_LDOM_NETWORK_ADAPTER3_OPTIONS
# GUEST_LDOM_NETWORK_ADAPTER3_SWITCH
# GUEST_LDOM_NETWORK_ADAPTER4_MAC_ADDRESS
# GUEST_LDOM_NETWORK_ADAPTER4_OPTIONS
# GUEST_LDOM_NETWORK_ADAPTER4_SWITCH
# GUEST_LDOM_NETWORK_ADAPTER5_MAC_ADDRESS
# GUEST_LDOM_NETWORK_ADAPTER5_OPTIONS
# GUEST_LDOM_NETWORK_ADAPTER5_SWITCH
# GUEST_LDOM_NETWORK_ADAPTER6_MAC_ADDRESS
# GUEST_LDOM_NETWORK_ADAPTER6_OPTIONS
# GUEST_LDOM_NETWORK_ADAPTER6_SWITCH
# GUEST_LDOM_NETWORK_ADAPTER7_MAC_ADDRESS
# GUEST_LDOM_NETWORK_ADAPTER7_OPTIONS
# GUEST_LDOM_NETWORK_ADAPTER7_SWITCH
# GUEST_LDOM_OBP_VARIABLES
# GUEST_LDOM_POSTINSTALL_SCRIPT
# GUEST_LDOM_PREINSTALL_SCRIPT
# GUEST_LDOM_VCONSOLE_GROUP
# GUEST_LDOM_VCONSOLE_PORT
# GUEST_LDOM_VCONSOLE_SERVICE
#
# only change the following variables if you know what you are doing #
# no further internal variables defined yet
#
# Note you can redefine any variable that is initialized before calling
# ReadConfigFile here!
'
# end of config parameters
## __SHORT_DESC - short description (for help texts, etc)
## Change to your need
##
# Note: CYGWIN ksh does not like typeset -r
##
typeset -r __SHORT_DESC="create one or more guest ldoms"
## __LONG_USAGE_HELP - Additional help if the script is called with
## the parameter "-v -h"
##
## Note: To use variables in the help text use the variable name without
## an escape character, eg. ${OS_VERSION}
##
__LONG_USAGE_HELP='
-x execute the commands to create the GuestLDoms
Current value: $( ConvertToYesNo $( [ "${PREFIX}"x = ""x ) )
Long format: --doit
-d guestldom
Name of the Guest LDom to configure
Current value: ${GUEST_LDOMS}
Long format: --guestldom
-s scriptfile
Write the commands to the file scriptfile - do not execute them
Current value: ${OUTPUT_SCRIPT}
Long format: --script
-b / +b
bind/do not bind the Guest LDom
Current value: $( ConvertToYesNo ${BIND_LDOMS} )
Long format: --bindldom
-i / +i
create/do not create the image file if it does not yet exist
Current value: $( ConvertToYesNo ${CREATE_IMAGE_FILE} )
Long format: --createimagefile
-L / +L
only list the defined Guest LDoms
Current value: $( ConvertToYesNo ${LIST_LDOMS} )
all other parameter will be ingored
'
## __SHORT_USAGE_HELP - Additional help if the script is called with the parameter "-h"
##
## Note: To use variables in the help text use the variable name without an escape
## character, eg. ${OS_VERSION}
##
__SHORT_USAGE_HELP='
[-d guestldom1] [...] [-d guestldom#] [-x] [-s script] [-b|+b] [-i|+i] [-L|+L]
'
## __MUST_BE_ROOT - run script only by root (def.: false)
## set to ${__TRUE} for scripts that must be executed by root only
##
__MUST_BE_ROOT=${__FALSE}
## __REQUIRED_USERID - required userid to run this script (def.: none)
## use blanks to separate multiple userids
## e.g. "oracle dba sysdba"
## "" = no special userid required
##
__REQUIRED_USERID=""
## __REQUIRED_ZONES - required zones (either global, non-global or local
## or the names of the valid zones)
## (def.: none)
## "" = no special zone required
##
__REQUIRED_ZONES=""
## __ONLY_ONCE - run script only once at a time (def.: false)
## set to ${__TRUE} for scripts that can not run more than one instance at
## the same time
##
__ONLY_ONCE=${__FALSE}
## __ REQUIRED_OS - required OS (uname -s) for the script (def.: none)
## use blanks to separate the OS names if the script runs under multiple OS
## e.g. "SunOS"
##
__REQUIRED_OS=""
## __REQUIRED_OS_VERSION - required OS version for the script (def.: none)
## minimum OS version necessary, e.g. 5.10
## "" = no special version necessary
##
__REQUIRED_OS_VERSION=""
## __REQUIRED_MACHINE_PLATFORM - required machine platform for the script (def.: none)
## required machine platform (uname -i) , e.g "i86pc"; use blanks to separate
## the multiple machine types, e.g "Sun Fire 3800 i86pc"
## "" = no special machine type necessary
##
__REQUIRED_MACHINE_PLATFORM=""
## __REQUIRED_MACHINE_CLASS - required machine class for the script (def.: none)
## required machine class (uname -m) , e.g "i86pc" ; use blanks to separate
## the multiple machine classes, e.g "sun4u i86pc"
## "" = no special machine class necessary
##
__REQUIRED_MACHINE_CLASS=""
## __REQUIRED_MACHINE_ARC - required machine architecture for the script (def.: none)
## required machine architecture (uname -p) , e.g "i386" ; use blanks to separate
## the machine architectures if more than one entry, e.g "sparc i386"
## "" = no special machine architecture necessary
##
__REQUIRED_MACHINE_ARC=""
## __VERBOSE_LEVEL - count of -v parameter (def.: 0)
##
## Note: You can also set this environment variable before starting the script
##
typeset -i __VERBOSE_LEVEL=${__VERBOSE_LEVEL:=0}
## __RT_VERBOSE_LEVEL - level of -v for runtime messages (def.: 1)
##
## e.g. 1 = -v -v is necessary to print info messages of the runtime system
## 2 = -v -v -v is necessary to print info messages of the runtime system
##
## Note: You can also set this environment variable before starting the script
##
typeset -i __RT_VERBOSE_LEVEL=${__RT_VERBOSE_LEVEL:=1}
## __QUIET_MODE - do not print messages to STDOUT (def.: false)
## use the parameter -q/+q to change this variable
##
## Note: You can also set this environment variable before starting the script
##
__QUIET_MODE=${__QUIET_MODE:=${__FALSE}}
## __VERBOSE_MODE - print verbose messages (def.: false)
## use the parameter -v/+v to change this variable
##
## Note: You can also set this environment variable before starting the script
##
__VERBOSE_MODE=${__VERBOSE_MODE:=${__FALSE}}
## __NO_TIME_STAMPS - Do not use time stamps in the messages (def.: false)
##
## Note: You can also set this environment variable before starting the script
##
__NO_TIME_STAMPS=${__NO_TIME_STAMPS:=${__FALSE}}
## __NO_HEADERS - Do not print headers and footers (def.: false)
##
## Note: You can also set this environment variable before starting the script
##
__NO_HEADERS=${__NO_HEADERS:=${__FALSE}}
## __FORCE - do the action anyway (def.: false)
## If this variable is set to ${__TRUE} the function "die" will return
## if called with an RC not zero (instead of aborting the script)
## use the parameter -f/+f to change this variable
##
__FORCE=${__FALSE}
## __USE_COLORS - use colors (def.: false)
## use the parameter -a/+a to change this variable
##
## Note: You can also set this environment variable before starting the script
##
__USE_COLORS=${__USE_COLORS:=${__FALSE}}
## __USER_BREAK_ALLOWED - CTRL-C aborts the script or not (def.: true)
## (no parameter to change this variable)
##
## Note: You can also set this environment variable before starting the script
##
__USER_BREAK_ALLOWED=${__USER_BREAK_ALLOWED:=${__TRUE}}
## __NOECHO - turn echo off while reading input from the user
## do not echo the user input in AskUser if __NOECHO is set to ${__TRUE}
##
__NOECHO=${__FALSE}
## __USE_TTY - write prompts and read user input from /dev/tty (def.: false)
## If __USE_TTY is ${__TRUE} the function AskUser writes the prompt to /dev/tty
## and the reads the user input from /dev/tty . This is useful if STDOUT is
## redirected to a file.
##
__USE_TTY=${__FALSE}
## __OVERWRITE mode - overwrite existing files or not (def.: false)
## use the parameter -O/+O to change this variable
##
## Note: You can also set this environment variable before starting the script
##
__OVERWRITE_MODE=${__OVERWRITE_MODE:=${__FALSE}}
## __DEBUG_MODE - use single step mode for main (def.: false)
## use the parameter -D/+D to change this variable
##
__DEBUG_MODE=${__FALSE}
__SCRIPT_ARRAY[0]=0
## __TEMPDIR - directory for temporary files
## The default is $TMPDIR (if defined), or $TMP (if defined),
## or $TEMP (if defined) or /tmp if none of the variables is
## defined
##
__TEMPDIR="${TMPDIR:-${TMP:-${TEMP:-/tmp}}}"
## __NO_OF_TEMPFILES
## number of automatically created tempfiles that are deleted at program end
## (def. 2)
## Note: The variable names for the tempfiles are __TEMPFILE1, __TEMPFILE2, etc.
##
__NO_OF_TEMPFILES=2
## __TEMPFILE_UMASK
## umask for creating temporary files (def.: 177)
##
__TEMPFILE_UMASK=177
## __LIST_OF_TMP_MOUNTS - list of mounts that should be umounted at program end
##
__LIST_OF_TMP_MOUNTS=""
## __LIST_OF_TMP_DIRS - list of directories that should be removed at program end
##
__LIST_OF_TMP_DIRS=""
## __LIST_OF_TMP_FILES - list of files that should be removed at program end
##
__LIST_OF_TMP_FILES=""
## __EXITROUTINES - list of routines that should be executed before the script ends
## Note: These routines are called *before* temp files, temp directories, and temp
## mounts are removed
##
__EXITROUTINES=""
## __FINISHROUTINES - list of routines that should be executed before the script ends
## Note: These routines are called *after* temp files, temp directories, and temp
## mounts are removed
##
__FINISHROUTINES=""
## __SIGNAL_SIGUSR1_FUNCTION - name of the function to execute if the signal SIGUSR1 is received
## default signal handling: none
##
__SIGNAL_SIGUSR1_FUNCTION=""
## __SIGNAL_SIGUSR2_FUNCTION - name of the function to execute if the signal SIGUSR2 is received
## default signal handling: none
##
__SIGNAL_SIGUSR2_FUNCTION=""
## __SIGNAL_SIGHUP_FUNCTION - name of the function to execute if the signal SIGHUP is received
## default signal handling: switch the verbose mode on or off
## If a user defined function ends with a return code not equal zero the default
## action fro the SIGHUP signal is not executed.
##
__SIGNAL_SIGHUP_FUNCTION=""
## __SIGNAL_SIGINT_FUNCTION - name of the function to execute if the signal SIGINT is received
## default signal handling: end the script if __USER_BREAK_ALLOWED is ${__TRUE} else ignore the signal
## If a user defined function ends with a return code not equal zero the default
## action for the SIGINT signal is not executed.
##
__SIGNAL_SIGINT_FUNCTION=""
## __SIGNAL_SIGQUIT_FUNCTION - name of the function to execute if the signal SIGQUIT is received
## default signal handling: end the script
## If a user defined function ends with a return code not equal zero the default
## action for the SIGQUIT signal is not executed.
##
__SIGNAL_SIGQUIT_FUNCTION=""
## __SIGNAL_SIGTERM_FUNCTION - name of the function to execute if the signal SIGTERM is received
## default signal handling: end the script
## If a user defined function ends with a return code not equal zero the default
## action for the SIGTERM signal is not executed.
##
__SIGNAL_SIGTERM_FUNCTION=""