File: Install

package info (click to toggle)
afbackup 3.1beta1-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 1,500 kB
  • ctags: 1,685
  • sloc: ansic: 22,406; csh: 3,597; tcl: 964; sh: 403; makefile: 200
file content (1394 lines) | stat: -rwxr-xr-x 37,271 bytes parent folder | download | duplicates (2)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
#! /bin/csh -f

set OSNAME=`uname -s|sed 's/[^a-zA-Z]//g'`

unalias cd
unalias cp
unalias mv

set servicename="afbackup"

if (-r Install.cache) then
  set noglob
  source Install.cache
  unset noglob
endif

set varstosave=(servinstdir username userid groupid defdev servvarinstdir clntinstdir clntvarinstdir port use_des des_header des_include des_lib des_libdir orduserrestore runclientconfig runserverconfig servicename)

set exitst=0

set pathext=(/usr/bin /bin /usr/ccs/bin /usr/ccs/lib /opt/gnu/bin /usr/local/bin /usr/local/gnu/bin /opt/bin /opt/gnu)

foreach newdir ($pathext)
  if (! -d $newdir) continue

  set found=0
  foreach dir ($path)
    if ($dir == $newdir) then
      set found=1
      break
    endif
  end
  if (! $found) then
    set path=($path $newdir)
  endif
end

rehash

set stack=()
alias gosub 'set stack=(\!:3 $stack); set __args=(\!:2) ; goto \!:1'
alias return 'set __lab=$stack[1] ; set stack=($stack[2-]) ; goto $__lab'
alias matches 'echo \!:1 |egrep -i \!:2|wc -l'
alias issymlink 'ls -l \!:1 |grep '^l'|wc -l'
alias do_exit 'goto exitlabel'

#foreach p ($path)
#  if (-x $p/cc) then
#    setenv CC cc
#    break
#  endif
#  if (-x $p/gcc) then
#    setenv CC gcc
#    break
#  endif
#end

set CONF_INTERPR=""
if (`matches $OSNAME HPUX`) set CONF_INTERPR=ksh

set adminprefix=/etc

set tmpfile=core.tmp.$$
set tmpfile2=core.tmp2.$$

set saved_files=""

set modes=(servonly clntonly clntrem all)

gosub which_make "" know_make
know_make:
set MAKEOPTS="EXTRA_CFLAGS=-DORIG_DEFAULTS"
set MAKECMD="make"
if ($?GNU_MAKE) then
  set MAKEOPTS="$MAKEOPTS MAKECMD=$GNU_MAKE"
  set MAKECMD=$GNU_MAKE
endif

set configure_options=""

clear
echo " "
echo 'Welcome to the installation procedure for'
echo " "
echo "AF's backup system *"
echo '=================='
echo " "
echo ' '
echo '(* People accustomed to Microsoft-publications please'
echo '   insert: hyper-optimized, ultra-reliable, turbo-speed,'
echo '   multimedia, leading technology, highest performance ...)'
echo ' '
echo 'You can interrupt this program any time hitting Ctrl-C. With some'
echo 'of the following questions a default answer will be offered in'
echo "square brackets. If you don't want to change this or don't know"
echo "how to set the value of the parameter, just hit the Return key."
echo " "
echo "First you have to decide, what functionality you"
echo 'would like to have on this machine.'
echo " "
echo '(1) Backup server only'
echo '(2) Backup client only (also to start backups on other hosts)'
echo '(3) Backup client only with remote start option'
echo '(4) Backup server, client and client remote start option'
echo " "

set sel=0
while (! `matches $sel '^[1-4]$'`)
  echo -n 'Please enter your selection [1-4]: '
  set sel=$<
  if (! `matches $sel '^[1-4]$'`) then
    echo "This is no valid selection. Please try again."
    echo " "
  endif
end

set mode=$modes[$sel]

onintr exitlabel

switch ($sel)
  case 1:
		gosub server_only "" contlab
		breaksw
  case 2:
		gosub client_only "" contlab
		breaksw
  case 3:
		gosub remclient "" contlab
		breaksw
  case 4:
		gosub all "" contlab
		breaksw
endsw

contlab:
echo " "
echo 'All done. The input supplied during this installation procedure'
echo 'is saved in the file "Install.cache". This file can be copied'
echo 'somewhere else to have the input present as default for the next'
echo 'upgrade or installation on other architectures. The file will be'
echo 'erased typing "make distclean".'

if (`echo $saved_files | wc -w` > 0) then
  echo " "
  echo "The following files are safety copies of files, that"
  echo "are crucial for your system. If up to now everything"
  echo "worked fine, you can safely remove them:"
  echo " "
  echo $saved_files
  echo ' '
endif

exitlabel:

set noglob
/bin/rm -f Install.cache
touch Install.cache
foreach var ($varstosave)
  eval 'set exists=$?'"$var"
  if ($exists) then
    set valuestr=`eval echo '$'$var`
    echo set $var"=($valuestr)" >> Install.cache
  endif
end

exit $exitst

### SERVER ONLY ###

server_only:
echo " "
echo "Ok, we're gonna install only the server side on this"
echo -n "machine. "

gosub server_install "" end_server_only

end_server_only:
return

### CLIENT ONLY ###

client_only:
echo " "
echo "Ok, we're gonna install only the client side on this"
echo -n "machine. "

gosub client_install "" end_client_only

end_client_only:
return

### REMOTELY STARTED CLIENT ###

remclient:
echo " "
echo "Ok, we're gonna install the client with remote start"
echo -n "option. "

