Codebase list fis-gtm / HEAD sr_unix / gtminstall.sh
HEAD

Tree @HEAD (Download .tar.gz)

gtminstall.sh @HEADraw · history · blame

  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
#!/bin/sh -
#################################################################
#                                                               #
# Copyright (c) 2014-2021 Fidelity National Information		#
# Services, Inc. and/or its subsidiaries. All rights reserved.	#
#                                                               #
#       This source code contains the intellectual property     #
#       of its copyright holder(s), and is made available       #
#       under a license.  If you do not know the terms of       #
#       the license, please stop and do not read further.       #
#                                                               #
#################################################################

# This script automates the installation of GT.M as much as possible,
# to the extent of attempting to download the distribution file.
# Current limitation is GNU/Linux on x86 (32- & 64-bit) architectures
# and root installation, but it is intended to relax this in the future.

# NOTE: This script requires the GNU wget program to download
# distribution files that are not on the local file system.

# Revision history
#
# 2011-02-15  0.01 K.S. Bhaskar - Initial version for internal use
# 2011-02-20  0.02 K.S. Bhaskar - Mostly usable with enough features for first Beta test
# 2011-02-21  0.03 K.S. Bhaskar - Deal with case of no group bin, bug fixes, download from FTP site, other platforms
# 2011-02-28  0.04 K.S. Bhaskar - Use which to get locations of id and grep, more bug fixes
# 2011-03-05  0.05 K.S. Bhaskar - Through V5.4-001 group only needed if execution restricted to a group
# 2011-03-08  0.06 K.S. Bhaskar - Make it work when bundled with GT.M V5.4-002
# 2011-03-10  0.10 K.S. Bhaskar - Incorporate review comments to bundle with V5.4-002 distribution
# 2011-05-03  0.11 K.S. Bhaskar - Allow for letter suffix releases
# 2011-10-25  0.12 K.S. Bhaskar - Support option to delete .o files on shared library platforms
# 2014-08-13  0.13 K.S. Bhaskar - Add verbosity around getting latest version and tarball, if requested
# 2015-10-13  0.14 GT.M Staff   - Fix a few minor bugs
# 2017-06-05  0.15 GT.M Staff	- GT.M install script should set RemoveIPC no in systemd linux distributions
# 2017-09-19  0.16 GT.M Staff	- Treat i686 as i586; Fix an interaction bug in gtminstall resulting from the above change
# 2019-07-14  0.17 GT.M Staff   - Add an option (--filename) to pass the file name of GT.M distribution tarball

# Turn on debugging if set
if [ "Y" = "$gtm_debug" ] ; then set -x ; fi

# Initialization
timestamp=`date +%Y%m%d%H%M%S`
gtm_id=`command -v id`
gtm_grep=`command -v grep`
if [ -z "$USER" ] ; then USER=`$gtm_id -un` ; fi

