This repository has been archived by the owner on Jan 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·1667 lines (1436 loc) · 49.3 KB
/
install
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
#!/bin/bash
#
# INSTALL.SH -- Install IRAF on the local machine, either as a system-wide
# facility, and/or for personal use. Root privileges are only required for
# a system installation.
#
# Usage:
# % install [opts]
#
# Where [opts] include:
#
# -h, --help # print help
# --version # print script version
#
# -n, --noop # no execute
# -d, --debug # debug output
# -v, --verbose # verbose output
# -s, --system # do a system install (needs root)
# -C, --csh # install C-shell scripts
#
# -t, --term <term> # set default terminal type
# -b, --bindir <dir> # set local bin directory
# -c, --cache <dir> # set cache directory
# -i, --imdir <dir> # set image directory
# -m, --mach <arch> # set architecture
# -r, --root <dir> # set iraf root directory
#
# -C, --oldcache <dir> # set old cache directory
# -I, --oldimdir <dir> # set old image directory
# -R, --oldroot <dir> # set old iraf root directory
#
#
# Initialize script variables.
if [ ! -n "$iraf" ]; then
export iraf=$PWD
fi
if [ -e "$iraf/unix/hlib/util.sh" ]; then
source $iraf/unix/hlib/util.sh
fi
if [ -e "${iraf}/unix/hlib/irafarch.sh" ]; then
mach=`${iraf}/unix/hlib/irafarch.sh ` # current platform architecture
hmach=`${iraf}/unix/hlib/irafarch.sh -hsi` # current HSI architecture
if [ -z "$IRAFARCH" ]; then
IRAFARCH=$mach
fi
elif [ -e "./unix/hlib/irafarch.sh" ]; then
mach=`./unix/hlib/irafarch.sh ` # current platform architecture
hmach=`./unix/hlib/irafarch.sh -hsi` # current HSI architecture
if [ -z "$IRAFARCH" ]; then
IRAFARCH=$mach
fi
else
mach=""
hmach=""
/bin/echo "Error: Cannot determine platform architecture, quitting."
/bin/echo ' : Try setting a $iraf or $IRAFARCH variable.'
exit 1
fi
if [ -e "${iraf}/.version" ]; then
VERSION=`cat ${iraf}/.version`
else
VERSION="v2.18"
fi
debug=0 # debug output
verbose=0 # verbose output
defterm="xgterm" # default terminal type
do_system=0 # system or personal install?
err_seen=0 # have errors been seen?
err_count=0 # error count
exec="yes" # take action?
old_links=0 # use old link method?
extn="sh" # shell script extension to use
LS="/bin/ls" # directory listing command
W='\([ "]\)' # match a blank, tab, or quote
TEMP="/tmp/iraf_install.$$" # temp output file
bindir="/usr/local/bin" # system local commands directory
imdir="" # image directory
cache="" # cache directory
p_iraf="" # <param> iraf root directory
p_imdir="" # <param> image directory
p_cache="" # <param> cache directory
o_iraf="" # old iraf root directory
o_imdir="" # old image directory
o_cache="" # old cache directory
# INSTALL_HELP -- Print script help.
install_help() {
ECHO ""
ECHO " Usage:"
ECHO " % install [opts]"
ECHO ""
ECHO " Where [opts] include:"
ECHO ""
ECHO " -h, --help # print help"
ECHO " --version # print script version"
ECHO ""
ECHO " -n, --noop # no execute"
ECHO " -d, --debug # debug output"
ECHO " -v, --verbose # verbose output"
ECHO " -s, --system # do a system install (needs root)"
ECHO " -C, --csh # install C-shell scripts"
ECHO ""
ECHO " -t, --term <term> # set default terminal type"
ECHO " -b, --bindir <dir> # set local bin directory"
ECHO " -c, --cache <dir> # set cache directory"
ECHO " -i, --imdir <dir> # set image directory"
ECHO " -m, --mach <arch> # set architecture"
ECHO " -r, --root <dir> # set iraf root directory"
ECHO ""
ECHO " -C, --oldcache <dir> # set old cache directory"
ECHO " -I, --oldimdir <dir> # set old image directory"
ECHO " -R, --oldroot <dir> # set old iraf root directory"
ECHO ""
ECHO ""
}
#=============================================================================
# Process command line arguments. The defaults are set to empty strings
# in order to allow them to be defined first on the command-line. In
# addition, if the 'sysinstall" option is used it will change how we
# look for installation directories.
#=============================================================================
while [ -n "$1" ] ; do
case "$1" in
"-h"|"-help"|"--help") # print script help
install_help
exit 0
;;
"-version"|"--version") # print script version
echo "$VERSION"
exit 0
;;
"-n"|"-noop"|"--noop") # no execute
exec=no
;;
"-d"|"-debug"|"--debug") # debug output
debug=1
;;
"-v"|"-verbose"|"--verbose") # verbose output
verbose=1
;;
"-s"|"-system"|"--system") # do a system-wide install?
do_system=1
;;
"-C"|"-csh"|"--csh") # install C-shell scripts
extn="csh"
;;
"-t"|"-term"|"--term") # set default terminal type.
defterm=$2 ; shift
;;
"-b"|"-bindir"|"--bindir") # set local bin directory
bindir=$2 ; shift
;;
"-c"|"-cache"|"--cache") # set cache directory
p_cache=$2 ; shift
;;
"-i"|"-imdir"|"--imdir") # set image directory
p_imdir=$2 ; shift
;;
"-m"|"-mach"|"--mach") # set architecture
mach=$2 ; hmach=$2 shift
;;
"-r"|"-root"|"--root") # set iraf root directory
p_iraf=$2 ; shift
if [ ! -n "$p_iraf" ]; then
export iraf=$p_iraf
fi
if [ -e "$iraf/unix/hlib/util.sh" ]; then
source $iraf/unix/hlib/util.sh
fi
if [ -e "${iraf}/unix/hlib/irafarch.sh" ]; then
mach=`${iraf}/unix/hlib/irafarch.sh`
fi
;;
"-C"|"-oldcache"|"--oldcache") # set old cache directory
o_cache=$2 ; shift
;;
"-I"|"-oldimdir"|"--oldimdir") # set old image directory
o_imdir=$2 ; shift
;;
"-R"|"-oldroot"|"--oldroot") # set old iraf root directory
o_iraf=$2 ; shift
;;
*)
MSG "Unknown option '$1'"
exit 1
;;
esac
if [ "$2" == "" ]; then
break
else
shift
fi
done
#=============================================================================
# Get the values of o_iraf and o_imdir from the current mkiraf.*sh file, if
# not already otherwise defined. Strip any trailing / in the pathname to be
# matched, so that the trailing /, if present, will be LEFT in the occurrence
# of the path in the file.
#=============================================================================
mkiraf=${iraf}/unix/hlib/mkiraf.sh
WS='[ ]'
if [ "$o_iraf" == "" ]; then
o_iraf=`grep "^iraf=" $mkiraf | sed -e "s+iraf=++" -e 's+"++g'`
fi
o_iraf=`echo $o_iraf | sed -e 's+/\(["]*\)$+\1+'`
if [ "$o_imdir" == "" ]; then
o_imdir=`grep "^imdir=" $mkiraf | sed -e "s+imdir=++" -e 's+"++g'`
fi
o_imdir=`echo $o_imdir | sed -e 's+/\(["]*\)$+\1+'`
if [ "$o_cache" == "" ]; then
o_cache=`grep "^cachedir=" $mkiraf | sed -e "s+cachedir=++" -e 's+"++g'`
fi
o_cache=`echo $o_cache | sed -e 's+/\(["]*\)$+\1+'`
#=============================================================================
# User Check
#
# If we're doing a private install, initialize the $HOME/.iraf directory.
#=============================================================================
# Get the current user name.
WHOAMI=`whoami`
if [ -e /usr/bin/whoami ]; then
WHOAMI=`/usr/bin/whoami`
elif [ -e /usr/ucb/whoami ]; then
WHOAMI=`/usr/ucb/whoami`
fi
if [ "$WHOAMI" == "root" ]; then
if (( $do_system==0 )); then
do_proceed="yes"
while [ "$do_proceed" == "yes" ]; do
BOLD_ON
ECHO "You are running as the root user: "
PROMPT "Install IRAF for all users on this machine?"
read ans
do_proceed="no"
if [ -n $ans ]; then
if [ "$ans" == "" -o "$ans" == "y" -o "$ans" == "yes" ]; then
ECHO "Proceeding with a system-wide install on this machine ..."
do_system=1
do_proceed="no"
elif [ "$ans" == "quit" -o "$ans" == "q" ]; then
exit 0
elif [ "$ans" == "no" -o "$ans" == "n" ]; then
ECHO "Proceeding with a personal install for 'root' ...."
do_system=0
do_proceed="no"
elif [ "$ans" == "help" -o "$ans" == "h" -o "$ans" == "?" ]; then
NEWLINE
MSG "If you proceed, IRAF will be installed on this machine for all"
MSG "users. This means that files and links will be put in the "
MSG "system directories such as /usr/include and a local bin dir,"
MSG "doing so requires root permission. If you say 'no', then IRAF"
MSG "will be installed as a personal system for the user."
NEWLINE
MSG "Type <cr> to continue, or 'q' to quit to exit."
NEWLINE
do_proceed="yes"
else
ECHO "Huh?"
do_proceed="yes"
fi
else
ECHO "Proceeding with a system-wide install on this machine ..."
do_system=1
do_proceed="no"
fi
done
fi
fi
if (( $do_system==0 )); then
if [ ! -e "$HOME/.iraf" ]; then
NEWLINE
ECHO "Initializing $HOME/.iraf directory ....."
NEWLINE
mkdir $HOME/.iraf
(cd $HOME/.iraf ; mkdir imdir cache bin)
fi
bindir="$HOME/.iraf/bin"
fi
#=============================================================================
clear
NEWLINE
BOLD_ON;
ECHO " ===================================="
ECHO " IRAF "$VERSION" Installation"
ECHO " ===================================="
BOLD_OFF
NEWLINE
ECHO " Welcome to the IRAF installation script. This script will first"
ECHO " prompt you for several needed path names. Once the installation is"
ECHO " complete, you will be allowed to do some minimal system configuration."
# Print a quick usage summary.
NEWLINE
ECHO -n " For each prompt: hit "
BOLD_ON ; ECHO -n "<CR>"; BOLD_OFF;
ECHO -n " to accept the default value, "
BOLD_ON ; ECHO -n "'q'" ; BOLD_OFF
ECHO ' to quit,'
ECHO -n " or "
BOLD_ON ; ECHO -n "'help'"; BOLD_OFF
ECHO -n " or ";
BOLD_ON ; ECHO -n "'?'"; BOLD_OFF
ECHO -n " to print an explanation of the prompt."
NEWLINE
NEWLINE
#=============================================================================
# Prompt the user for needed paths.
#=============================================================================
NEWLINE
BOLD_ON
ECHO "========================================================================"
ECHO "===================== Query for System Settings ======================"
ECHO "========================================================================"
BOLD_OFF
NEWLINE
#=============================================================================
# Set $iraf, the new root directory for iraf. The system must already have
# been read in at this directory (e.g., /iraf/iraf), but we assume that no
# files have yet been modified.
#=============================================================================
if [ "$iraf" == "" ]; then
if [ -e "IRAF.NET" -a -e "IS.PORT.GEN" ]; then
# Use the current directory.
d_iraf=`pwd`
else
# Make a guess at what the new root directory is.
d_iraf=""
if [ -d "/iraf/iraf" ]; then
d_iraf="/iraf/iraf"
elif [ -d "/opt/iraf/iraf" ]; then
d_iraf="/opt/iraf/iraf"
elif [ -d "/iraf" ]; then
d_iraf="/iraf"
elif [ -d "/usr/local/iraf" ]; then
d_iraf="/usr/local/iraf"
elif [ -d "/opt/iraf" ]; then
d_iraf="/usr/iraf"
elif [ -d "/usr/iraf" ]; then
d_iraf="/usr/iraf"
else
# Search for an iraf directory.
IDIRS=("/u* /local /home /opt /iraf* /")
for i in ${IDIRS[@]} ; do
if [ -d "$i/iraf" ]; then
d_iraf="$i/iraf"
break
fi
done
fi
if [ "$d_iraf" == "" ]; then
d_iraf="/iraf/iraf"
fi
fi
else
if [ -n "$p_iraf" ]; then
d_iraf=$p_iraf
else
d_iraf="$iraf"
fi
fi
iraf_prompt="yes"
while [ $iraf_prompt == "yes" ]; do
d_iraf=`ECHO $d_iraf | sed -e 's+/\(["]*\)$+\1+'`
iraf_prompt="no"
NEWLINE
BOLD_ON ; ECHO -n "New iraf root directory " ; BOLD_OFF
ECHO -n "($d_iraf): "
read iraf
if [ "$iraf" == "" ]; then
export iraf="$d_iraf"
break
elif [ "$iraf" == "quit" -o "$iraf" == "q" ]; then
exit 0
elif [ "$iraf" == "help" -o "$iraf" == "h" -o "$iraf" == "?" ]; then
NEWLINE
MSG "The iraf root directory is the place where the IRAF tar"
MSG "file was unpacked; it contains subdirectories such as 'dev',"
MSG "'local', 'noao', 'pkg', and the file IS.PORT.GEN."
di=$d_iraf
if [ -d $di/dev -a -d $di/pkg -a -d $di/noao ]; then
MSG ""
MSG "The default path '$d_iraf' appears to be correct ..."
else
MSG ""
MSG "The default path '$d_iraf' appears to be incorrect ..."
fi
NEWLINE
iraf=$d_iraf
iraf_prompt="yes"
fi
done
#=============================================================================
# Set $imdir, the default user image storage root directory. Each user imdir
# will be a subdirectory of this directory by default, when MKIRAF is run.
# Since bulk image data can consume hundreds of megabytes of disk space, IRAF
# likes to keep such data on a public scratch device, which is probably not
# backed up, which has a short file expiration interval, and possibly which
# has been configured (newfs/mkfs) with a large block size for fast seq. i/o.
#=============================================================================
if [ "$imdir" == "" ]; then
if (( $do_system==0 )); then
d_imdir="$HOME/.iraf/imdir/"
elif [ -d "$o_imdir" ]; then
d_imdir=$o_imdir
elif [ -d "/opt/iraf" ]; then
d_imdir=/opt/iraf/imdirs
elif [ -d "/iraf" ]; then
d_imdir=/iraf/imdirs
elif [ -d "/home/iraf" ]; then
d_imdir=/home/iraf/imdirs
elif [ -d "$iraf_p" ]; then
d_imdir=$iraf_p/imdirs
elif [ -d "/usr/local/iraf" ]; then
d_imdir=/usr/local/iraf/imdirs
else
d_imdir="/tmp"
fi
imdir_prompt="yes"
while [ "$imdir_prompt" == "yes" ]; do
imdir_prompt="no"
BOLD_ON ; ECHO -n "Default root image storage directory " ; BOLD_OFF
ECHO -n "($d_imdir): "
read imdir
if [ "$imdir" == "" ]; then
imdir="$d_imdir"
imdir_prompt="no"
elif [ "$imdir" == "quit" -o "$imdir" == "q" ]; then
exit 0
elif [ "$imdir" == "help" -o "$imdir" == "h" -o "$imdir" == "?" ]; then
NEWLINE
MSG "The root imdir directory is the default image storage dir"
MSG 'for OIF images (i.e. the ".imh" format) used by all users on'
MSG "this system. Individual user dirs will be created as needed."
MSG "It should be some large data disk on the machine which has a"
MSG "regular backup, scratch or tmp disks should be avoided or data"
MSG "may be lost."
MSG ""
MSG 'The "HDR$" syntax should not be used at this stage, please'
MSG 'edit the hlib$mkiraf.sh script after installation if you wish'
MSG "to make this the default."
export imdir=$d_imdir
imdir_prompt="yes"
fi
# Cannot have iraf and imdir the same.
if [ "$imdir" == "$iraf" ]; then
NEWLINE
MSG "The definition of imdir cannot be the same as the iraf"
MSG "root, please choose a different directory. Ideally this"
MSG "should be some large data area on your system or a user"
MSG "data area such as /home, /users, /u1, etc."
NEWLINE
NEWLINE
imdir_prompt="yes"
fi
done
fi
#=============================================================================
# Set $cache, the default user file cache root directory.
#=============================================================================
if [ "$cache" == "" ]; then
if (( $do_system==0 )); then
d_cache="$HOME/.iraf/cache/"
elif [ -d "/iraf" ]; then
d_cache="/iraf/cache"
elif [ -d "/home/iraf" ]; then
d_cache="/home/iraf/cache"
elif [ -d "$iraf_p" ]; then
d_cache="$iraf_p/cache"
elif [ -d "/usr/local/iraf" ]; then
d_cache="/usr/local/iraf/cache"
else
d_cache="/tmp"
fi
cache_prompt="yes"
while [ "$cache_prompt" == "yes" ]; do
cache_prompt="no"
BOLD_ON ; ECHO -n "Default root cache directory " ; BOLD_OFF
ECHO -n "($d_cache): "
read cache
if [ "$cache" == "" ]; then
cache="$d_cache"
cache_prompt="no"
elif [ "$cache" == "quit" -o "$cache" == "q" ]; then
exit 0
elif [ "$cache" == "help" -o "$cache" == "h" -o "$cache" == "?" ]; then
NEWLINE
MSG "The root cache directory is the default storage directory for"
MSG "URL-referenced files. Individual user dirs will be created as"
MSG "needed. It should be some large data disk on the machine "
MSG "which has a regular backup, scratch or tmp disks should be"
MSG "avoided or data may be lost."
MSG ""
NEWLINE
export cache=$d_cache
cache_prompt="yes"
fi
# Cannot have iraf and cache the same.
if [ "$cache" == "$iraf" ]; then
NEWLINE
MSG "The definition of cache cannot be the same as the iraf"
MSG "root, please choose a different directory. Ideally this"
MSG "should be some large data area on your system or a user"
MSG "data area such as /home, /users, /u1, etc."
NEWLINE
NEWLINE
cache_prompt="yes"
fi
done
fi
#=============================================================================
# Get UNIX directory where HSI commands (links) are to be installed, if not
# set on command line. IRAF will only install a very few new commands in this
# directory. Ideally it should be a directory on the standard user $path,
# so that users do not have to customize their . files just to run IRAF.
#=============================================================================
if [ "$lbin" == "" ]; then
# Look around and come up with a likely candidate directory.
if (( $do_system==0 )); then
d_lbin="$HOME/.iraf/bin/"
elif [ -d "/usr/local/bin" ]; then
d_lbin="/usr/local/bin"
elif [ -d "/opt/local/bin" ]; then
d_lbin="/opt/local/bin"
elif [ -d "/local/bin" ]; then
d_lbin="/local/bin"
else
d_lbin="/usr/bin"
fi
lbin_prompt="yes"
while [ "$lbin_prompt" == "yes" ]; do
lbin_prompt="no"
BOLD_ON ; ECHO -n "Local unix commands directory " ; BOLD_OFF
ECHO -n "($d_lbin): "
read lbin
if [ "$lbin" == "" ]; then
lbin="$d_lbin"
lbin_prompt="no"
elif [ "$lbin" == "quit" -o "$lbin" == "q" ]; then
exit 0
elif [ "$lbin" == "help" -o "$lbin" == "h" -o "$lbin" == "?" ]; then
NEWLINE
MSG "The local bin directory is the system directory into which the"
MSG "iraf commands (e.g. cl, mkiraf, mkpkg, etc) will be installed"
MSG "as symlinks to files in the iraf tree. This should be a common"
MSG "dir such as /usr/local/bin which will likely be found in every"
MSG "user's path."
NEWLINE
export lbin=$d_lbin
lbin_prompt="yes"
fi
# Create the local bin directory if it doesn't exist?
if [ ! -e $lbin ]; then
if (( $do_system==0 )); then
ans="yes"
else
BOLD_ON ;
ECHO -n " Sorry, but $lbin does not exist, create it? "
BOLD_OFF
read ans
fi
if [ "$ans" == "" -o "$ans" == "y" -o "$ans" == "yes" ]; then
ECHO " Creating directory $lbin..."
if [ "$exec" == "yes" ]; then
mkdir $lbin
if [ ! -e $lbin ]; then
ERRMSG "Cannot create $lbin, please retry..."
export lbin=$d_lbin
lbin_prompt="yes"
fi
fi
else
lbin_prompt="yes"
fi
NEWLINE
fi
done
fi
bindir=$lbin
# Prompt for the terminal to use in a private installation.
if (( $do_system==0 )); then
myterm="none"
BOLD_ON
ECHO "Terminal types: xgterm, xtermjh, xterm, etc."
ECHO -n 'Enter default terminal type ('
BOLD_OFF
ECHO -n $defterm
BOLD_ON
ECHO -n '): '
BOLD_OFF
read myterm
if [ -z "$myterm" ]; then
myterm=$defterm
fi
fi
#===============================================================================
# Determine iraf root directory
#===============================================================================
#===============================================================================
# Determine the old 'iraf', 'imdir' and 'cachedir' for editing.
#===============================================================================
#===============================================================================
# Verify the machine type.
#===============================================================================
if [ -e /usr/bin/uname ]; then
uname_cmd="/usr/bin/uname"
elif [ -e /bin/uname ]; then
uname_cmd="/bin/uname"
else
WARNING "No 'uname' command found to determine architecture."
exit 1
fi
export UNAME=`$uname_cmd | tr '[A-Z]' '[a-z]'`
if [ "$UNAME" == "sunos" ]; then
export UNAME_M=`$uname_cmd -m | cut -c2- | tr '[A-Z]' '[a-z]'`
else
export UNAME_M=`$uname_cmd -m | tr '[A-Z]' '[a-z]' | tr ' ' '_'`
fi
export OSVERSION=`$uname_cmd -r | cut -c1`
# ============================================
# The following is partially system dependent.
# ============================================
# Set the BINDIRS pathnames - directories where the HSI executables go.
host="$iraf/unix"
hbin="$iraf/unix/bin.$hmach"
hlib="$iraf/unix/hlib"
ibin="$iraf/bin.$IRAFARCH"
fbin="$iraf/bin"
# Replace any // by /.
host=`echo $host | sed -e "s+//+/+g"`
hbin=`echo $hbin | sed -e "s+//+/+g"`
fbin=`echo $fbin | sed -e "s+//+/+g"`
hlib=`echo $hlib | sed -e "s+//+/+g"`
# Strip any trailing /.
host=`echo $host | sed -e 's+/\(["]*\)$+\1+'`
hbin=`echo $hbin | sed -e 's+/\(["]*\)$+\1+'`
fbin=`echo $fbin | sed -e 's+/\(["]*\)$+\1+'`
hlib=`echo $hlib | sed -e 's+/\(["]*\)$+\1+'`
BINDIRS="$hbin $hlib $fbin $host"
# The following file lists are partially system dependent.
PATHFILES="mkiraf.csh mkiraf.sh libc/iraf.h cl.sh cl.csh ecl.sh ecl.csh setup.sh setup.csh"
MODEFILES="cl.sh cl.csh ecl.sh ecl.csh fc.sh fc.csh mkiraf.csh mkiraf.sh mkfloat.${extn} mkmlist.${extn} $host/reboot generic.e mkpkg.e rmbin.e rmfiles.e rpp.e rtar.e wtar.e xc.e xpp.e xyacc.e sgidispatch.e $hbin/sgi2*.e irafarch.sh irafarch.csh"
LINKFILES="ecl.${extn} cl.${extn} mkiraf.csh mkiraf.sh mkmlist.${extn} generic.e mkpkg.e rmbin.e rmfiles.e rtar.e sgidispatch.e wtar.e rpp.e xpp.e xyacc.e xc.e"
LINKCMDS=(ecl cl mkiraf mkmlist generic mkpkg rmbin rmfiles rtar sgidispatch wtar rpp xpp xyacc xc)
LTARGETS=(${hlib}/ecl.${extn} ${hlib}/cl.${extn} ${hlib}/mkiraf.sh ${hlib}/mkmlist.${extn} ${hbin}/generic.e ${hbin}/mkpkg.e ${hbin}/rmbin.e ${hbin}/rmfiles.e ${hbin}/rtar.e ${hbin}/sgidispatch.e ${hbin}/wtar.e ${hbin}/rpp.e ${hbin}/xpp.e ${hbin}/xyacc.e ${hbin}/xc.e)
CMDLINKS="ecl cl mkiraf mkmlist generic mkpkg rmbin rmfiles rtar sgidispatch wtar rpp xpp xyacc xc irafarch"
#===============================================================================
# Echo parameters, get go-ahead.
#===============================================================================
NEWLINE
BOLD_ON
ECHO "========================================================================"
ECHO "===================== Verifying System Settings ======================"
ECHO "========================================================================"
BOLD_OFF
NEWLINE
BOLD_ON; ECHO -n "Hostname = "; \
BOLD_OFF; ECHO `hostname` | awk '{printf("%-20.20s ", $1)}'
BOLD_ON; ECHO -n "OS version = "; \
BOLD_OFF; ECHO `$uname_cmd`" "`$uname_cmd -r`
BOLD_ON; ECHO -n "Architecture = "; \
BOLD_OFF; ECHO $mach | awk '{printf("%-20s ", $1)}'
BOLD_ON; ECHO -n "HSI arch = "; \
BOLD_OFF; ECHO $hmach | awk '{printf("%-20s\n", $1)}'
BOLD_ON; ECHO -n "Old iraf root = "; \
BOLD_OFF; ECHO $o_iraf | awk '{printf("%-20s ", $1)}'
BOLD_ON; ECHO -n "New iraf root = "; \
BOLD_OFF; ECHO $iraf | awk '{printf("%-20s\n", $1)}'
BOLD_ON; ECHO -n "Old imdir = "; \
BOLD_OFF; ECHO $o_imdir | awk '{printf("%-20s ", $1)}'
BOLD_ON; ECHO -n "New imdir = "; \
BOLD_OFF; ECHO $imdir | awk '{printf("%-s\n", $1)}'
BOLD_ON; ECHO -n "Old cache = "; \
BOLD_OFF; ECHO $o_cache | awk '{printf("%-20s ", $1)}'
BOLD_ON; ECHO -n "New cache = "; \
BOLD_OFF; ECHO $cache | awk '{printf("%-s\n", $1)}'
NEWLINE
BOLD_ON; ECHO -n "Local bin dir = "; \
BOLD_OFF; ECHO $bindir | awk '{printf("%-20s\n", $1)}'
NEWLINE ; NEWLINE
#=============================================================================
# Prompt for the go-ahead ...
#=============================================================================
do_proceed="yes"
while [ "$do_proceed" == "yes" ]; do
PROMPT "Proceed with installation? "
read ans
do_proceed="no"
if [ "$ans" == "" -o "$ans" == "y" -o "$ans" == "yes" ]; then
NEWLINE
do_proceed="no"
elif [ "$ans" == "quit" -o "$ans" == "q" ]; then
exit 0
elif [ "$ans" == "no" -o "$ans" == "n" ]; then
exit 0
elif [ "$ans" == "help" -o "$ans" == "h" -o "$ans" == "?" ]; then
NEWLINE
MSG "If you proceed, the system will be installed on this machine."
MSG "This means that command links will be placed in the local bin"
MSG "directory, needed system files will be created, and the iraf"
MSG "root path will be edited into key files. Stopping at this stage"
MSG "will have no side effects on your system or the iraf files."
MSG "Type <cr> to continue, or 'q' to quit to exit the installation."
NEWLINE
do_proceed="yes"
else
ECHO "Huh?"
do_proceed="yes"
fi
done
# Constraints:
#
# - validate iraf root directory
# - imdir cannot be under iraf root directory
# - cache cannot be under iraf root directory
# - check for write permission on iraf directory
#
# - if [ sysinstall ]; then
# - check we're running with root/sudo permissions
# - check file permissions to $iraf, $iraf/unix, $iraf/unix/hlib
# fi
#
# - check that bin directory exists
# - delete existing command directory
# Do the actual installation. This involves:
#
# 1) Editing the $iraf path into system files
# 2) Creating the <iraf.h> link
# 3) Creating the system command links
# 4) Creating the image directory (imdir)
# 5) Creating the cache directory (cache)
# 6) Tape setup (modes on alloc.e and /dev tape devices)
# 7) Graphics/Display file installation/setup
#=============================================================================
# See whether there is an existing commands dir we need to delete.
#=============================================================================
NEWLINE
BOLD_ON
ECHO "========================================================================"
ECHO "========================= Begin Installation ========================="
ECHO "========================================================================"
BOLD_OFF
NEWLINE
NEWLINE
ECHO -n "Checking for existing commands directory... "
cl_found=0
clpath=""
paths=`echo $PATH | sed -e "s/:/ /g"`
for d in ${paths[@]}; do
if [ -e "$d/cl" ]; then
cl_found=1
clpath="$d/cl"
break
fi
done
if (( $do_system==0 )); then
cl_found=0
fi
if (( $cl_found==1 )); then
o_lbin=${clpath%/*}
if [ "$o_lbin" != "$lbin" ]; then
DO_WARN
NEWLINE
MSG "IRAF commands were found in the directory:"
MSG ""
MSG " $o_lbin"
MSG ""
MSG " These commands may conflict with the commands now being"
MSG "installed in: '$lbin'"
MSG ""
del_cmd_="yes"
while [ "$del_cmd_" == "yes" ]; do
PROMPT "Do you want to delete commands in the old directory? "
read ans
del_cmd_="no"
if [ -n $ans ]; then
if [ "$ans" == "y" -o "$ans" == "yes" ]; then
NEWLINE
for i in ${CMDLINKS[@]}; do # remove the iraf commands
file=$o_lbin/$i
if [ -e "$file" ]; then
MSG "Deleting old command $file ..."
if [ "$exec"=="yes" ]; then
RM $file >> /dev/null 2>&1
fi
fi
done
del_cmd_="no"
elif [ "$ans" == "quit" -o "$ans" == "q" ]; then
exit 1
elif [ "$ans" == "no" -o "$ans" == "n" ]; then
junk=1 # fall through
del_cmd_="no"
elif [ "$ans" == "help" -o "$ans" == "h" -o "$ans" == "?" ]; then
NEWLINE
MSG "Multiple commands such as 'cl' or 'mkiraf' on a machine"
MSG "may cause errors (such as 'command not found' due to an"
MSG "invalid link), or confusions as to which version of iraf"
MSG "is being run if the old link is still valid. This is"
MSG "because the command being used depends on the order in"
MSG 'which the directories occur in the users "$path" environ-'
MSG "ment variable (which may vary by user)."
MSG ""
MSG "It is recommended there be only one iraf command directory"
MSG "on a given system, other methods can be used to start a"
MSG "different IRAF installation. This script will not auto-"
MSG "matically remove those links, and will only correct the"
MSG "path is the local bin directory is the same as before."
MSG ""
MSG "Type 'q' to quit and rerun the install script to specify"
MSG "a different local bin directory, 'yes' to remove the old"
MSG "links, and 'no' to leave the old commands around."
MSG ""
NEWLINE
del_cmd_="yes"
else
NEWLINE
for i in ${CMDLINKS[@]}; do # remove the iraf commands
file=$o_lbin/$i
if [ -e "$file" ]; then
MSG "Deleting old command $file ..."
if [ "$exec"=="yes" ]; then
RM $file >> /dev/null 2>&1
fi
fi
done
del_cmd_="no"
fi
fi
NEWLINE
done
else
DO_OK
fi
else
DO_OK
fi
# Step 1) Edit the $iraf path into the system files
NEWLINE
BOLD_ON
ECHO " Editing Paths"
ECHO " -------------"
BOLD_OFF
# Edit the $iraf pathname in the .login file for user 'iraf'.
if (( $do_system==0 )); then
ECHO -n "Editing the iraf user .login/.cshrc paths ... "
pfiles=("$iraf/local/.cshrc $iraf/local/.login")
else
ECHO -n "Editing the user .login/.cshrc paths ... "
if [ "$SHELL" == "/bin/csh" ]; then
pfiles=("$HOME/.cshrc $HOME/.login")
else
pfiles=("$HOME/.bashrc $HOME/.profile $HOME/.bash_profile $HOME/.bash_login")
fi
fi
for file in ${pfiles[@]}; do
if [ -e "$file" ]; then
if [ "$exec" == "yes" ]; then
RM $TEMP >& /dev/null
sed -e "s+$o_iraf+$iraf+" $file > $TEMP