gosub server_install "" end_remclient
end_remclient:
return

### CLIENT, SERVER AND REMOTE START OPTION ###

all:
echo " "
echo "Ok, we will install the client, server and remote start"
echo -n "option. "

gosub server_install "" end_allinst
end_allinst:
return

################ SERVER INSTALLATION #################

server_install:

if (! $?servinstdir) then
  set servinstdir=/usr/backup
endif

echo "First we have to specify, where to install the"
echo "files and programs. Please enter a directory of"
echo 'your choice (you may supply the same directory'
echo 'like for the client side).'
ask_for_servinstdir:
echo 'Is '$servinstdir' ok ? If yes, enter yes.'
echo 'Otherwise, please enter an alternate directory.'

choose_servinstdir:
echo " "
set choice="blub"
while (! `matches $choice '^(ye?s?|no?|/.*)$'`)
  echo -n 'Your choice (Yes/No/path) [Yes]: '
  set choice=$<
  if ("$choice" == "") set choice="yes"
  if (! `matches $choice '^(ye?s?|no?|/.*)$'`) then
    echo " "
    echo "This is no valid choice. Please Try again."
  endif
end
if (`matches $choice '^no?$'`) then
  echo "Please enter the directory."
  goto choose_servinstdir
endif
if (`matches $choice '^/'`) then
  set servinstdir=$choice
endif

gosub choose_DES "" chosen_DES_servonly
chosen_DES_servonly:

echo " "
echo "Now we have to build the programs. Please stand by"
echo "and watch for error messages. If any occur, you have"
echo "a problem. Warnings can usually be ignored. If errors"
echo 'occur, drop a mail to the author (af@muc.de)'
echo 'with the fault message(s) of make or try to patch the'
echo "stuff yourself. If you succeed, please also drop a"
echo "mail to the author, so your changes can be added to the"
echo "distribution."
echo " "
echo "Running configure now ..."
echo " "
$CONF_INTERPR ./configure -prefix="$servinstdir" --without-prefixext \
		--with-rexecdir="$servinstdir"/server/rexec \
		$configure_options
set s=$status
echo " "
if ($s != 0) then
  echo "Damn. Something went wrong. Please contact the author."
  echo "Stopping here."
  set exitst=1
  do_exit
endif

echo "Running make now ..."
echo " "
if ($mode == "all" || $mode == "clntrem") then
  $MAKECMD $MAKEOPTS
  set s=$status
else
  $MAKECMD server $MAKEOPTS
  set s=$status
endif

echo " "
if ($s != 0) then
  echo "Damn. Something went wrong. Please contact the author."
  echo "Stopping here."
  set exitst=1
  do_exit
endif

echo " "
echo "We're now going to install the files and programs."
echo " "
if ($mode == "all" || $mode == "clntrem") then
  $MAKECMD install install.rclient $MAKEOPTS
  set s=$status
else
  $MAKECMD install.server $MAKEOPTS
  set s=$status
endif

echo " "
if ($s != 0) then
  echo "Oops. This failed. Maybe your directory choice is"
  echo "somewhat problematic. Choose one of:"
  set c=b
  while (! `matches $c '^[ar]'`)
    echo -n 'Abort, Retry (A/R) [R]: '
    set c=$<
    if ("$c" == "" ) set c=r
  end
  if ($c == "a" || $c == "A") then
    set exitst=1
    do_exit
  else
    echo ' '
    goto ask_for_servinstdir
  endif
endif

\rm -f $tmpfile

gosub add_backup_service "" serv_serv_added

serv_serv_added:

if (! $?username) then
  if ($mode == "all" || $mode == "clntrem") then
    set username=root
  else
    set username=backup
  endif
endif

echo ' '
echo 'An entry for the backup service is necessary in the system'
echo "file $adminprefix/inetd.conf."
add_inetdline:
set inetdlinen=`grep '^[ 	]*'"$servicename" $adminprefix/inetd.conf|wc -l`
set inetdline=(`grep '^[ 	]*'"$servicename" $adminprefix/inetd.conf`)
if ($inetdlinen > 0) then
  echo "There is an entry for afbackup present in $adminprefix/inetd.conf."
  echo "It looks like this:"
  echo ' '
  grep '^[ 	]*'"$servicename" $adminprefix/inetd.conf
  echo ' '
  set def=No
  set i=($inetdline)
  if (! `matches $inetdline[6]"/" ^$servinstdir"/"`) then
    echo 'The directory path in this entry seems to be wrong (It'
    echo 'should be '$servinstdir'/... )'
    set def="Yes"
  endif
  if ($i[7] != "afserver") then
    echo 'The program name in this entry is wrong (it must be afserver).'
    set def="Yes"
  endif
  if ($i[5] != $username) then
    echo 'The username in this entry is wrong (should be '$username').'
    set def="Yes"
  endif
  if ($i[3] != "tcp" || $i[4] != "nowait" || $i[2] != "stream") then
    echo 'The protocol in this entry is wrong (we are using TCP).'
    set def="Yes"
  endif
  if ($def != "No") then
    echo " "
  endif
  echo 'Should we remove this entry and create a new one ?'
  inetdentry:
  echo ' '
  echo -n 'Your choice (Yes/No) ['$def']: '
  set c=blub
  while (! `matches $c '^(ye?s?|no?)$'`)
    set c=$<
    if ("$c" == "") set c=$def
    if (! `matches $c '^(ye?s?|no?)$'`) then
      echo ' '
      echo "Invalid choice. Please try again."
      goto inetdentry
    endif
  end
  if (`matches $c '^ye?s?$'`) then
    set panic=0
    cp $adminprefix/inetd.conf $adminprefix/inetd.conf.$$
    set saved_files=($saved_files $adminprefix/inetd.conf.$$)

    if (! -e $adminprefix/inetd.conf.$$) then
      echo "Panic: cannot make safety copy of $adminprefix/inetd.conf."
      echo "I'll not go on to add the entry. You have to do it yourself."
      set panic=1
    else
      grep -v '^[         ]*'"$servicename" $adminprefix/inetd.conf >! $tmpfile
      if (! -e $tmpfile) then
	echo "Error: removing entry from the system file failed."
	set panic=1
      else
        cp $tmpfile $adminprefix/inetd.conf
	if ($status) then
	  echo "Error: removing entry from the system file failed."
	  set panic=1
	endif
      endif
    endif
    if ($panic) then
      echo "The following line must be removed from $adminprefix/inetd.conf"
      echo ' '
      grep '^[ 	]*'"$servicename" $adminprefix/inetd.conf
      echo " "
      echo "Please hit enter, when you are done with it."
      set a=$<
    endif
    goto add_inetdline
  else
    set line=(`grep '^[         ]*'"$servicename" $adminprefix/inetd.conf`)
    set username=$line[5]
  endif