# Functions
dump_info()
{
    set +x
    if [ -n "$gtm_arch" ] ; then echo gtm_arch " : " $gtm_arch ; fi
    if [ -n "$gtm_buildtype" ] ; then echo gtm_buildtype " : " $gtm_buildtype ; fi
    if [ -n "$gtm_configure_in" ] ; then echo gtm_configure_in " : " $gtm_configure_in ; fi
    if [ -n "$gtm_copyenv" ] ; then echo gtm_copyenv " : " $gtm_copyenv ; fi
    if [ -n "$gtm_copyexec" ] ; then echo gtm_copyexec " : " $gtm_copyexec ; fi
    if [ -n "$gtm_debug" ] ; then echo gtm_debug " : " $gtm_debug ; fi
    if [ -n "$gtm_dist" ] ; then echo gtm_dist " : " $gtm_dist ; fi
    if [ -n "$gtm_distrib" ] ; then echo gtm_distrib " : " $gtm_distrib ; fi
    if [ -n "$gtm_dryrun" ] ; then echo gtm_dryrun " : " $gtm_dryrun ; fi
    if [ -n "$gtm_filename" ] ; then echo gtm_filename " : " $gtm_filename ; fi
    if [ -n "$gtm_flavor" ] ; then echo gtm_flavor " : " $gtm_flavor ; fi
    if [ -n "$gtm_ftp_dirname" ] ; then echo gtm_ftp_dirname " : " $gtm_ftp_dirname ; fi
    if [ -n "$gtm_group" ] ; then echo gtm_group " : " $gtm_group ; fi
    if [ -n "$gtm_group_already" ] ; then echo gtm_group_already " : " $gtm_group_already ; fi
    if [ -n "$gtm_group_restriction" ] ; then echo gtm_group_restriction " : " $gtm_group_restriction ; fi
    if [ -n "$gtm_hostos" ] ; then echo gtm_hostos " : " $gtm_hostos ; fi
    if [ -n "$gtm_install_utf8" ] ; then echo gtm_install_utf8 " : " $gtm_install_utf8 ; fi
    if [ -n "$gtm_install_flavor" ] ; then echo gtm_install_flavor " : " $gtm_install_flavor ; fi
    if [ -n "$gtm_installdir" ] ; then echo gtm_installdir " : " $gtm_installdir ; fi
    if [ -n "$gtm_keep_obj" ] ; then echo gtm_keep_obj " : " $gtm_keep_obj ; fi
    if [ -n "$gtm_lcase_utils" ] ; then echo gtm_lcase_utils " : " $gtm_lcase_utils ; fi
    if [ -n "$gtm_linkenv" ] ; then echo gtm_linkenv " : " $gtm_linkenv ; fi
    if [ -n "$gtm_linkexec" ] ; then echo gtm_linkexec " : " $gtm_linkexec ; fi
    if [ -n "$gtm_overwrite_existing" ] ; then echo gtm_overwrite_existing " : " $gtm_overwrite_existing ; fi
    if [ -n "$gtm_prompt_for_group" ] ; then echo gtm_prompt_for_group " : " $gtm_prompt_for_group ; fi
    if [ -n "$gtm_prompt_for_sys_reconfig" ] ; then echo gtm_prompt_for_sys_reconfig " : " $gtm_prompt_for_sys_reconfig ; fi
    if [ -n "$gtm_sf_dirname" ] ; then echo gtm_sf_dirname " : " $gtm_sf_dirname ; fi
    if [ -n "$gtm_tmp" ] ; then echo gtm_tmp " : " $gtm_tmp ; fi
    if [ -n "$gtm_user" ] ; then echo gtm_user " : " $gtm_user ; fi
    if [ -n "$gtm_verbose" ] ; then echo gtm_verbose " : " $gtm_verbose ; fi
    if [ -n "$gtm_version" ] ; then echo gtm_version " : " $gtm_version ; fi
    if [ -n "$gtmroutines" ] ; then echo gtmroutines " : " $gtmroutines ; fi
    if [ -n "$timestamp" ] ; then echo timestamp " : " $timestamp ; fi
    if [ "Y" = "$gtm_debug" ] ; then set -x ; fi
}

err_exit()
{
    set +x
    echo "gtminstall [option] ... [version]"
    echo "Options are:"
    echo "--build-type buildtype - * type of GT.M build, default is pro"
    echo "--copyenv dirname - copy gtmprofile and gtmcshrc files to dirname; incompatible with linkenv"
    echo "--copyexec dirname - copy gtm script to dirname; incompatible with linkexec"
    echo "--debug - * turn on debugging with set -x"
    echo "--distrib dirname or URL - source directory for GT.M distribution tarball, local or remote"
    echo "--filename filename - name of GT.M distribution tarball"
    echo "--dry-run - do everything short of installing GT.M, including downloading the distribution"
    echo "--group group - group that should own the GT.M installation"
    echo "--group-restriction - limit execution to a group; defaults to unlimited if not specified"
    echo "--help - print this usage information"
    echo "--installdir dirname - directory where GT.M is to be installed; defaults to /usr/lib/fis-gtm/version_platform"
    m1="--keep-obj - keep .o files"
    m1="$m1"" of M routines (normally deleted on platforms with GT.M support for routines in shared libraries)"
    echo "$m1"
    echo "--linkenv dirname - create link in dirname to gtmprofile and gtmcshrc files; incompatible with copyenv"
    echo "--linkexec dirname - create link in dirname to gtm script; incompatible with copyexec"
    echo "--noprompt-for-sys-cfg - do not prompt to adjust OS configuration files"
    echo "--overwrite-existing - install into an existing directory, overwriting contents; defaults to requiring new directory"
    m1="--prompt-for-group - * GT.M installation "
    m1="$m1""script will prompt for group; default is yes for production releases V5.4-002 or later, no for all others"
    echo "$m1"
    echo "--ucaseonly-utils -- install only upper case utility program names; defaults to both if not specified"
    echo "--user username - user who should own GT.M installation; default is root"
    echo "--utf8 - install UTF-8 support"
    echo "--verbose - * output diagnostic information as the script executes; default is to run quietly"
    echo "options that take a value (e.g, --group) can be specified as either --option=value or --option value"
    echo "options marked with * are likely to be of interest primarily to GT.M developers"
    echo "version is defaulted from mumps file if one exists in the same directory as the installer"
    echo "This version must run as root."
    exit 1
}

