forked from lordal/SWAMID-IDP-Deployer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy_idp.sh
executable file
·1824 lines (1604 loc) · 58.9 KB
/
deploy_idp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# UTF-8
HELP="
##############################################################################
# Federated Identity Appliance Deployer #
# #
# This script is intended to deploy an eduroam ready FreeRADIUS server. #
# It is derived from the SWAMID approach but only supports CAF eduroam #
# at this time. #
# #
# Supported Federations: #
# CAF - (Canadian Access Federation) on CentOS #
# #
# This script requires a configuration file or it will not run properly. #
# Please see ./www/index.html for the interactive configuration builder #
# By using this method we avoid storage of any sensitive passwords. #
# #
# Steps to use the script: #
# Create a configuration via: ~/www/index.html #
# Save the config in this directory #
# Run the script: ./deploy_idp.sh [-h shows this message] #
# Join this machine to your domain: net join -U Administrator #
# Decide on your commercial TLS Certificate #
# Send your request to tickets@canarie.ca to join eduroam #
##############################################################################
"
##############################################################################
# Deployment Profiles: SWAMID, CAF #
# #
# ___ SWAMID: #
# Deploys a working IDP for SWAMID on an Ubuntu system #
# Uses: jboss-as-distribution-6.1.0.Final or tomcat6 #
# shibboleth-identityprovider-2.4.0 #
# cas-client-3.2.1-release #
# mysql-connector-java-5.1.24 (for EPTID) #
# #
# Originators of this deployment script by Anders Lördal #
# Högskolan i Gävle and SWAMID #
# Please send SWAMID questions and improvements to: anders.lordal@hig.se #
# #
# ___ Canadian Access Federation (CAF): #
# Deploys a working IDP for CAF on an CentOS system #
# Uses: #
# Java: java-1.6.0-openjdk-devel #
# Servlet Container: tomcat6 #
# IDP Software: shibboleth-identityprovider-2.4.0 #
# mysql-connector-java-5.1.24 (for EPTID) #
# #
# #
# RADIUS Software: freeRADIUS 2.1.12 and related #
# Connectivity to AD: samba & related utilities #
# Please send CAF questions and improvements to: tickets@canarie.ca #
# #
# Notes #
# Templates are provided for CAS and LDAP authentication #
# To add a new template for another authentication, just add a new directory #
# under the 'prep' directory, add the neccesary .diff files and add any #
# special hanlding of those files to the script. #
# #
# You can pre-set configuration values in the file 'config' #
# #
##############################################################################
mdSignerFinger="12:60:D7:09:6A:D9:C1:43:AD:31:88:14:3C:A8:C4:B7:33:8A:4F:CB"
# Set cleanUp to 0 (zero) for debugging of created files
cleanUp=0
# Default enable of whiptail UI
GUIen=y
GUIbacktitle="Federated Identity Appliance Deployer"
# Version of shibboleth IDP
shibVer="2.4.0"
# Default values
upgrade=0
Spath="$(cd "$(dirname "$0")" && pwd)"
backupPath="${Spath}/backups/"
templatePath="${Spath}/assets"
backupList="${backupPath}/recoverypoints.txt"
files=""
ts=`date "+%s"`
whiptailBin=`which whiptail`
whipSize="16 75"
certpath="/opt/shibboleth-idp/ssl/"
httpsP12="/opt/shibboleth-idp/credentials/https.p12"
certREQ="${certpath}tomcat.req"
FQDN=`hostname`
FQDN=`host -t A ${FQDN} | awk '{print $1}'`
Dname=`echo ${FQDN} | cut -d\. -f2-`
if [ "${FQDN}" = "Host" ]
then
myInterface=`netstat -nr |grep "^0.0.0.0" |awk '{print $NF}'`
myIP=`ip addr list ${myInterface} |grep "inet " |cut -d' ' -f6|cut -d/ -f1`
Dname=`host -t A ${myIP} | awk '{print $NF}' | cut -d\. -f2- | sed 's/\.$//'`
FQDN=`host -t A ${myIP} | awk '{print $NF}' | sed 's/\.$//'`
fi
passGenCmd="openssl rand -base64 20"
messages="${Spath}/msg.txt"
statusFile="${Spath}/status.log"
echo "" > ${statusFile}
bupFile="/opt/backup-shibboleth-idp.${ts}.tar.gz"
idpPath="/opt/shibboleth-idp/"
certificateChain="http://webkonto.hig.se/chain.pem"
tomcatDepend="https://build.shibboleth.net/nexus/content/repositories/releases/edu/internet2/middleware/security/tomcat6/tomcat6-dta-ssl/1.0.0/tomcat6-dta-ssl-1.0.0.jar"
dist=""
distCmdU=""
distCmd1=""
distCmd2=""
distCmd3=""
distCmd4=""
distCmd5=""
fetchCmd="curl --silent -k --output"
shibbURL="http://shibboleth.net/downloads/identity-provider/${shibVer}/shibboleth-identityprovider-${shibVer}-bin.zip"
casClientURL="http://downloads.jasig.org/cas-clients/cas-client-3.2.1-release.zip"
tmp1sstr="These are the installers settings it will run with:\n\n"
# read config file
if [ -f "${Spath}/config" ]
then
. ${Spath}/config # dynamically (or by hand) editted config file
. ${Spath}/config_descriptions # descriptive terms for each element - uses associative array cfgDesc[varname]
fi
freeradiusfile="${Spath}/files/freeradius.tx"
##### FUNCTIONS #####
# cleanup function
cleanBadInstall() {
if [ -d "/opt/shibboleth-identityprovider" ]
then
rm -rf /opt/shibboleth-identityprovider*
fi
if [ -L "/opt/jboss" ]
then
rm -rf /opt/jboss*
fi
if [ -d "/opt/cas-client-3.2.1" ]
then
rm -rf /opt/cas-client-3.2.1
fi
if [ -d "/opt/ndn-shib-fticks" ]
then
rm -rf /opt/ndn-shib-fticks
fi
if [ -d "/opt/shibboleth-idp" ]
then
rm -rf /opt/shibboleth-idp
fi
if [ -d "/opt/mysql-connector-java-5.1.24" ]
then
rm -rf /opt/mysql-connector-java-5.1.24
fi
if [ -f "/usr/share/tomcat6/lib/tomcat6-dta-ssl-1.0.0.jar" ]
then
rm /usr/share/tomcat6/lib/tomcat6-dta-ssl-1.0.0.jar
fi
}
# find java home
setJavaHome () {
javaBin=`which java`
if [ -z "${JAVA_HOME}" ]
then
# check java
if [ -L "${javaBin}" ]
then
export JAVA_HOME=`readlink -f ${javaBin} | awk -F'bin' '{print $1}'`
else
if [ -s "${javaBin}" ]
then
export JAVA_HOME=`${javaBin} -classpath ${Spath}/files/ getJavaHome`
else
echo "No java found, please install JRE"
exit 1
fi
fi
if [ -z "`grep 'JAVA_HOME' /root/.bashrc`" ]
then
echo "export JAVA_HOME=${JAVA_HOME}" >> /root/.bashrc
fi
fi
}
installStateStatusString=""
installStateFSSO=0
installStateEduroam=0
setInstallStatus() {
# check for installed IDP
msg_FSSO="Federated SSO/Shibboleth:"
msg_RADIUS="eduroam read FreeRADIUS:"
if [ -L "/opt/shibboleth-identityprovider" -a -d "/opt/shibboleth-idp" ]
then
msg_fsso_stat="Installed"
installStateFSSO=1
else
msg_fsso_stat="Not Installed yet"
installStateFSSO=0
fi
if [ -L "/etc/raddb/sites-enabled/eduroam-inner-tunnel" -a -d "/etc/raddb" ]
then
msg_freeradius_stat="Installed"
installStateEduroam=1
else
msg_freeradius_stat="Not Installed yet"
installStateEduroam=0
fi
getStatusString="System state:\n${msg_FSSO} ${msg_fsso_stat}\n${msg_RADIUS} ${msg_freeradius_stat}"
}
refresh() {
${whiptailBin} --backtitle "${GUIbacktitle}" --title "Deploy/Refresh relevant eduroam software base" --defaultno --yes-button "Yes, proceed" --no-button "No, back to main menu" --yesno --clear -- \
"Create restore point and refresh machine to CAF eduroam base?" ${whipSize} 3>&1 1>&2 2>&3
continueFwipe=$?
if [ "${continueFwipe}" -eq 0 ]
then
eval ${redhatCmdEduroam}
echo ""
echo "Update Completed" >> ${statusFile} 2>&1
fi
displayMainMenu
}
review(){
if [ "${GUIen}" = "y" ]
then
${whiptailBin} --backtitle "${GUIbacktitle}" --title "Review Install Settings" --ok-button "Return to Main Menu" --scrolltext --clear --textbox ${freeradiusfile} 20 75 3>&1 1>&2 2>&3
displayMainMenu
else
echo "Please make sure whiptail is installed"
fi
}
deployCustomizations() {
# flat copy of files from deployer to OS
cp ${templatePath}/etc/nsswitch.conf.template /etc/nsswitch.conf
cp ${templatePath}/etc/raddb/sites-available/default.template /etc/raddb/sites-available/default
cp ${templatePath}/etc/raddb/sites-available/eduroam.template /etc/raddb/sites-available/eduroam
cp ${templatePath}/etc/raddb/sites-available/eduroam-inner-tunnel.template /etc/raddb/sites-available/eduroam-inner-tunnel
cp ${templatePath}/etc/raddb/eap.conf.template /etc/raddb/eap.conf
chgrp radiusd /etc/raddb/sites-available/*
# remove and redo symlink for freeRADIUS sites-available to sites-enabled
(cd /etc/raddb/sites-enabled;rm -f eduroam-inner-tunnel; ln -s ../sites-available/eduroam-inner-tunnel eduroam-inner-tunnel)
(cd /etc/raddb/sites-enabled;rm -f eduroam; ln -s ../sites-available/eduroam)
#rm -f /etc/raddb/sites-available/eduroam-inner-tunnel
#ln -s /etc/raddb/sites-available/eduroam-inner-tunnel /etc/raddb/sites-enabled/eduroam-inner-tunnel
#rm -f /etc/raddb/sites-available/eduroam
#ln -s /etc/raddb/sites-available/eduroam /etc/raddb/sites-enabled/eduroam
# do parsing of templates into the right spot
# in order as they appear in the variable list
# /etc/krb5.conf
cat ${templatePath}/etc/krb5.conf.template \
|perl -npe "s#kRb5_LiBdEf_DeFaUlT_ReAlM#${krb5_libdef_default_realm}#" \
|perl -npe "s#kRb5_DoMaIn_ReAlM#${krb5_domain_realm}#" \
|perl -npe "s#kRb5_rEaLmS_dEf_DoM#${krb5_realms_def_dom}#" \
> /etc/krb5.conf
# /etc/samba/smb.conf
cat ${templatePath}/etc/samba/smb.conf.template \
|perl -npe "s#sMb_WoRkGrOuP#${smb_workgroup}#" \
|perl -npe "s#sMb_NeTbIoS_NaMe#${smb_netbios_name}#" \
|perl -npe "s#sMb_PaSsWd_SvR#${smb_passwd_svr}#" \
|perl -npe "s#sMb_ReAlM#${smb_realm}#" \
> /etc/samba/smb.conf
# /etc/raddb/modules
cat ${templatePath}/etc/raddb/modules/mschap.template \
|perl -npe "s#fReErAdIuS_rEaLm#${freeRADIUS_realm}#" \
> /etc/raddb/modules/mschap
chgrp radiusd /etc/raddb/modules/mschap
# /etc/raddb/radiusd.conf
cat ${templatePath}/etc/raddb/radiusd.conf.template \
|perl -npe "s#fReErAdIuS_rEaLm#${freeRADIUS_realm}#" \
> /etc/raddb/radiusd.conf
chgrp radiusd /etc/raddb/radiusd.conf
# /etc/raddb/proxy.conf
cat ${templatePath}/etc/raddb/proxy.conf.template \
|perl -npe "s#PXYCFG_rEaLm#${freeRADIUS_pxycfg_realm}#" \
> /etc/raddb/proxy.conf
chgrp radiusd /etc/raddb/proxy.conf
# /etc/raddb/clients.conf
cat ${templatePath}/etc/raddb/clients.conf.template \
|perl -npe "s#PrOd_EduRoAm_PhRaSe#${freeRADIUS_cdn_prod_passphrase}#" \
|perl -npe "s#CLCFG_YaP1_iP#${freeRADIUS_clcfg_ap1_ip}#" \
|perl -npe "s#CLCFG_YaP1_sEcReT#${freeRADIUS_clcfg_ap1_secret}#" \
|perl -npe "s#CLCFG_YaP2_iP#${freeRADIUS_clcfg_ap2_ip}#" \
|perl -npe "s#CLCFG_YaP2_sEcReT#${freeRADIUS_clcfg_ap2_secret}#" \
> /etc/raddb/clients.conf
chgrp radiusd /etc/raddb/clients.conf
# /etc/raddb/certs/ca.cnf (note that there are a few things in the template too like setting it to 10yrs validity )
cat ${templatePath}/etc/raddb/certs/ca.cnf.template \
|perl -npe "s#CRT_Ca_StAtE#${freeRADIUS_ca_state}#" \
|perl -npe "s#CRT_Ca_LoCaL#${freeRADIUS_ca_local}#" \
|perl -npe "s#CRT_Ca_OrGnAmE#${freeRADIUS_ca_org_name}#" \
|perl -npe "s#CRT_Ca_EmAiL#${freeRADIUS_ca_email}#" \
|perl -npe "s#CRT_Ca_CoMmOnNaMe#${freeRADIUS_ca_commonName}#" \
> /etc/raddb/certs/ca.cnf
# /etc/raddb/certs/server.cnf (note that there are a few things in the template too like setting it to 10yrs validity )
cat ${templatePath}/etc/raddb/certs/server.cnf.template \
|perl -npe "s#CRT_SvR_StAtE#${freeRADIUS_svr_state}#" \
|perl -npe "s#CRT_SvR_LoCaL#${freeRADIUS_svr_local}#" \
|perl -npe "s#CRT_SvR_OrGnAmE#${freeRADIUS_svr_org_name}#" \
|perl -npe "s#CRT_SvR_EmAiL#${freeRADIUS_svr_email}#" \
|perl -npe "s#CRT_SvR_CoMmOnNaMe#${freeRADIUS_svr_commonName}#" \
> /etc/raddb/certs/server.cnf
# /etc/raddb/certs/client.cnf (note that there are a few things in the template too like setting it to 10yrs validity )
cat ${templatePath}/etc/raddb/certs/client.cnf.template \
|perl -npe "s#CRT_SvR_StAtE#${freeRADIUS_svr_state}#" \
|perl -npe "s#CRT_SvR_LoCaL#${freeRADIUS_svr_local}#" \
|perl -npe "s#CRT_SvR_OrGnAmE#${freeRADIUS_svr_org_name}#" \
|perl -npe "s#CRT_SvR_EmAiL#${freeRADIUS_svr_email}#" \
|perl -npe "s#CRT_SvR_CoMmOnNaMe#${freeRADIUS_svr_commonName}#" \
> /etc/raddb/certs/client.cnf
echo "Merging variables completed " >> ${statusFile} 2>&1
# construct default certificates including a CSR for this host in case a commercial CA is used
# WARNING, see the /etc/raddb/README to 'clean' out certificate bits when you run
# this script respect the protections freeRADIUS put in place to not overwrite certs
if [ ! -e "/etc/raddb/certs/server/crt" ]
then
echo "bootstrap already run, skipping"
else
(cd /etc/raddb/certs; ./bootstrap )
fi
# ensure proper start/stop at run level 3 for the machine are in place for winbind,smb, and of course, radiusd
ckCmd="/sbin/chkconfig"
ckArgs="--level 3"
ckState="on"
ckServices="winbind smb radiusd"
for myService in $ckServices
do
${ckCmd} ${ckArgs} ${myService} ${ckState}
done
# disable SELinux as it interferes with the winbind process.
cp ${templatePath}/etc/sysconfig/selinux.template /etc/sysconfig/selinux
# tweak winbind to permit proper authentication traffic to proceed
# without this, the NTLM call out for freeRADIUS will not be able to process requests
chmod ugo+rx /var/run/winbindd
echo "Start Up processes completed" >> ${statusFile} 2>&1
}
doInstall() {
${whiptailBin} --backtitle "${GUIbacktitle}" --title "Deploy eduroam customizations" --defaultno --yes-button "Yes, proceed" --no-button "No, back to main menu" --yesno --clear -- "Proceed with creating restore point and deploying Canadian Access Federation(CAF) eduroam settings?" ${whipSize} 3>&1 1>&2 2>&3
continueFwipe=$?
if [ "${continueFwipe}" -eq 0 ]
then
eval ${redhatCmdEduroam}
echo ""
echo "Update Completed" >> ${statusFile} 2>&1
echo "Beginning overlay , creating Restore Point" >> ${statusFile} 2>&1
createRestorePoint
deployCustomizations
${whiptailBin} --backtitle "${GUIbacktitle}" --title "eduroam customization completed" --msgbox "Congratulations! eduroam customizations are now deployed!\n\nNext steps: Join this machine to the AD domain by typing \n\nnet join -U Administrator\n\n After, reboot the machine and it should be ready to answer requests. \n\nDecide on your commercial certificate: Self Signed certificates were generated by default. A CSR is located at /etc/raddb/certs/server.csr to request a commercial one. Remember the RADIUS extensions needed though!\n\nFor further configuration details, please see the documentation on disk or the web \n\n Choose OK to return to main menu." 22 75
else
${whiptailBin} --backtitle "${GUIbacktitle}" --title "eduroam customization aborted" --msgbox "eduroam customizations WERE NOT done. Choose OK to return to main menu" ${whipSize}
fi
displayMainMenu
}
displayMainMenu() {
if [ "${GUIen}" = "y" ]
then
# ${whiptailBin} --backtitle "${GUIbacktitle}" --title "Review and Confirm Install Settings" --scrolltext --clear --defaultno --yesno --textbox ${freeradiusfile} 20 75 3>&1 1>&2 2>&3
#eduroamTask=$(${whiptailBin} --backtitle "${GUIbacktitle}" --title "Identity Server Main Menu" --cancel-button "exit, no changes" menu --clear -- "${getStatusString}\nWhich do you want to do?" ${whipSize} 2 review "install Settings" refresh "relevant CentOS packages" install "full eduroam base server" 20 75 3>&1 1>&2 2>&3)
eduroamTask=$(${whiptailBin} --backtitle "${GUIbacktitle}" --title "Identity Server Main Menu" --cancel-button "exit" --menu --clear -- "Which do you want to do?" ${whipSize} 5 refresh "relevant CentOS packages" review "install Settings" install "full eduroam base server" 3>&1 1>&2 2>&3)
else
echo "eduroam tasks[ install| uninstall ]"
read eduroamTask
echo ""
fi
if [ "${eduroamTask}" = "review" ]
then
echo "review selected!"
review
elif [ "${eduroamTask}" = "refresh" ]
then
echo "refresh chosen, creating Restore Point" >> ${statusFile} 2>&1
createRestorePoint
refresh
elif [ "${eduroamTask}" = "install" ]
then
echo "install chosen, creating Restore Point" >> ${statusFile} 2>&1
createRestorePoint
echo "Restore Point Completed" >> ${statusFile} 2>&1
eval ${redhatCmdEduroam}
echo ""
echo "Update Completed" >> ${statusFile} 2>&1
doInstall
fi
}
createRestorePoint() {
# Creates a restore point. Note the tar command starts from / and uses . prefixed paths.
# this should permit easier, less error prone untar of the file on same machine if needed
rpLabel="RestorePoint-`date +%F-%s`"
rpFile="${backupPath}/Identity-Appliance-${rpLabel}.tar"
# record our list of backups
echo "${rpLabel} ${rpFile}" >> ${backupList}
bkpCmd="(cd /;tar cfv ${rpFile} ./etc/krb5.conf ./etc/samba ./etc/raddb) >> ${statusFile} 2>&1"
eval ${bkpCmd}
}
validateConfig() {
# criteria for config are non empty configuration elements for all uncommented rows
#
# this parses all attributes in the configuration file to ensure they are not zero length
#
tmpBailIfHasAny=""
vc_attribute_list=`cat ${Spath}/config|egrep -v "^#"| awk -F= '{print $1}'|awk '/./'|tr '\n' ' '`
# uses indirect reference for variable names.
eval set -- "${vc_attribute_list}"
while [ $# -gt 0 ]
do
echo "DO======${tmpVal}===== ---- $1, \$$1, ${!1}"
if [ "XXXXXX" == "${!1}XXXXXX" ]
then
#echo "##### $1 is ${!1}"
echo "########EMPTYEMPTY $1 is empty"
tmpBailIfHasAny="${tmpBailIfHasAny} $1 "
else
echo "ha"
tmpString=" `echo "${cfgDesc[$1]}"`";
tmpval=" `echo "${!1}"`";
#settingsHumanReadable=" ${settingsHumanReadable} ${tmpString}: ${!1}\n"
settingsHumanReadable="${settingsHumanReadable} ${cfgDesc[$1]}: ${!1}\n"
fi
shift
done
#
# announce and exit when attributes are non zero
#
if [ "XXXXXX" == "${tmpBailIfHasAny}XXXXXX" ]
then
echo ""
else
echo "Config variables failed to validate from file: ${Spath}/config"
echo "***Please fix these variables as they were detected as zero length:${tmpBailIfHasAny}";
echo ""
exit 1;
fi
cat > ${freeradiusfile}<< EOM
${settingsHumanReadable}
EOM
}
#### END FUNCTIONS ####
redhatCmdEduroam="yum -y install bind-utils ntp samba samba-winbind freeradius freeradius-krb5 freeradius-ldap freeradius-perl freeradius-python freeradius-utils freeradius-mysql make"
#### END FETCHING COMMANDS ####
if [ ! -x "${whiptailBin}" ]
then
GUIen="n"
fi
# parse options
options=$(getopt -o ckwh -l "help" -- "$@")
eval set -- "${options}"
while [ $# -gt 0 ]
do
case "$1" in
-w)
${whiptailBin} --backtitle "${GUIbacktitle}" --title "CLEAN OUT INSTALLATION" --defaultno --yesno --clear -- \
"Wipe entire install from machine, with no backup?\n\n Both options exit immediately, yes will proceed with wipe" ${whipSize} 3>&1 1>&2 2>&3
continueFwipe=$?
if [ "${continueFwipe}" -eq 0 ]
then
cleanBadInstall
echo "Install cleaned up"
fi
exit
;;
-c)
GUIen="n"
;;
-k)
cleanUp="0"
;;
-h | --help)
printf "%s\n" "${HELP}"
exit
;;
esac
shift
validateConfig
setInstallStatus
displayMainMenu
createRestorePoint
exit
done
# guess linux dist
lsbBin=`which lsb_release`
if [ -x "${lsbBin}" ]
then
dist=`lsb_release -i 2>/dev/null |cut -d':' -f2 | perl -npe 's/^\s+//g'`
if [ ! -z "`echo ${dist} |grep -i 'ubuntu' |grep -v 'grep'`" ]
then
dist="ubuntu"
elif [ ! -z "`echo ${dist} |grep -i 'redhat' |grep -v 'grep'`" ]
then
dist="redhat"
fi
else
if [ -s "/etc/centos-release" -o -s "/etc/redhat-release" ]
then
dist="redhat"
fi
fi
# define commands
ubuntuCmdU="apt-get -qq update"
ubuntuCmd1="apt-get -y install patch unzip curl >> ${statusFile} 2>&1"
ubuntuCmd2="apt-get -y install git-core maven2 openjdk-6-jdk >> ${statusFile} 2>&1"
ubuntuCmd3="apt-get -y install default-jre >> ${statusFile} 2>&1"
ubuntuCmd4="apt-get -y install tomcat6 >> ${statusFile} 2>&1"
ubuntuCmd5="apt-get -y install mysql-server >> ${statusFile} 2>&1"
redhatCmdU="yum -q -y update"
redhatCmd1="yum -y install patch zip unzip curl"
redhatCmd2="yum -y install git-core"
redhatCmd3=""
redhatCmd4=""
redhatCmd5="yum -y install mysql-server"
redhatCmdEduroam="yum -y install ntp samba samba-winbind freeradius freeradius-krb5 freeradius-ldap freeradius-perl freeradius-python freeradius-utils freeradius-mysql"
# added to grab appropriate running user
runningAs=`/usr/bin/whoami`
#
if [ ${dist} = "ubuntu" ]
then
distCmdU=${ubuntuCmdU}
distCmd1=${ubuntuCmd1}
distCmd2=${ubuntuCmd2}
distCmd3=${ubuntuCmd3}
distCmd4=${ubuntuCmd4}
distCmd5=${ubuntuCmd5}
elif [ ${dist} -eq "redhat" ]
then
Rmsg="Red Hat and CentOS ship with the GNU Java compiler and VM by default. These are not usable with Shibboleth so you must install another JVM. The Sun HotSpot VM is the most commonly used. On recent versions of these distros, you can also install a compatible version of OpenJDK 1.6 using yum. To find the appropriate package name, run yum makecache && yum search openjdk. You will also need to ensure that Tomcat is using OpenJDK rather than the GNU tools."
if [ "${GUIen}" = "y" ]
then
${whiptailBin} --backtitle "${GUIbacktitle}" --title "Redhat/Centos" --defaultno --yesno --clear -- \
"$Rmsg" ${whipSize} 3>&1 1>&2 2>&3
continueFNum=$?
continueF="n"
if [ "${continueFNum}" -eq 0 ]
then
continueF="y"
fi
else
echo $Rmsg
echo "Make sure Maven2 is installed! Continue script [ y | N ]?"
read continueF
echo ""
fi
if [ "${continueF}" != "y" ]
then
cleanBadInstall
exit
fi
distCmdU=${redhatCmdU}
distCmd1=${redhatCmd1}
distCmd2=${redhatCmd2}
distCmd3=${redhatCmd3}
distCmd4=${redhatCmd4}
distCmd5=${redhatCmd5}
fi
if [ "${runningAs}" != "root" ]
then
echo "Run as root!"
exit
fi
prep="prep/${type}"
# check for installed IDP
if [ -L "/opt/shibboleth-identityprovider" -a -d "/opt/shibboleth-idp" ]
then
upgrade=1
fi
# get data from user for a new install
if [ "${upgrade}" -eq 0 ]
then
if [ -z "${appserv}" ]
then
if [ "${GUIen}" = "y" ]
then
appserv=$(${whiptailBin} --backtitle "${GUIbacktitle}" --title "Application server" --nocancel --menu --clear -- "Which application server do you want to use?" ${whipSize} 2 \
tomcat "Apache Tomcat 6" jboss "Jboss Application server 6" 3>&1 1>&2 2>&3)
else
echo "Application server [ tomcat | jboss ]"
read appserv
echo ""
fi
fi
if [ -z "${type}" ]
then
if [ "${GUIen}" = "y" ]
then
tList="${whiptailBin} --backtitle \"${GUIbacktitle}\" --title \"Authentication type\" --nocancel --menu --clear -- \"Which authentication type do you want to use?\" ${whipSize} 2"
for i in `ls ${Spath}/prep | perl -npe 's/\n/\ /g'`
do
tDesc=`cat ${Spath}/prep/${i}/.desc`
tList="`echo ${tList}` \"${i}\" \"${tDesc}\""
done
type=$(eval "${tList} 3>&1 1>&2 2>&3")
else
echo "Authentication [ `ls ${Spath}/prep |grep -v common | perl -npe 's/\n/\ /g'`]"
read type
echo ""
fi
fi
prep="prep/${type}"
if [ -z "${google}" ]
then
if [ "${GUIen}" = "y" ]
then
${whiptailBin} --backtitle "${GUIbacktitle}" --title "Attributes to Google" --yesno --clear -- \
"Do you want to release attributes to google?\n\nSwamid, Swamid-test and testshib.org installed as standard" ${whipSize} 3>&1 1>&2 2>&3
googleNum=$?
google="n"
if [ "${googleNum}" -eq 0 ]
then
google="y"
fi
else
echo "Release attributes to Google? [Y/n]: (Swamid, Swamid-test and testshib.org installed as standard)"
read google
echo ""
fi
fi
while [ "${google}" != "n" -a -z "${googleDom}" ]
do
if [ "${GUIen}" = "y" ]
then
googleDom=$(${whiptailBin} --backtitle "${GUIbacktitle}" --title "Your Google domain name" --nocancel --inputbox --clear -- \
"Please input your Google domain name (student.xxx.yy)." ${whipSize} "student.${Dname}" 3>&1 1>&2 2>&3)
else
echo "Your Google domain name: (student.xxx.yy)"
read googleDom
echo ""
fi
done
while [ -z "${ntpserver}" ]
do
if [ "${GUIen}" = "y" ]
then
ntpserver=$(${whiptailBin} --backtitle "${GUIbacktitle}" --title "NTP server" --nocancel --inputbox --clear -- \
"Please input your NTP server address." ${whipSize} "ntp.${Dname}" 3>&1 1>&2 2>&3)
else
echo "Specify NTP server:"
read ntpserver
echo ""
fi
done
while [ -z "${ldapserver}" ]
do
if [ "${GUIen}" = "y" ]
then
ldapserver=$(${whiptailBin} --backtitle "${GUIbacktitle}" --title "LDAP server" --nocancel --inputbox --clear -- \
"Please input yout LDAP server(s) (ldap.xxx.yy).\n\nSeparate multiple servers with spaces.\nLDAPS is used by default." ${whipSize} "ldap.${Dname}" 3>&1 1>&2 2>&3)
else
echo "Specify LDAP URL: (ldap.xxx.yy) (seperate servers with space). LDAPS is used by default."
read ldapserver
echo ""
fi
done
while [ -z "${ldapbasedn}" ]
do
if [ "${GUIen}" = "y" ]
then
ldapbasedn=$(${whiptailBin} --backtitle "${GUIbacktitle}" --title "LDAP Base DN" --nocancel --inputbox --clear -- \
"Please input your LDAP Base DN" ${whipSize} 3>&1 1>&2 2>&3)
else
echo "Specify LDAP Base DN:"
read ldapbasedn
echo ""
fi
done
while [ -z "${ldapbinddn}" ]
do
if [ "${GUIen}" = "y" ]
then
ldapbinddn=$(${whiptailBin} --backtitle "${GUIbacktitle}" --title "LDAP Bind DN" --nocancel --inputbox --clear -- \
"Please input your LDAP Bind DN" ${whipSize} 3>&1 1>&2 2>&3)
else
echo "Specify LDAP Bind DN:"
read ldapbinddn
echo ""
fi
done
while [ -z "${ldappass}" ]
do
if [ "${GUIen}" = "y" ]
then
ldappass=$(${whiptailBin} --backtitle "${GUIbacktitle}" --title "LDAP Password" --nocancel --passwordbox --clear -- \
"Please input your LDAP Password:" ${whipSize} 3>&1 1>&2 2>&3)
else
echo "Specify LDAP Password:"
read ldappass
echo ""
fi
done
while [ "${type}" = "ldap" -a -z "${subsearch}" ]
do
if [ "${GUIen}" = "y" ]
then
${whiptailBin} --backtitle "${GUIbacktitle}" --title "LDAP Subsearch" --nocancel --yesno --clear -- \
"Do you want to enable LDAP subtree search?" ${whipSize} 3>&1 1>&2 2>&3
subsearchNum=$?
subsearch="false"
if [ "${subsearchNum}" -eq 0 ]
then
subsearch="true"
fi
else
echo "LDAP Subsearch: [ true | false ]"
read subsearch
echo ""
fi
done
while [ -z "${ninc}" ]
do
if [ "${GUIen}" = "y" ]
then
ninc=$(${whiptailBin} --backtitle "${GUIbacktitle}" --title "norEduPersonNIN" --nocancel --inputbox --clear -- \
"Please specify LDAP attribute for norEduPersonNIN (YYYYMMDDnnnn)." ${whipSize} "norEduPersonNIN" 3>&1 1>&2 2>&3)
else
echo "LDAP attribute for norEduPersonNIN (YYYYMMDDnnnn)? (empty string for 'norEduPersonNIN')"
read ninc
echo ""
if [ -z "${ninc}" ]
then
ninc="norEduPersonNIN"
fi
fi
done
while [ -z "${idpurl}" ]
do
if [ "${GUIen}" = "y" ]
then
idpurl=$(${whiptailBin} --backtitle "${GUIbacktitle}" --title "IDP URL" --nocancel --inputbox --clear -- \
"Please input the URL to this IDP (https://idp.xxx.yy)." ${whipSize} "https://${FQDN}" 3>&1 1>&2 2>&3)
else
echo "Specify IDP URL: (https://idp.xxx.yy)"
read idpurl
echo ""
fi
done
if [ "${type}" = "cas" ]
then
while [ -z "${casurl}" ]
do
if [ "${GUIen}" = "y" ]
then
casurl=$(${whiptailBin} --backtitle "${GUIbacktitle}" --title "" --nocancel --inputbox --clear -- \
"Please input the URL to yourCAS server (https://cas.xxx.yy/cas)." ${whipSize} "https://cas.${Dname}/cas" 3>&1 1>&2 2>&3)
else
echo "Specify CAS URL server: (https://cas.xxx.yy/cas)"
read casurl
echo ""
fi
done
while [ -z "${caslogurl}" ]
do
if [ "${GUIen}" = "y" ]
then
caslogurl=$(${whiptailBin} --backtitle "${GUIbacktitle}" --title "" --nocancel --inputbox --clear -- \
"Please input the Login URL to your CAS server (https://cas.xxx.yy/cas/login)." ${whipSize} "${casurl}/login" 3>&1 1>&2 2>&3)
else
echo "Specify CAS Login URL server: (https://cas.xxx.yy/cas/login)"
read caslogurl
echo ""
fi
done
fi
while [ -z "${certOrg}" ]
do
if [ "${GUIen}" = "y" ]
then
certOrg=$(${whiptailBin} --backtitle "${GUIbacktitle}" --title "Certificate organisation" --nocancel --inputbox --clear -- \
"Please input organisation name string for certificate request" ${whipSize} 3>&1 1>&2 2>&3)
else
echo "Organisation name string for certificate request:"
read certOrg
echo ""
fi
done
while [ -z "${certC}" ]
do
if [ "${GUIen}" = "y" ]
then
certC=$(${whiptailBin} --backtitle "${GUIbacktitle}" --title "Certificate country" --nocancel --inputbox --clear -- \
"Please input country string for certificate request." ${whipSize} 'SE' 3>&1 1>&2 2>&3)
else
echo "Country string for certificate request: (empty string for 'SE')"
read certC
echo ""
if [ -z "${certC}" ]
then
certC="SE"
fi
fi
done
while [ -z "${certAcro}" ]
do
acro=""
for i in ${certOrg}
do
t=`echo ${i} | cut -c1`
acro="${acro}${t}"
done
if [ "${GUIen}" = "y" ]
then
certAcro=$(${whiptailBin} --backtitle "${GUIbacktitle}" --title "Organisation acronym" --nocancel --inputbox --clear -- \
"Please input organisation Acronym (eg. 'HiG')" ${whipSize} "${acro}" 3>&1 1>&2 2>&3)
else
echo "norEduOrgAcronym: (eg. 'HiG')"
read certAcro
echo ""
fi
done
while [ -z "${certLongC}" ]
do
if [ "${GUIen}" = "y" ]
then
certLongC=$(${whiptailBin} --backtitle "${GUIbacktitle}" --title "Country descriptor" --nocancel --inputbox --clear -- \
"Please input country descriptor (eg. 'Sweden')" ${whipSize} 'Sweden' 3>&1 1>&2 2>&3)
else
echo "Country descriptor (eg. 'Sweden')"
read certLongC
echo ""
fi
done
if [ -z "${fticks}" ]
then
if [ "${GUIen}" = "y" ]
then
${whiptailBin} --backtitle "${GUIbacktitle}" --title "Send anonymous data" --yesno --clear -- \
"Do you want to send anonymous usage data to SWAMID?\nThis is recommended." ${whipSize} 3>&1 1>&2 2>&3
fticsNum=$?
fticks="n"
if [ "${fticsNum}" -eq 0 ]
then
fticks="y"
fi
else
echo "Send anonymous usage data to SWAMID [ y | n ]?"
read fticks
echo ""
fi
fi
if [ "${fticks}" != "n" -a ${dist} = "redhat" -a ! -s "`which mvn`" ]
then
if [ "${GUIen}" = "y" ]
then
${whiptailBin} --backtitle "${GUIbacktitle}" --title "Maven2" --defaultno --yesno --clear -- \
"Make sure Maven2 is installed?\nContinue?" ${whipSize} 3>&1 1>&2 2>&3
continueFNum=$?
continueF="n"
if [ "${continueFNum}" -eq 0 ]
then
continueF="y"
fi
else
echo "Make sure Maven2 is installed! Continue script [ y | n ]?"
read continueF
echo ""
fi
if [ "${continueF}" = "n" ]
then
cleanBadInstall
exit
fi
fi
if [ -z "${eptid}" ]
then
if [ "${GUIen}" = "y" ]
then
${whiptailBin} --backtitle "${GUIbacktitle}" --title "eduPersonTargetedID" --yesno --clear -- \
"Do you want to install support for eduPersonTargetedID?\nThis is recommended." ${whipSize} 3>&1 1>&2 2>&3
eptidNum=$?
eptid="n"
if [ "${eptidNum}" -eq 0 ]
then
eptid="y"
fi
else
echo "Install support for eduPersonTargetedID [ y | n ]"
read eptid
echo ""
fi
fi
if [ "${eptid}" != "n" ]
then
if [ "${GUIen}" = "y" ]
then
mysqlPass=$(${whiptailBin} --backtitle "${GUIbacktitle}" --title "MySQL password" --nocancel --passwordbox --clear -- \
"Please input the root password for MySQL\n\nEmpty string generates new password." ${whipSize} 3>&1 1>&2 2>&3)