else
  echo ' '
  echo "Should we add an entry to $adminprefix/inetd.conf for the afbackup"
  echo 'service ? Default username is '$username'. If you do not'
  echo 'want to add an entry, just enter no. If you would like'
  echo 'to run the server under a different username, enter it.'
  echo 'If everything is ok, enter yes.'
  askaddinetd:
  echo ' '
  echo -n "Your choice (Yes/No/username) [Yes]: "
  set c=""
  set c=$<
  if ("$c" == "") set c=Yes
  if (! `matches $c '^(ye?s?|no?)$'`) then
    set username=$c
  endif
  if (! `matches $c '^no?$'`) then
    echo "$servicename	stream	tcp	nowait	$username	$servinstdir/server/bin/afserver afserver $servinstdir/server/lib/backup.conf" >> $adminprefix/inetd.conf
  endif
endif

echo ' '

if (`grep '[ 	]*'"$username": $adminprefix/passwd |wc -l` < 1) then
  echo "No user entry found for $username in $adminprefix/passwd."
  askadduser:
  echo ' '
  echo -n 'Should we add an entry (Yes/No) [Yes] ? '
  set c=blub
  while (! `matches $c '^(ye?s?|no?)$'`)
    set c=$<
    if ("$c" == "") set c=Yes
    if (! `matches $c '^(ye?s?|no?)$'`) then
      echo ' '
      echo "Invalid choice. Please try again."
      goto askadduser
    endif
  end
  if (`matches $c '^ye?s?$'`) then
    if (! $?userid) then
      set userid=2988
    endif
    while (`cut -f3 -d: $adminprefix/passwd|grep "^$userid"'$'|wc -l` > 0)
      @ userid++
    end
    echo " "
    echo "The default user-ID is $userid. If this is ok, just"
    echo "enter yes. If not, enter the desired ID."
    set c=blub
    askforuserid:
    while (! `matches $c '^(ye?s?|no?|[0-9][0-9]*)$'`)
      echo " "
      echo -n 'Your choice (Yes/No/userid) [Yes]: '
      set c=$<
      if ("$c" == "") set c='Yes'
      if (! `matches $c '^(ye?s?|no?|[0-9][0-9]*)$'`) then
        echo ' '
        echo 'This is no valid choice. Please try again.'
      endif
    end
    if (`matches $c '^[0-9][0-9]*$'`) then
      set userid=$c
    else
      if (`matches $c '^n'`) then
        echo "Please enter the desired user-ID."
        goto askforuserid
      endif
    endif
    if (`cut -f3 -d: $adminprefix/passwd|grep "^$userid"'$'|wc -l` > 0) then
      echo "Warning: A user entry with the user-ID $userid already exists"
      echo "     on the system. Using it nonetheless."
    endif

    if (! $?groupid) then
      set groupid=14
    endif
    while (`cut -f3 -d: $adminprefix/group|grep "^$groupid"'$'|wc -l` < 1)
      @ groupid--
    end
    echo " "
    echo "The default group-ID is $groupid. If this is ok, just"
    echo "enter yes. If not, enter the desired ID."
    set c=blub
    askforgroupid:
    while (! `matches $c '^(ye?s?|no?|[0-9][0-9]*)$'`)
      echo " "
      echo -n 'Your choice (Yes/No/groupid) [Yes]: '
      set c=$<
      if ("$c" == "") set c='Yes'
      if (! `matches $c '^(ye?s?|no?|[0-9][0-9]*)$'`) then
        echo ' '
        echo 'This is no valid choice. Please try again.'
      endif
    end
    if (`matches $c '^[0-9][0-9]*$'`) then
      set groupid=$c
      if (`cut -f3 -d: $adminprefix/group|grep "^$groupid"'$'|wc -l` < 1) then
	echo "Warning: A group entry with this group-ID does not exist"
	echo "    in the system. Using it nonetheless."
      endif
    else
      if (`matches $c '^n'`) then
        echo "Please enter the desired group-ID."
        goto askforgroupid
      endif
    endif

    set panic=0
    cp $adminprefix/passwd $adminprefix/passwd.$$
    set saved_files=($saved_files $adminprefix/passwd.$$)

    if (! -e $adminprefix/passwd.$$) then
      echo "Panic: cannot make safety copy of $adminprefix/passwd."
      echo "I'll not go on to add the user. You have to do it yourself."
      set panic=1
    else
      if (`grep '^+' $adminprefix/passwd|wc -l` > 0) then
        \rm -f $tmpfile $tmpfile2
        echo "/^+/ i\" >! $tmpfile
        echo "$username":x:"$userid":"$groupid":"Backup Server:$servinstdir/server:" \
  		>> $tmpfile
        sed -f $tmpfile $adminprefix/passwd >! $tmpfile2
        if ($status) then
  	  echo "Error: adding the user to the system file failed."
  	  set panic=1
        else
  	  cp $tmpfile2 $adminprefix/passwd
          if ($status) then
  	    echo "Error: adding the user to the system file failed."
  	    set panic=1
	  endif
        endif
      else
        echo "$username":x:"$userid":"$groupid":"Backup Server:$servinstdir/server:" \
		>> $adminprefix/passwd
      endif
    endif

    if ($panic) then
      echo "The following line must be added to $adminprefix/passwd"
      echo '(before the line starting with a +, if present):'
      echo ' '
      echo "$username":x:"$userid":"$groupid":"Backup Server:$servinstdir/server:"
      echo " "
      echo "Please hit enter, when you are done with it."
      set a=$<
    endif
  endif