mktmpdir()
{
	tmpdirname="/tmp/gtminstall_${timestamp}"
	mkdir $tmpdirname
	mkdirstatus=$?
	while [ 0 -ne $mkdirstatus ] ; do
		let i++
		tmpdirname="/tmp/gtminstall_${timestamp}_$i"
		mkdir $tmpdirname
		mkdirstatus=$?

	done
	echo $tmpdirname
}

read_yes_no()
{
	read resp
	response=`echo $resp | tr '[a-z]' '[A-Z]'`
	if [ "Y" = "$response" -o "YES" = "$response" ] ; then
		echo "yes"
	else
		echo "no"
	fi
}

# Defaults that can be over-ridden by command line options to follow
if [ -z "$gtm_buildtype" ] ; then gtm_buildtype="pro" ; fi
if [ -z "$gtm_keep_obj" ] ; then gtm_keep_obj="N" ; fi
if [ -z "$gtm_dryrun" ] ; then gtm_dryrun="N" ; fi
if [ -z "$gtm_group_restriction" ] ; then gtm_group_restriction="N" ; fi
if [ -z "$gtm_lcase_utils" ] ; then gtm_lcase_utils="Y" ; fi
if [ -z "$gtm_overwrite_existing" ] ; then gtm_overwrite_existing="N" ; fi
if [ -z "$gtm_prompt_for_group" ] ; then gtm_prompt_for_group="N" ; fi
if [ -z "$gtm_prompt_for_sys_reconfig" ] ; then gtm_prompt_for_sys_reconfig="Y" ; fi
if [ -z "$gtm_verbose" ] ; then gtm_verbose="N" ; fi

# Initializing internal flags
gtm_group_already="N"

