-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdeploy_idp.sh
executable file
·1436 lines (1307 loc) · 44.2 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/sh
# UTF-8
HELP="
##############################################################################
# Shibboleth deployment script by Anders Lördal #
# Högskolan i Gävle and SWAMID #
# #
# Version 2.0 #
# #
# 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) #
# #
# Templates are provided for CAS and LDAP authentication #
# #
# To disable the whiptail gui run with argument '-c' #
# To keep generated files run with argument '-k' #
# NOTE! some of theese files WILL contain cleartext passwords. #
# #
# 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' #
# #
# Please send questions and improvements to: [email protected] #
##############################################################################
"
# Copyright 2011, 2012, 2013 Anders Lördal, Högskolan i Gävle and SWAMID
#
# This file is part of IDP-Deployer
#
# IDP-Deployer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# IDP-Deployer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with IDP-Deployer. If not, see <http://www.gnu.org/licenses/>.
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=1
# Default enable of whiptail UI
GUIen=y
# Version of shibboleth IDP
shibVer="2.4.0"
# Default values
upgrade=0
Spath="$(cd "$(dirname "$0")" && pwd)"
files=""
ts=`date "+%s"`
whiptailBin=`which whiptail`
whipSize="13 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"
if [ ! -x "${whiptailBin}" ]
then
GUIen="n"
fi
# parse options
options=$(getopt -o ckh -l "help" -- "$@")
eval set -- "${options}"
while [ $# -gt 0 ]
do
case "$1" in
-c)
GUIen="n"
;;
-k)
cleanUp="0"
;;
-h | --help)
printf "%s\n" "${HELP}"
exit
;;
esac
shift
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 unzip curl"
redhatCmd2="yum -y install git-core"
redhatCmd3=""
redhatCmd4=""
redhatCmd5="yum -y install mysql-server"
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 "SWAMID IDP Deployer" --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 [ "${USERNAME}" != "root" ]
then
echo "Run as root!"
exit
fi
# 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
}
# read config file
if [ -f "${Spath}/config" ]
then
. ${Spath}/config
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 "SWAMID IDP Deployer" --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 \"SWAMID IDP Deployer\" --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 "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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)
else
echo "Root password for MySQL (empty string generates new password)?"
read mysqlPass
echo ""
fi
fi
if [ -z "${selfsigned}" ]
then
if [ "${GUIen}" = "y" ]
then
${whiptailBin} --backtitle "SWAMID IDP Deployer" --title "Self signed certificate" --defaultno --yesno --clear -- \
"Create a self signed certificate for HTTPS?\n\nThis is NOT recommended! Only for testing purposes" ${whipSize} 3>&1 1>&2 2>&3
selfsignedNum=$?
selfsigned="n"
if [ "${selfsignedNum}" -eq 0 ]
then
selfsigned="y"
fi
else
echo "Create a self signed certificate for https [ y | n ]"
read selfsigned
echo ""
fi
fi
if [ "${GUIen}" = "y" ]
then
pass=$(${whiptailBin} --backtitle "SWAMID IDP Deployer" --title "IDP keystore password" --nocancel --passwordbox --clear -- \
"Please input your IDP keystore password\n\nEmpty string generates new password." ${whipSize} 3>&1 1>&2 2>&3)
httpspass=$(${whiptailBin} --backtitle "SWAMID IDP Deployer" --title "HTTPS Keystore password" --nocancel --passwordbox --clear -- \
"Please input your Keystore password for HTTPS\n\nEmpty string generates new password." ${whipSize} 3>&1 1>&2 2>&3)
else
echo "IDP keystore password (empty string generates new password)"
read pass
echo ""
echo "Keystore password for https (empty string generates new password)"
read httpspass
echo ""
fi
# Confirmation
cat > ${Spath}/files/confirm.tx << EOM
Options passed to the installer:
Application server: ${appserv}
Authentication type: ${type}
Release to Google: ${google}
Google domain name: ${googleDom}
NTP server: ${ntpserver}
LDAP server: ${ldapserver}
LDAP Base DN: ${ldapbasedn}
LDAP Bind DN: ${ldapbinddn}
LDAP Subsearch: ${subsearch}
norEduPersonNIN: ${ninc}
IDP URL: ${idpurl}
CAS Login URL: ${caslogurl}
CAS URL: ${casurl}
Cert org string: ${certOrg}
Cert country string: ${certC}
norEduOrgAcronym: ${certAcro}
Country descriptor: ${certLongC}
Usage data to SWAMID: ${fticks}
EPTID support: ${eptid}
Create self seigned cert: ${selfsigned}
EOM
cRet="1"
if [ "${GUIen}" = "y" ]
then
${whiptailBin} --backtitle "SWAMID IDP Deployer" --title "Save config" --clear --yesno -- "Do you want to save theese config values?\n\nIf you save theese values the current config file will be ovverwritten.\n NOTE: No passwords will be saved." ${whipSize} 3>&1 1>&2 2>&3
cRet=$?
else
cat ${Spath}/files/confirm.tx
/bin/echo -e "Do you want to save theese config values?\n\nIf you save theese values the current config file will be ovverwritten.\n NOTE: No passwords will be saved."
read cAns
echo ""
if [ "$cAns" = "y" ]
then
cRet="0"
else
cRet="1"
fi
fi
if [ "${cRet}" -eq 0 ]
then
cat > ${Spath}/config << EOM
appserv="${appserv}"
type="${type}"
google="${google}"
googleDom="${googleDom}"
ntpserver="${ntpserver}"
ldapserver="${ldapserver}"
ldapbasedn="${ldapbasedn}"
ldapbinddn="${ldapbinddn}"
subsearch="${subsearch}"
idpurl="${idpurl}"
caslogurl="${caslogurl}"
casurl="${casurl}"
certOrg="${certOrg}"
certC="${certC}"
fticks="${fticks}"
eptid="${eptid}"
selfsigned="${selfsigned}"
ninc="${ninc}"
certAcro="${certAcro}"
certLongC="${certLongC}"
EOM
fi
cRet="1"
if [ "${GUIen}" = "y" ]
then
${whiptailBin} --backtitle "SWAMID IDP Deployer" --title "Confirm" --scrolltext --clear --textbox ${Spath}/files/confirm.tx 20 75 3>&1 1>&2 2>&3
${whiptailBin} --backtitle "SWAMID IDP Deployer" --title "Confirm" --clear --yesno --defaultno -- "Do you want to install this IDP with theese options?" ${whipSize} 3>&1 1>&2 2>&3
cRet=$?
else
cat ${Spath}/files/confirm.tx
echo "Do you want to install this IDP with theese options [ y | n ]?"
read cAns
echo ""
if [ "$cAns" = "y" ]
then
cRet="0"
fi
fi
rm ${Spath}/files/confirm.tx
if [ "${cRet}" -ge 1 ]
then
exit
fi
fi
certCN=`echo ${idpurl} | cut -d/ -f3`
/bin/echo -e "\n\n\n"
echo "Starting deployment!"
if [ "${upgrade}" -eq 1 ]
then
echo "Previous installation found, performing upgrade."
eval ${distCmd1}
cd /opt
currentShib=`ls -l /opt/shibboleth-identityprovider |awk '{print $NF}'`
currentVer=`echo ${currentShib} |awk -F\- '{print $NF}'`
if [ "${currentVer}" = "${shibVer}" ]
then
mv ${currentShib} ${currentShib}.${ts}
fi
if [ ! -f "${Spath}/files/shibboleth-identityprovider-${shibVer}-bin.zip" ]
then
echo "Shibboleth not found, fetching from web"
${fetchCmd} ${Spath}/files/shibboleth-identityprovider-${shibVer}-bin.zip ${shibbURL}
fi
unzip -q ${Spath}/files/shibboleth-identityprovider-${shibVer}-bin.zip
chmod -R 755 /opt/shibboleth-identityprovider-${shibVer}
unlink /opt/shibboleth-identityprovider
ln -s /opt/shibboleth-identityprovider-${shibVer} /opt/shibboleth-identityprovider
if [ -d "/opt/cas-client-3.2.1" ]
then
while [ -z "${idpurl}" ]
do
if [ "${GUIen}" = "y" ]
then
idpurl=$(${whiptailBin} --backtitle "SWAMID IDP Deployer" --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
while [ -z "${casurl}" ]
do
if [ "${GUIen}" = "y" ]
then
casurl=$(${whiptailBin} --backtitle "SWAMID IDP Deployer" --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 "SWAMID IDP Deployer" --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
cp /opt/cas-client-3.2.1/modules/cas-client-core-3.2.1.jar /opt/shibboleth-identityprovider/lib/
cp /opt/cas-client-3.2.1/modules/commons-logging-1.1.jar /opt/shibboleth-identityprovider/lib/
mkdir /opt/shibboleth-identityprovider/src/main/webapp/WEB-INF/lib
cp /opt/cas-client-3.2.1/modules/cas-client-core-3.2.1.jar /opt/shibboleth-identityprovider/src/main/webapp/WEB-INF/lib
cp /opt/cas-client-3.2.1/modules/commons-logging-1.1.jar /opt/shibboleth-identityprovider/src/main/webapp/WEB-INF/lib
prep="prep/${type}"
cat ${Spath}/${prep}/shibboleth-identityprovider-web.xml.diff.template \
| perl -npe "s#IdPuRl#${idpurl}#" \
| perl -npe "s#CaSuRl#${caslogurl}#" \
| perl -npe "s#CaS2uRl#${casurl}#" \
> ${Spath}/${prep}/shibboleth-identityprovider-web.xml.diff
files="`echo ${files}` ${Spath}/${prep}/shibboleth-identityprovider-web.xml.diff"
patch /opt/shibboleth-identityprovider/src/main/webapp/WEB-INF/web.xml -i ${Spath}/${prep}/shibboleth-identityprovider-web.xml.diff >> ${statusFile} 2>&1
fi
if [ -d "/opt/ndn-shib-fticks" ]
then
if [ -z "`ls /opt/ndn-shib-fticks/target/*.jar`" ]
then
cd /opt/ndn-shib-fticks
mvn >> ${statusFile} 2>&1
fi
cp /opt/ndn-shib-fticks/target/*.jar /opt/shibboleth-identityprovider/lib
else
${whiptailBin} --backtitle "SWAMID IDP Deployer" --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
if [ "${fticks}" != "n" ]
then
echo "Installing ndn-shib-fticks"
eval ${distCmd2}
cd /opt
git clone git://github.com/leifj/ndn-shib-fticks.git >> ${statusFile} 2>&1
cd ndn-shib-fticks
mvn >> ${statusFile} 2>&1
cp /opt/ndn-shib-fticks/target/*.jar /opt/shibboleth-identityprovider/lib
fi
fi
if [ -d "/opt/mysql-connector-java-5.1.24/" ]
then
cp /opt/mysql-connector-java-5.1.24/mysql-connector-java-5.1.24-bin.jar /opt/shibboleth-identityprovider/lib/
fi
cd /opt
tar zcf ${bupFile} shibboleth-idp
cp /opt/shibboleth-idp/metadata/idp-metadata.xml /opt/shibboleth-identityprovider/src/main/webapp/metadata.xml
setJavaHome
cd /opt/shibboleth-identityprovider
/bin/echo -e "\n\n\n\nRunning shiboleth installer"
sh install.sh -Dinstall.config=no -Didp.home.input="/opt/shibboleth-idp" >> ${statusFile} 2>&1
else
# install depends
echo "Updating repositories and installing generic dependancies"
eval ${distCmdU}
eval ${distCmd1}
# install java if needed
javaBin=`which java`
if [ ! -s "${javaBin}" ]
then
eval ${distCmd3}
javaBin=`which java`
fi
if [ ! -s "${javaBin}" ]
then
echo "No java could be found! Install a working JRE and re-run this script."
cleanBadInstall
exit 1
fi
setJavaHome
# set path to ca cert file
if [ -f "/etc/ssl/certs/java/cacerts" ]
then
javaCAcerts="/etc/ssl/certs/java/cacerts"
else
javaCAcerts="${JAVA_HOME}/lib/security/cacerts"
fi
# generate keystore pass
if [ -z "${pass}" ]
then
pass=`${passGenCmd}`
fi
if [ -z "${httpspass}" ]
then
httpspass=`${passGenCmd}`
fi
if [ -z "${mysqlPass}" ]
then
mysqlPass=`${passGenCmd}`
/bin/echo -e "Mysql root password generated\nPassword is '${mysqlPass}'" >> ${messages}
fi
cd /opt
# get depens if needed
if [ "${appserv}" = "jboss" ]
then
if [ ! -f "${Spath}/files/jboss-as-distribution-6.1.0.Final.zip" ]
then
echo "Jboss not found, fetching from web"
${fetchCmd} ${Spath}/files/jboss-as-distribution-6.1.0.Final.zip http://download.jboss.org/jbossas/6.1/jboss-as-distribution-6.1.0.Final.zip
fi
unzip -q ${Spath}/files/jboss-as-distribution-6.1.0.Final.zip
chmod 755 jboss-6.1.0.Final
ln -s /opt/jboss-6.1.0.Final /opt/jboss
fi
if [ "${appserv}" = "tomcat" ]
then
test=`dpkg -s tomcat6 > /dev/null 2>&1`
isInstalled=$?
if [ "${isInstalled}" -ne 0 ]
then
eval ${distCmd4}
fi
fi
if [ ! -f "${Spath}/files/shibboleth-identityprovider-${shibVer}-bin.zip" ]
then
echo "Shibboleth not found, fetching from web"
${fetchCmd} ${Spath}/files/shibboleth-identityprovider-${shibVer}-bin.zip ${shibbURL}
fi
if [ "${type}" = "cas" ]
then
if [ ! -f "${Spath}/files/cas-client-3.2.1-release.zip" ]
then
echo "Cas-client not found, fetching from web"
${fetchCmd} ${Spath}/files/cas-client-3.2.1-release.zip ${casClientURL}
fi
unzip -q ${Spath}/files/cas-client-3.2.1-release.zip
if [ ! -s "/opt/cas-client-3.2.1/modules/cas-client-core-3.2.1.jar" ]
then
echo "Unzip of cas-client failed, check zip file: ${Spath}/files/cas-client-3.2.1-release.zip"
cleanBadInstall
exit
fi
fi
# unzip all files
echo "Unzipping dependancies"
unzip -q ${Spath}/files/shibboleth-identityprovider-${shibVer}-bin.zip
chmod -R 755 /opt/shibboleth-identityprovider-${shibVer}
ln -s shibboleth-identityprovider-${shibVer} shibboleth-identityprovider
if [ "${type}" = "cas" ]
then
# copy cas depends into shibboleth
cp /opt/cas-client-3.2.1/modules/cas-client-core-3.2.1.jar /opt/shibboleth-identityprovider/lib/
cp /opt/cas-client-3.2.1/modules/commons-logging-1.1.jar /opt/shibboleth-identityprovider/lib/
mkdir /opt/shibboleth-identityprovider/src/main/webapp/WEB-INF/lib
cp /opt/cas-client-3.2.1/modules/cas-client-core-3.2.1.jar /opt/shibboleth-identityprovider/src/main/webapp/WEB-INF/lib
cp /opt/cas-client-3.2.1/modules/commons-logging-1.1.jar /opt/shibboleth-identityprovider/src/main/webapp/WEB-INF/lib
cat ${Spath}/${prep}/shibboleth-identityprovider-web.xml.diff.template \
| perl -npe "s#IdPuRl#${idpurl}#" \
| perl -npe "s#CaSuRl#${caslogurl}#" \
| perl -npe "s#CaS2uRl#${casurl}#" \
> ${Spath}/${prep}/shibboleth-identityprovider-web.xml.diff
files="`echo ${files}` ${Spath}/${prep}/shibboleth-identityprovider-web.xml.diff"
patch /opt/shibboleth-identityprovider/src/main/webapp/WEB-INF/web.xml -i ${Spath}/${prep}/shibboleth-identityprovider-web.xml.diff >> ${statusFile} 2>&1
fi