endif

chown -R $username $servinstdir

if ($mode != "clntrem") then
  echo " "
  echo "Now we should change the owner of your tape device"
  echo "to user $username and give him exclusive access to it."
  echo "You may now enter a filename-pattern or no, if you"
  echo "want to skip this step. Here are the usual streamer"
  echo "device name patterns for some OS-es:"
  echo " "
  echo "Solaris:       /dev/rmt/[0-9]*"
  echo "AIX:           /dev/rmt[0-9]*"
  echo "IRIX:          /dev/rmt/tps[0-9]*"
  echo "HP-UX:         /dev/rmt/[0-9]*"
  echo "Linux:         /dev/st[0-9]* /dev/nst[0-9]*"
  echo "Digital UNIX:  /dev/rmt[0-9]* /dev/nrmt[0-9]*"
  echo "Free BSD:      /dev/rst[0-9]* /dev/nrst[0-9]*"

  if (! $?defdev) then
    switch (`uname -s`)
      case SunOS:
		set defdev="/dev/rmt/0*"
		breaksw
      case AIX:
		set defdev="/dev/rmt0*"
		breaksw
       case IRIX:
		set defdev="/dev/rmt/tps0d4*"
		breaksw
      case HP-UX:
		set defdev="/dev/rmt/0*"
		breaksw
      case Linux:
		set defdev="/dev/st0* /dev/nst0*"
		breaksw
      case OSF1:
		set defdev="/dev/rmt0* /dev/nrmt0*"
		breaksw
      case FreeBSD:
		set defdev="/dev/rst0* /dev/nrst0*"
		breaksw
      default:
		set defdev=""
    endsw
  endif

 seldev:
  echo " "
  echo -n "Your choice [$defdev]: "
  set c=""
  set c=$<
  if ("$c" == "") set c="$defdev"
  if (! `matches "$c" '^no?$'`) then
    chown $username $c
    set r=$status
    chmod 600 $c
    set r2=$status
    if ($r || $r2) then
      echo "Oops, this did not work. Please do it manually entering:"
      echo '(replace <devicenames> with your device-names pattern)'
      echo " "
      echo " chown $username <devicenames>"
      echo " chmod 600 <devicenames>"
      echo " "
      echo "Please hit return, when you are done with it or"
      echo "want to skip this step."
      set c=$<
    endif
  endif
  set defdev="$c"
endif


set PS1="ps -ef"
set PS2="ps -fp"

if (`matches $OSNAME linux` || `matches $OSNAME FreeBSD`) then
  set PS1="ps -uxa"
  set PS2="ps"
endif
if (`matches $OSNAME sunos`) then
  set REV=`uname -r|sed 's/[.].*$//g'`
  if ($REV < 5) then
    set PS1="ps -uxa"
    set PS2="ps"
  endif
endif

echo ' '

set inetdline=("`$PS1|grep -v grep|grep inetd`")
set running_inetds=`$PS1|grep -v grep|grep inetd|wc -l`
if ($running_inetds == 0) then
  echo "Sorry, i'm unable to figure out, what the process ID of the"
  echo 'inetd is like. Would you do me a favour and enter it here ?'
  askforinetdpid:
  echo ' '
  echo -n 'Process ID: '
  set pid=""
  set pid=$<
  if ("$pid" == "" || ! `matches $pid '^[0-9][0-9]*$'`) then
    echo ' '
    echo "Invalid input. Please try again."
    goto askforinetdpid
  endif
  $PS2 $pid >& /dev/null
  if ($status) then
    echo ' '
    echo "This is not the pid of the inetd. Please try again."
    goto askforinetdpid
  endif
  set inetdline=("`$PS2 $pid|grep -v grep|grep inetd`")