# Process command line
while [ $# -gt 0 ] ; do
    case "$1" in
        --build-type*) tmp=`echo $1 | cut -s -d = -f 2-`
            if [ -n "$tmp" ] ; then gtm_buildtype=$tmp
            else if [ 1 -lt "$#" ] ; then gtm_buildtype=$2 ; shift
                else echo "--buildtype needs a value" ; err_exit
                fi
            fi
	    shift ;;
        --copyenv*) tmp=`echo $1 | cut -s -d = -f 2-`
            if [ -n "$tmp" ] ; then gtm_copyenv=$tmp
            else if [ 1 -lt "$#" ] ; then gtm_copyenv=$2 ; shift
                else echo "--copyenv needs a value" ; err_exit
                fi
            fi
            unset gtm_linkenv
            shift ;;
        --copyexec*) tmp=`echo $1 | cut -s -d = -f 2-`
            if [ -n "$tmp" ] ; then gtm_copyexec=$tmp
            else if [ 1 -lt "$#" ] ; then gtm_copyexec=$2 ; shift
                else echo "--copyexec needs a value" ; err_exit
                fi
            fi
            unset gtm_linkexec
            shift ;;
        --debug) gtm_debug="Y" ; set -x ; shift ;;
        --distrib*) tmp=`echo $1 | cut -s -d = -f 2-`
            if [ -n "$tmp" ] ; then gtm_distrib=$tmp
            else if [ 1 -lt "$#" ] ; then gtm_distrib=$2 ; shift
                else echo "--distrib needs a value" ; err_exit
                fi
            fi
            shift ;;
        --filename) tmp=`echo $1 | cut -s -d = -f 2-`
            if [ -n "$tmp" ] ; then gtm_filename=$tmp
            else if [ 1 -lt "$#" ] ; then gtm_filename=$2 ; shift
                else echo "--filename needs a value" ; err_exit
                fi
            fi
            shift ;;
        --dry-run) gtm_dryrun="Y" ; shift ;;
        --group-restriction) gtm_group_restriction="Y" ; shift ;; # must come before group*
        --group*) tmp=`echo $1 | cut -s -d = -f 2-`
            if [ -n "$tmp" ] ; then gtm_group=$tmp
            else if [ 1 -lt "$#" ] ; then gtm_group=$2 ; shift
                else echo "--group needs a value" ; err_exit
                fi
            fi
            shift ;;
        --help) err_exit ;;
        --installdir*) tmp=`echo $1 | cut -s -d = -f 2-`
            if [ -n "$tmp" ] ; then gtm_installdir=$tmp
            else if [ 1 -lt "$#" ] ; then gtm_installdir=$2 ; shift
                else echo "--installdir needs a value" ; err_exit
                fi
            fi
            shift ;;
        --keep-obj) gtm_keep_obj="Y" ; shift ;;
        --linkenv*) tmp=`echo $1 | cut -s -d = -f 2-`
            if [ -n "$tmp" ] ; then gtm_linkenv=$tmp
            else if [ 1 -lt "$#" ] ; then gtm_linkenv=$2 ; shift
                else echo "--linkenv needs a value" ; err_exit
                fi
            fi
            unset gtm_copyenv
            shift ;;
        --linkexec*) tmp=`echo $1 | cut -s -d = -f 2-`
            if [ -n "$tmp" ] ; then gtm_linkexec=$tmp
            else if [ 1 -lt "$#" ] ; then gtm_linkexec=$2 ; shift
                else echo "--linkexec needs a value" ; err_exit
                fi
            fi
            unset gtm_copyexec
            shift ;;
        --noprompt-for-sys-cfg) gtm_prompt_for_sys_reconfig="N" ; shift ;;
        --overwrite-existing) gtm_overwrite_existing="Y" ; shift ;;
        --prompt-for-group) gtm_prompt_for_group="Y" ; shift ;;
        --ucaseonly-utils) gtm_lcase_utils="N" ; shift ;;
        --user*) tmp=`echo $1 | cut -s -d = -f 2-`
            if [ -n "$tmp" ] ; then gtm_user=$tmp
            else if [ 1 -lt "$#" ] ; then gtm_user=$2 ; shift
                else echo "--user needs a value" ; err_exit
                fi
            fi
            shift ;;
        --utf8*) gtm_install_utf8="Y" ; shift ;;
        --verbose) gtm_verbose="Y" ; shift ;;
        -*) echo Unrecognized option "$1" ; err_exit ;;
        *) if [ -n "$gtm_version" ] ; then echo Nothing must follow the GT.M version ; err_exit
            else gtm_version=$1 ; shift ; fi
    esac
done
if [ "Y" = "$gtm_verbose" ] ; then echo Processed command line ; dump_info ; fi

# Set environment variables according to machine architecture
gtm_arch=`uname -m | tr -d _`
case $gtm_arch in
    sun*) gtm_arch="sparc" ;;
esac
gtm_hostos=`uname -s | tr A-Z a-z`
case $gtm_hostos in
    gnu/linux) gtm_hostos="linux" ;;
    hp-ux) gtm_hostos="hpux" ;;
    sun*) gtm_hostos="solaris" ;;
esac
gtm_shlib_support="Y"
case ${gtm_hostos}_${gtm_arch} in
    aix*) # no Source Forge dirname
        gtm_arch="rs6000" # uname -m is not useful on AIX
        gtm_ftp_dirname="aix"
        gtm_flavor="rs6000"
        gtm_install_flavor="RS6000" ;;
    hpux_ia64) # no Source Forge dirname
        gtm_ftp_dirname="hpux_ia64"
        gtm_flavor="ia64"
        gtm_install_flavor="IA64" ;;
    linux_i586) gtm_sf_dirname="GT.M-x86-Linux"
        gtm_ftp_dirname="linux"
        gtm_flavor="i586"
        gtm_install_flavor="x86"
        gtm_shlib_support="N" ;;
    linux_i686) gtm_sf_dirname="GT.M-x86-Linux"
        gtm_ftp_dirname="linux"
        gtm_flavor="i586"
        gtm_install_flavor="x86"
        gtm_shlib_support="N" ;;
    linux_ia64) # no Source Forge dirname
        gtm_ftp_dirname="linux_ia64"
        gtm_flavor="ia64"
        gtm_install_flavor="IA" ;;
    linux_s390x) # no Source Forge dirname
        gtm_ftp_dirname="linux_s390x"
        gtm_flavor="s390x"
        gtm_install_flavor="S390X" ;;
    linux_x8664) gtm_sf_dirname="GT.M-amd64-Linux"
        gtm_ftp_dirname="linux_x8664"
        gtm_flavor="x8664"
        gtm_install_flavor="x86_64" ;;
    solaris_sparc) # no Source Forge dirname
        gtm_ftp_dirname="sun"
        gtm_flavor="sparc"
        gtm_install_flavor="SPARC" ;;
    default) echo Architecture `uname -o` on `uname -m` not supported by this script ; err_exit ;;
esac

# GT.M version is required - first see if gtminstall and mumps are bundled
if [ -z "$gtm_version" ] ; then
    tmp=`dirname $0`
    if [ -e "$tmp/mumps" -a -e "$tmp/_XCMD.m" ] ; then
        gtm_distrib=$tmp
        gtm_dist=$tmp ; export gtm_dist
        chmod +x $gtm_dist/mumps
        tmp=`mktmpdir`
        gtmroutines="$tmp($gtm_dist)" ; export gtmroutines
        gtm_version=`$gtm_dist/mumps -run %XCMD 'write $piece($zversion," ",2)'`
        rm -rf $tmp
    fi
fi
if [ "Y" = "$gtm_verbose" ] ; then
    echo Determined architecture, OS and GT.M version ; dump_info
    wget_flags="-P"
else wget_flags="-qP"
fi

# See if GT.M version can be determined from meta data
if [ -z "$gtm_distrib" ] ; then
    gtm_distrib=http://sourceforge.net/projects/fis-gtm
fi
gtm_tmp=`mktmpdir`
mkdir $gtm_tmp/tmp
if [ -z "$gtm_version" -o "latest" = "`echo "$gtm_version" | tr LATES lates`" ] ; then
    case $gtm_distrib in
        http://sourceforge.net/projects/fis-gtm | https://sourceforge.net/projects/fis-gtm)
            if [ "Y" = "$gtm_verbose" ] ; then
		echo wget ${gtm_distrib}/files/${gtm_sf_dirname}/latest to determine latest version
		echo Check proxy settings if wget hangs
            fi
            if { wget $wget_flags $gtm_tmp ${gtm_distrib}/files/${gtm_sf_dirname}/latest 2>&1 1>${gtm_tmp}/wget_latest.log ; } ; then
                gtm_version=`cat ${gtm_tmp}/latest`
            else echo Unable to determine GT.M version ; err_exit
            fi ;;
        ftp://*)
            if [ "Y" = "$gtm_verbose" ] ; then
		echo wget $gtm_tmp ${gtm_distrib}/${gtm_ftp_dirname}/latest to determine latest version
		echo Check proxy settings if wget hangs
            fi
            if { wget $wget_flags $gtm_tmp ${gtm_distrib}/${gtm_ftp_dirname}/latest 2>&1 1>${gtm_tmp}/wget_latest.log ; } ; then
                gtm_version=`cat ${gtm_tmp}/latest`
            else echo Unable to determine GT.M version ; err_exit
            fi ;;
        *)
            if [ -f ${gtm_distrib}/latest ] ; then
                gtm_version=`cat ${gtm_distrib}/latest`
                if [ "Y" = "$gtm_verbose" ] ; then echo Version is $gtm_version ; fi
            else echo Unable to determine GT.M version ; err_exit
            fi ;;
    esac
fi
if [ -z "$gtm_version" ] ; then
echo GT.M version to install is required ; err_exit
fi