endif
if ($running_inetds > 1) then
  echo "Sorry, I found several processes looking like inetd."
  echo "Would you please give me a hint and tell me the real"
  echo 'process ID ? You may evaluate the following lines:'
  echo ' '
  $PS1|grep -v grep|grep inetd
  askfipid2:
  echo ' '
  echo -n 'Process ID: '
  set pid=""
  set pid=$<
  if ("$pid" == "" || ! `matches $pid '^[0-9][0-9]*$'`) then
    echo ' '
    echo "Invalid input. Please try again."
    goto askfipid2
  endif
  $PS2 $pid >& /dev/null
  if ($status) then
    echo ' '
    echo "This is not the pid of the inetd. Please try again."
    goto askfipid2
  endif
  set inetdline=("`$PS2 $pid|grep -v grep|grep inetd`")
endif
set inetdline=(`echo "$inetdline"|sed 's/[?*\[]/_/g;s/\]/_/g'`)
if ($running_inetds == 1) then
  set pid=$inetdline[2]
endif

echo ' '
echo "The process ID of the inetd seems to be $pid, the"
echo "appropriate entry in the process list is:"
echo ' '
echo "$inetdline"
asksendhup:
echo ' '
echo "To activate the backup service we can now send a HANGUP signal"
echo -n 'to the inetd. Do you want to do this (Yes/No) [Yes] ? '
set c=blub
while (! `matches $c '^(ye?s?|no?)$'`)
  set c=$<
  if ("$c" == "") set c=Yes
  if (! `matches $c '^(ye?s?|no?)$'`) then
    echo ' '
    echo "Invalid choice. Please try again."
    goto asksendhup
  endif
end
if (`matches $c '^ye?s?$'`) then
  sh -c "kill -1 $pid"
endif

if (! $?servvarinstdir) then
  set servvarinstdir=/var/logs/backup
endif
echo " "
echo "You might now want to move the variable part of the"
if ($mode == "all" || $mode == "clntrem") then
  echo -n "backup service"
else
  echo -n "server side"
endif
echo " installation to the /var-directory. The"
echo "default directory is $servvarinstdir. If you want to do"
echo "this and this directory is ok, just enter yes. If"
echo 'the directory is not ok, enter the desired one (you'
echo 'may supply the same as for the client side). If you'
echo "want to skip this step, just enter no."
mvservvar:
echo ' '
echo -n 'Your choice (Yes/No/path) [No]: '
set c=blub
while (! `matches $c '^(ye?s?|no?|/.*)$'`)
  set c=$<
  if ("$c" == "") set c=no
  if (! `matches $c '^(ye?s?|no?|/.*)$'`) then
    echo ' '
    echo "Invalid choice. Please try again."
    goto mvservvar
  endif
end
if (`matches $c '^/'`) then
  set servvarinstdir=$c
endif
if (! `matches $c '^no?$'`) then
  mkdir -p $servvarinstdir
  set curwd=`pwd`
  cd $servinstdir/server
  if (`issymlink var`) then
    echo "Warning: The directory seems to be moved already."
    echo "         Please check, where $servinstdir/server/var"
    echo "         points to. Not moving anything."
    goto eosvmove
  endif
  tar cf - var | (cd $servvarinstdir; tar xf -)
  mv $servvarinstdir/var $servvarinstdir/server
  \rm -rf var
  ln -s $servvarinstdir/server var
  eosvmove:

  if ($mode == "all" || $mode == "clntrem") then
    cd $servinstdir/client
    if (`issymlink var`) then
      echo "Warning: The directory seems to be moved already."
      echo "         Please check, where $servinstdir/client/var"
      echo "         points to. Not moving anything."
      goto eoclsvmove
    endif
    tar cf - var | (cd $servvarinstdir; tar xf -)
    mv $servvarinstdir/var $servvarinstdir/client
    \rm -rf var
    ln -s $servvarinstdir/client var
    eoclsvmove:
  endif

  cd $curwd
endif

if ($mode == "all" || $mode == "servonly") then
  if (! $?runserverconfig) then
    set runserverconfig=Yes
  endif
  echo ' '
  echo "Now we may run the program $servinstdir/server/bin/serverconfig,"
  echo "so you can configure the server side of the backup system. Would"
  echo 'you like to do this now ?'
  confserv:
  echo ' '
  echo -n "Your choice (Yes/No) [$runserverconfig]: "
  set c=blub
  while (! `matches $c '^(ye?s?|no?)$'`)
    set c=$<
    if ("$c" == "") set c=$runserverconfig
    if (! `matches $c '^(ye?s?|no?)$'`) then
      echo ' '
      echo "Invalid choice. Please try again."
      goto serv
    endif
  end
  set runserverconfig="$c"
  if (`matches $c 'ye?s?'`) then
    $servinstdir/server/bin/serverconfig
  endif
endif

if ($mode != "clntrem" && $mode != "servonly") then
  if (! $?orduserrestore) then
    set orduserrestore=No
  endif
  echo " "
  echo "Do you want ordinary users to be able to restore their"
  echo "own files and/or directories without administrator help ?"
  ordusersclnt:
  echo ' '
  echo -n "Your choice (Yes/No) [$orduserrestore]: "
  set c=blub
  while (! `matches $c '^(ye?s?|no?)$'`)
    set c=$<
    if ("$c" == "") set c=$orduserrestore
    while (! `matches $c '^(ye?s?|no?)$'`)
      echo ' '
      echo "Invalid choice. Please try again."
      goto ordusersclnt
    end
  end
  set orduserrestore=$c
  if (`matches $c 'ye?s?'`) then
    /bin/rm -f $servinstdir/client/bin/afrestore \
		$servinstdir/client/bin/afbackout \
		$servinstdir/client/bin/backout \
		$servinstdir/client/bin/restore
    cp $servinstdir/client/bin/full_backup \
		$servinstdir/client/bin/afrestore
    ln $servinstdir/client/bin/afrestore $servinstdir/client/bin/afbackout
    ln -s afbackout $servinstdir/client/bin/backout
    ln -s afrestore $servinstdir/client/bin/restore
    chmod 4755 $servinstdir/client/bin/afrestore
  endif