# Get GT.M distribution if gtminstall is not bundled with distribution
if [ -f "${gtm_distrib}/mumps" ] ; then gtm_tmp=$gtm_distrib
else
    tmp=`echo $gtm_version | tr -d .-`
    if [ -z "$gtm_filename" ] ; then
	    gtm_filename=gtm_${tmp}_${gtm_hostos}_${gtm_flavor}_${gtm_buildtype}.tar.gz
    fi
    case $gtm_distrib in
        http://sourceforge.net/projects/fis-gtm | https://sourceforge.net/projects/fis-gtm)
            if [ "Y" = "$gtm_verbose" ] ; then
		echo wget ${gtm_distrib}/files/${gtm_sf_dirname}/${gtm_version}/${gtm_filename} to download tarball
		echo Check proxy settings if wget hangs
            fi
            if { ! wget $wget_flags $gtm_tmp ${gtm_distrib}/files/${gtm_sf_dirname}/${gtm_version}/${gtm_filename} \
                2>&1 1>${gtm_tmp}/wget_dist.log ; } ; then
                echo Unable to download GT.M distribution $gtm_filename ; err_exit
            fi ;;
        ftp://*)
            if [ "Y" = "$gtm_verbose" ] ; then
		echo wget ${gtm_distrib}/${gtm_ftp_dirname}/${tmp}/${gtm_filename} to download tarball
		echo Check proxy settings if wget hangs
            fi
            if { ! wget $wget_flags $gtm_tmp ${gtm_distrib}/${gtm_ftp_dirname}/${tmp}/${gtm_filename} \
                2>&1 1>${gtm_tmp}/wget_dist.log ; } ; then
                echo Unable to download GT.M distribution $gtm_filename ; err_exit
            fi ;;
        *)
            if [ -f ${gtm_distrib}/${gtm_filename} ] ; then
                if [ "Y" = "$gtm_verbose" ] ; then echo tarball is ${gtm_distrib}/${gtm_filename} ; fi
                ln -s ${gtm_distrib}/${gtm_filename} $gtm_tmp
            else echo Unable to locate GT.M distribution file ${gtm_distrib}/${gtm_filename} ; err_exit
            fi ;;
    esac
    ( cd $gtm_tmp/tmp ; gzip -d < ${gtm_tmp}/${gtm_filename} | tar xf - 2>&1 1>${gtm_tmp}/tar.log )
fi
if [ "Y" = "$gtm_verbose" ] ; then echo Downloaded and unpacked GT.M distribution ; dump_info ; fi

# Check installation settings & provide defaults as needed
tmp=`$gtm_id -un`
if [ -z "$gtm_user" ] ; then gtm_user=$tmp
else if [ "$gtm_user" != "`$gtm_id -un $gtm_user`" ] ; then
    echo $gtm_user is a non-existent user ; err_exit
    fi
fi
if [ "root" = $tmp ] ; then
    if [ -z "$gtm_group" ] ; then gtm_group=`$gtm_id -gn`
    else if [ "root" != "$gtm_user" -a "$gtm_group" != "`$gtm_id -Gn $gtm_user | xargs -n 1 | $gtm_grep $gtm_group`" ] ; then
        echo $gtm_user is not a member of $gtm_group ; err_exit
        fi
    fi
 else
    echo Non-root installations not currently supported
    if [ "N" = "$gtm_dryrun" ] ; then err_exit
    else echo "Continuing because --dry-run selected"
    fi
fi
if [ -z "$gtm_installdir" ] ; then gtm_installdir=/usr/lib/fis-gtm/${gtm_version}_${gtm_install_flavor} ; fi
if [ -d "$gtm_installdir" -a "Y" != "$gtm_overwrite_existing" ] ; then
    echo $gtm_installdir exists and --overwrite-existing not specified ; err_exit
fi

issystemd=`command -v systemctl`
if [ -n "$issystemd" ] ; then
	# It is a systemd installation
	logindconf="/etc/systemd/logind.conf"
	removeipcopt=`awk -F = '/^RemoveIPC/ {opt=$2} END{print opt}' $logindconf`
	if [ "no" != "$removeipcopt" ] ; then
		# RemoveIPC=no is NOT the final settings in the file
		ipcissue1="If RemoveIPC=yes is configured for systemd, ipcs (database shm & sem)"
		ipcissue1="$ipcissue1 are removed for a non-system user's processes when that user logs out."
		ipcissue2="That can cause database operations to fail with mysterious errors."

		ipcline1="# GT.M : Override systemd default of RemoveIPC=yes to prevent automatic ipc removal of"
		ipcline1="$ipcline1 Shared Memory Segments and Semaphore Arrays of orphaned databases"
		ipcline2="RemoveIPC=no"
		ipccmd="systemctl restart systemd-logind"

		echo "$ipcissue1"
		echo "$ipcissue2"
		echo "The installation would like to add the below two lines to $logindconf"
		echo "   $ipcline1"
		echo "   $ipcline2"
		echo "And issue the below command to restart systemd-logind"
		echo "   $ipccmd"
		if [ "N" != "$gtm_prompt_for_sys_reconfig" ]; then
			echo -n "Do you wish to proceed (Y/N)? "
			answer=`read_yes_no`
			if [ "yes" != "$answer" ] ; then
				echo "Will abort installation"
				echo $ipcissue1
				echo $ipcissue2
				echo "Please add the below two lines to $logindconf"
				echo "   $ipcline1"
				echo "   $ipcline2"
				echo "and restart systemd-logind using the below command, for example or by rebooting the system"
				echo "   $ipccmd"
				echo "and retry GT.M installation"
				exit 1
			fi
			echo $ipcline1 >> $logindconf
			echo $ipcline2 >> $logindconf
			$ipccmd
		else
			echo "==============================================================="
			echo "Installation directed to not change systemd configuration files"
			echo "==============================================================="
		fi
	fi