endif

if ($mode == "all" || $mode == "clntrem") then
  if (! $?runclientconfig) then
    set runclientconfig=Yes
  endif
  echo ' '
  echo "Now we may run the program $servinstdir/client/bin/clientconfig,"
  echo "so you can configure the client side of the backup system. Would"
  echo 'you like to do this now ?'
  confsclnt:
  echo ' '
  echo -n "Your choice (Yes/No) [$runclientconfig]: "
  set c=blub
  while (! `matches $c '^(ye?s?|no?)$'`)
    set c=$<
    if ("$c" == "") set c=$runclientconfig
    if (! `matches $c '^(ye?s?|no?)$'`) then
      echo ' '
      echo "Invalid choice. Please try again."
      goto confsclnt
    endif
  end
  set runclientconfig="$c"
  if (`matches $c 'ye?s?'`) then
    $servinstdir/client/bin/clientconfig
  endif
endif

return


################## CLIENT INSTALLATION ##################

client_install:
if (! $?clntinstdir) then
  set clntinstdir=/usr/backup
endif

echo "First we have to specify, where to install the"
echo "files and programs. Please enter a directory of"
echo 'your choice (you may supply the same directory'
echo 'like for the server side).'
ask_for_clntinstdir:
echo 'Is '$clntinstdir' ok ? If yes, enter yes.'
echo 'Otherwise, please enter an alternate directory.'

choose_clntinstdir:
echo " "
set choice="blub"
while (! `matches $choice '^(ye?s?|no?|/.*)$'`)
  echo -n 'Your choice (Yes/No/path) [Yes]: '
  set choice=$<
  if ("$choice" == "") set choice="yes"
  if (! `matches $choice '^(ye?s?|no?|/.*)$'`) then
    echo " "
    echo "This is no valid choice. Please Try again."
  endif
end
if (`matches $choice '^no?$'`) then
  echo "Please enter the directory."
  goto choose_clntinstdir
endif
if (`matches $choice '^/'`) then
  set clntinstdir=$choice
endif

gosub choose_DES "" chosen_DES_clnt
chosen_DES_clnt:

echo " "
echo "Now we have to build the programs. Please stand by"
echo "and watch for error messages. If any occur, you have"
echo "a problem. Warnings can usually be ignored. If errors"
echo "occur, drop a mail to the author"
echo '(af@muc.de)'
echo 'with the fault message(s) of make or try to patch the'
echo "stuff yourself. If you succeed, please also drop a"
echo "mail to the author, so your changes ca be added to the"
echo "distribution."
echo " "
echo "Running configure now ..."
echo " "
$CONF_INTERPR ./configure -prefix="$clntinstdir" --without-prefixext \
		--with-rexecdir="$clntinstdir"/server/rexec \
		$configure_options
set s=$status
echo " "
if ($s != 0) then
  echo "Damn. Something went wrong. Please contact the author."
  echo "Stopping here."
  set exitst=1
  do_exit
endif

echo "Running make now ..."
echo " "
$MAKECMD client $MAKEOPTS
set s=$status
echo " "
if ($s != 0) then
  echo "Damn. Something went wrong. Please contact the author."
  echo "Stopping here."
  set exitst=1
  do_exit
endif

echo " "
echo "We're now going to install the files and programs."
echo " "
$MAKECMD install.client $MAKEOPTS
set s=$status

echo " "
if ($s != 0) then
  echo "Oops. This failed. Maybe your directory choice is"
  echo "somewhat problematic. Choose one of:"
  set c=b
  while (! `matches $c '^[ar]'`)
    echo -n 'Abort, Retry (A/R) [R]: '
    set c=$<
    if ("$c" == "" ) set c=r
  end
  if ($c == "a" || $c == "A") then
    return
  else
    echo ' '
    goto ask_for_clntinstdir
  endif
endif

gosub add_backup_service "" clnt_serv_added

clnt_serv_added:

if (! $?clntvarinstdir) then
  set clntvarinstdir=/var/logs/backup
endif
echo " "
echo "You might now want to move the variable part of the"
echo "client side installation to the /var-directory. The"
echo "default directory is $clntvarinstdir. If you want to do"
echo "this and this directory is ok, just enter yes. If"
echo 'the directory is not ok, enter the desired one (you'
echo 'may supply the same as for the server side). If you'
echo "want to skip this step, just enter no."
mvclntvar:
echo ' '
echo -n 'Your choice (Yes/No/path) [No]: '
set c=blub
while (! `matches $c '^(ye?s?|no?|/.*)$'`)
  set c=$<
  if ("$c" == "") set c=no
  if (! `matches $c '^(ye?s?|no?|/.*)$'`) then
    echo ' '
    echo "Invalid choice. Please try again."
    goto mvclntvar
  endif
end
if (`matches $c '^/'`) then
  set clntvarinstdir=$c
endif
if (! `matches $c '^no?$'`) then
  mkdir -p $clntvarinstdir
  set curwd=`pwd`
  cd $clntinstdir/client
  if (`issymlink var`) then
    echo " "
    echo "Warning: The directory seems to be moved already."
    echo "         Please check, where $clntinstdir/client/var"
    echo "         points to. Not moving anything."
    goto eoclmove
  endif
  tar cf - var | (cd $clntvarinstdir; tar xf -)
  mv $clntvarinstdir/var $clntvarinstdir/client
  \rm -rf var
  ln -s $clntvarinstdir/client var
  eoclmove:
  cd $curwd
endif

if (! $?orduserrestore) then
  set orduserrestore=No
endif
echo " "
echo "Do you want ordinary users to be able to restore their"
echo "own files and/or directories without administrator help ?"
orduserclnt:
echo ' '
echo -n "Your choice (Yes/No) [$orduserrestore]: "
set c=blub
while (! `matches $c '^(ye?s?|no?)$'`)
  set c=$<
  if ("$c" == "") set c=$orduserrestore
  while (! `matches $c '^(ye?s?|no?)$'`)
    echo ' '
    echo "Invalid choice. Please try again."
    goto orduserclnt
  end
  set orduserrestore=$c
end
if (`matches $c 'ye?s?'`) then
  /bin/rm -f $clntinstdir/client/bin/afrestore \
		$clntinstdir/client/bin/afbackout \
		$clntinstdir/client/bin/backout \
		$clntinstdir/client/bin/restore
  cp $clntinstdir/client/bin/full_backup \
		$clntinstdir/client/bin/afrestore
  ln $clntinstdir/client/bin/afrestore $clntinstdir/client/bin/afbackout
  ln -s afbackout $clntinstdir/client/bin/backout
  ln -s afrestore $clntinstdir/client/bin/restore
  chmod 4755 $clntinstdir/client/bin/afrestore
endif

if (! $?runclientconfig) then
  set runclientconfig=Yes
endif
echo ' '
echo "Now we may run the program $clntinstdir/client/bin/clientconfig,"
echo "so you can configure the client side of the backup system. Would"
echo 'you like to do this now ?'
confclnt:
echo ' '
echo -n "Your choice (Yes/No) [$runclientconfig]: "
set c=blub
while (! `matches $c '^(ye?s?|no?)$'`)
  set c=$<
  if ("$c" == "") set c=$runclientconfig
  if (! `matches $c '^(ye?s?|no?)$'`) then
    echo ' '
    echo "Invalid choice. Please try again."
    goto confclnt
  endif
end
set runclientconfig="$c"
if (`matches $c 'ye?s?'`) then
  $clntinstdir/client/bin/clientconfig
endif

return


####### add afbackup entry to /etc/services

add_backup_service:

echo ' '
echo 'An entry for the backup service is necessary in the system'
echo "file $adminprefix/services."
add_service:
set servicesline=`grep '^[ 	]*'"$servicename" $adminprefix/services|wc -l`
if ($servicesline > 0) then
  echo "There is an entry for afbackup present in $adminprefix/services."
  echo "It looks like this:"
  echo ' '
  grep '^[ 	]*'"$servicename" $adminprefix/services
  echo ' '
  echo 'Should we remove this entry and create a new one ?'
  serventry:
  echo ' '
  echo -n 'Your choice (Yes/No) [No]: '
  set c=blub
  while (! `matches $c '^(ye?s?|no?)$'`)
    set c=$<
    if ("$c" == "") set c=no
    if (! `matches $c '^(ye?s?|no?)$'`) then
      echo ' '
      echo "Invalid choice. Please try again."
      goto serventry
    endif
  end
  if (`matches $c '^ye?s?$'`) then
    set panic=0
    cp $adminprefix/services $adminprefix/services.$$
    set saved_files=($saved_files $adminprefix/services.$$)

    if (! -e $adminprefix/services.$$) then
      echo "Panic: cannot make safety copy of $adminprefix/services."
      echo "I'll not go on to add the entry. You have to do it yourself."
      set panic=1
    else
      grep -v '^[ 	]*'"$servicename" $adminprefix/services >! $tmpfile
      if (! -e $tmpfile) then
	echo "Error: removing entry from the system file failed."
	set panic=1
      else
        cp $tmpfile $adminprefix/services
	if ($status) then
	  echo "Error: removing entry from the system file failed."
	  set panic=1
	endif
      endif
    endif
    if ($panic) then
      echo "The following line must be removed from $adminprefix/services"
      echo ' '
      grep '^[ 	]*'"$servicename" $adminprefix/services
      echo " "
      echo "Please hit enter, when you are done with it."
      set a=$<
    endif
    goto add_service
  endif    