fi
if [ "Y" = "$gtm_verbose" ] ; then echo Finished checking options and assigning defaults ; dump_info ; fi

# Prepare input to GT.M configure script
gtm_configure_in=${gtm_tmp}/configure_${timestamp}.in
if { ! $gtm_id -gn bin 2>/dev/null 1>/dev/null ; } then
    if [ "N" = "$gtm_prompt_for_group" -o 54002 -gt `echo $gtm_version | cut -s -d V -f 2- | tr -d A-Za-z.-` ] ; then
        echo y >>$gtm_configure_in
        echo root >>$gtm_configure_in
        echo $gtm_group_restriction >>$gtm_configure_in
        gtm_group_already="Y"
    fi
fi
echo $gtm_user >>$gtm_configure_in
if [ "Y" = "$gtm_prompt_for_group" -o 54002 -le `echo $gtm_version | cut -s -d V -f 2- | tr -d A-Za-z.-` ] ; then
    echo $gtm_group >>$gtm_configure_in
fi
if [ "N" = "$gtm_group_already" ] ; then
    echo $gtm_group_restriction >>$gtm_configure_in
fi
echo $gtm_installdir >>$gtm_configure_in
echo y >>$gtm_configure_in
if [ -z "$gtm_install_utf8" ] ; then echo n  >>$gtm_configure_in
else echo y  >>$gtm_configure_in
fi
echo $gtm_lcase_utils >>$gtm_configure_in
if [ "Y" = $gtm_shlib_support ] ; then echo $gtm_keep_obj >>$gtm_configure_in ; fi
echo y >>$gtm_configure_in
if [ "Y" = "$gtm_verbose" ] ; then echo Prepared configuration file ; cat $gtm_configure_in ; dump_info ; fi


# Run the GT.M configure script
if [ "$gtm_distrib" != "$gtm_tmp" ] ; then
    chmod +w $gtm_tmp/tmp
    cd $gtm_tmp/tmp
fi
tmp=`head -1 configure | cut -f 1`
if [ "#!/bin/sh" != "$tmp" ] ; then
    echo "#!/bin/sh" >configure.sh
fi
cat configure >>configure.sh
chmod +x configure.sh

# Stop here if this is a dry run
if [ "Y" = "$gtm_dryrun" ] ; then echo Installation prepared in $gtm_tmp ; exit ; fi

./configure.sh <$gtm_configure_in 1> $gtm_tmp/configure_${timestamp}.out 2>$gtm_tmp/configure_${timestamp}.err
if [ $? -gt 0 ] ; then cat $gtm_tmp/configure_${timestamp}.out $gtm_tmp/configure_${timestamp}.err ; fi
if [ "Y" = "$gtm_verbose" ] ; then echo Installation complete ; ls -l $gtm_installdir ; fi

# Create copies of environment scripts and gtm executable
if [ -d "$gtm_linkenv" ] ; then
    ( cd $gtm_linkenv ; ln -s $gtm_installdir/gtmprofile $gtm_installdir/gtmcshrc ./ )
    if [ "Y" = "$gtm_verbose" ] ; then echo Linked env ; ls -l $gtm_linkenv ; fi
else if [ -d "$gtm_copyenv" ] ; then
        ( cd $gtm_copyenv ; cp $gtm_installdir/gtmprofile $gtm_installdir/gtmcshrc ./ )
        if [ "Y" = "$gtm_verbose" ] ; then echo Copied env ; ls -l $gtm_copyenv ; fi
     fi
fi
if [ -d "$gtm_linkexec" ] ; then
    ( cd $gtm_linkexec ; ln -s $gtm_installdir/gtm ./ )
    if [ "Y" = "$gtm_verbose" ] ; then echo Linked exec ; ls -l $gtm_linkexec ; fi
else if [ -d "$gtm_copyexec" ] ; then
        ( cd $gtm_copyexec ; cp $gtm_installdir/gtm ./ )
        if [ "Y" = "$gtm_verbose" ] ; then echo Copied exec ; ls -l $gtm_copyexec ; fi
     fi
fi