else
  if (! $?port) then
    set port=2988
  endif
  while (`grep -i $port/tcp $adminprefix/services|grep -v $servicename|wc -l` > 0)
    @ port++
  end
 portserviceselection:
  if ($port == 2988) then
    set hint=' (hex 0xbac)'
  else
    set hint=''
  endif
  echo ' '
  echo "Should we add an entry to $adminprefix/services for the afbackup"
  echo 'service ? Default port number is '$port$hint'. If'
  echo 'you do not want to add an entry, just enter no. If you'
  echo 'would like to use a different port number, enter it. If'
  echo 'you want a service name different from '"$servicename"','
  echo 'enter it (all lowercase letters, numbers or -, please).'
  echo 'If everything is ok, enter yes.'
  set c="_-_"
  while (! `matches $c '^(ye?s?|no?|[0-9][0-9]*|[a-z][a-z0-9-]*)$'`)
    echo " "
    echo -n 'Your choice (Yes/No/port/servicename) [Yes]: '
    set c=$<
    if ($c == "") set c='Yes'
    if (! `matches $c '^(ye?s?|no?|[0-9][0-9]*|[a-z][a-z0-9-]*)$'`) then
      echo ' '
      echo 'This is no valid choice. Please try again.'
    endif
  end
  if (`matches $c '^[0-9][0-9]*$'`) then
    set port=$c
    echo " "
    echo "Ok, port number changed to $c."
    if (`grep '^[ 	]*[a-z][a-z0-9-]*[ 	][ 	]*'"$c/"'[tT][Cc][Pp]' $adminprefix/services|wc -l` > 0) then
      echo "Warning: Port number $c is already used in $adminprefix/services."
    endif
    goto portserviceselection
  endif
  if (`matches $c '^[a-z][a-z0-9-]*$'` && ! `matches $c 'yes'`) then
    set servicename="$c"
    echo " "
    echo "Ok, service name changed to $c."
    if (`grep '^[ 	]*'"$c"'[ 	][ 	]*[1-9][0-9]*/[tT][Cc][Pp]' $adminprefix/services|wc -l` > 0) then
      echo "Warning: service name $c is already used in $adminprefix/services."
    endif
    goto portserviceselection
  endif
  if (! `matches $c '^no?$'`) then
    echo "$servicename		$port/tcp" >> $adminprefix/services
  endif
endif

\rm -f $tmpfile

return


which_make:

gmake -v >& /dev/null
if (! $status) then
  setenv GNU_MAKE gmake
  return
endif

make -v >& /dev/null
if ($status) then
  unsetenv GNU_MAKE
  return
endif

if (`make -v|grep GNU|wc -l` > 0) then
  setenv GNU_MAKE make
  return
endif

setenv GNU_MAKE gmake

return

###########################################################################

choose_DES:

echo " "
echo "Will we use 128 Bit DES encryption for authenticating the"
echo "client to the server ? (Eric Young's DES library (currently"
echo "version 3.23) is required and by default expected in the"
echo "directory ../libdes. The defaults can be modified in the"
echo "following section, when answering yes) If no, the old style"
echo "encryption is performed."

if (! $?use_des) then
  set use_des=No
endif

gosub yes_no $use_des DES_yesno
DES_yesno:

set use_des=$yesno
if ($yesno == "no") then
  return
endif

set configure_options="$configure_options --with-des"

if (! $?des_header) then
  set des_header=des.h
endif

echo " "
echo "Please enter the name of the DES-library's header file"
gosub mult_choice "$des_header [^ ]*" DES_have_header
DES_have_header:

set des_header="$the_choice"

if (! $?des_include) then
  set des_include=../libdes
endif

echo " "
echo "Please enter the directory, where "$des_header" can be found"

gosub mult_choice "$des_include [^ ]*" DES_have_include
DES_have_include:

set des_include="$the_choice"

if (! -e $des_include/$des_header) then
  echo " "
  echo "Warning: File '$des_include/$des_header' does not exist."
endif

set configure_options="$configure_options --with-des-include=$des_include"
set configure_options="$configure_options --with-des-header=$des_header"

if (! $?des_lib) then
  set des_lib=-ldes
endif

echo " "
echo "Please enter the specifier of the DES-library for linking"
gosub mult_choice "$des_lib [^ ]*" DES_have_lib
DES_have_lib:

set des_lib="$the_choice"
if (`matches "$des_lib" '^lib'`) then
  set des_lib=`echo $des_lib|sed 's#^lib#-l#g;s#[.].*##g'`
endif
set deslibfile=`echo $des_lib|sed 's#^-l#lib#g'`'.*'

if (! $?des_libdir) then
  if ($?des_include) then
    set des_libdir=`echo $des_include|sed 's#/include$#/lib#g'`
  else
    set des_libdir=../libdes
  endif
endif

echo " "
echo "Please enter the directory, where the DES library can be found"

gosub mult_choice "$des_libdir [^ ]*" DES_have_libdir
DES_have_libdir:

set des_libdir="$the_choice"

ls $des_libdir/$deslibfile >& /dev/null
if ($status) then
  echo " "
  echo "Warning: File '$des_libdir/$deslibfile' does not exist."
else
  set deslibfile=`basename $des_libdir/$deslibfile`
endif

set configure_options="$configure_options --with-des-libdir=$des_libdir"
set configure_options="$configure_options --with-des-ldflag=$des_lib"

return

###########################################################################

yes_no:

set yesno=blub
echo " "
echo -n 'Your choice (Yes/No) ['$__args']: '
set yesno=$<
if ($yesno == "") set yesno=$__args
if (! `matches $yesno '^(ye?s?|no?)$'`) then
  echo ' '
  echo 'This is no valid choice. Please try again.'
  goto yes_no
endif

if (`matches $yesno '^ye?s?$'`) then
  set yesno="yes"
else
  set yesno="no"
endif

return

###########################################################################

mult_choice:

set noglob
set defaultsel=`echo "$__args"|awk '{print $1}'`
set validch=`echo "$__args"|awk '{printf "%s",$2; for(i=3;i<=NF;i++) printf " %s", $i}'`

echo " "
set the_choice=blub
echo -n 'Your choice ['$defaultsel']: '
set the_choice="$<"
if ("$the_choice" == "") set the_choice=$defaultsel
if (! `matches "$the_choice" '^'"$validch"'$'`) then
  echo ' '
  echo 'This is no valid choice. Please try again.'
  goto mult_choice
endif
unset noglob

return