Guest User

SOGo Ubuntu 14.04 Install Script

a guest
Feb 10th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 52.89 KB | None | 0 0
  1.  
  2. 1
  3. 2
  4. 3
  5. 4
  6. 5
  7. 6
  8. 7
  9. 8
  10. 9
  11. 10
  12. 11
  13. 12
  14. 13
  15. 14
  16. 15
  17. 16
  18. 17
  19. 18
  20. 19
  21. 20
  22. 21
  23. 22
  24. 23
  25. 24
  26. 25
  27. 26
  28. 27
  29. 28
  30. 29
  31. 30
  32. 31
  33. 32
  34. 33
  35. 34
  36. 35
  37. 36
  38. 37
  39. 38
  40. 39
  41. 40
  42. 41
  43. 42
  44. 43
  45. 44
  46. 45
  47. 46
  48. 47
  49. 48
  50. 49
  51. 50
  52. 51
  53. 52
  54. 53
  55. 54
  56. 55
  57. 56
  58. 57
  59. 58
  60. 59
  61. 60
  62. 61
  63. 62
  64. 63
  65. 64
  66. 65
  67. 66
  68. 67
  69. 68
  70. 69
  71. 70
  72. 71
  73. 72
  74. 73
  75. 74
  76. 75
  77. 76
  78. 77
  79. 78
  80. 79
  81. 80
  82. 81
  83. 82
  84. 83
  85. 84
  86. 85
  87. 86
  88. 87
  89. 88
  90. 89
  91. 90
  92. 91
  93. 92
  94. 93
  95. 94
  96. 95
  97. 96
  98. 97
  99. 98
  100. 99
  101. 100
  102. 101
  103. 102
  104. 103
  105. 104
  106. 105
  107. 106
  108. 107
  109. 108
  110. 109
  111. 110
  112. 111
  113. 112
  114. 113
  115. 114
  116. 115
  117. 116
  118. 117
  119. 118
  120. 119
  121. 120
  122. 121
  123. 122
  124. 123
  125. 124
  126. 125
  127. 126
  128. 127
  129. 128
  130. 129
  131. 130
  132. 131
  133. 132
  134. 133
  135. 134
  136. 135
  137. 136
  138. 137
  139. 138
  140. 139
  141. 140
  142. 141
  143. 142
  144. 143
  145. 144
  146. 145
  147. 146
  148. 147
  149. 148
  150. 149
  151. 150
  152. 151
  153. 152
  154. 153
  155. 154
  156. 155
  157. 156
  158. 157
  159. 158
  160. 159
  161. 160
  162. 161
  163. 162
  164. 163
  165. 164
  166. 165
  167. 166
  168. 167
  169. 168
  170. 169
  171. 170
  172. 171
  173. 172
  174. 173
  175. 174
  176. 175
  177. 176
  178. 177
  179. 178
  180. 179
  181. 180
  182. 181
  183. 182
  184. 183
  185. 184
  186. 185
  187. 186
  188. 187
  189. 188
  190. 189
  191. 190
  192. 191
  193. 192
  194. 193
  195. 194
  196. 195
  197. 196
  198. 197
  199. 198
  200. 199
  201. 200
  202. 201
  203. 202
  204. 203
  205. 204
  206. 205
  207. 206
  208. 207
  209. 208
  210. 209
  211. 210
  212. 211
  213. 212
  214. 213
  215. 214
  216. 215
  217. 216
  218. 217
  219. 218
  220. 219
  221. 220
  222. 221
  223. 222
  224. 223
  225. 224
  226. 225
  227. 226
  228. 227
  229. 228
  230. 229
  231. 230
  232. 231
  233. 232
  234. 233
  235. 234
  236. 235
  237. 236
  238. 237
  239. 238
  240. 239
  241. 240
  242. 241
  243. 242
  244. 243
  245. 244
  246. 245
  247. 246
  248. 247
  249. 248
  250. 249
  251. 250
  252. 251
  253. 252
  254. 253
  255. 254
  256. 255
  257. 256
  258. 257
  259. 258
  260. 259
  261. 260
  262. 261
  263. 262
  264. 263
  265. 264
  266. 265
  267. 266
  268. 267
  269. 268
  270. 269
  271. 270
  272. 271
  273. 272
  274. 273
  275. 274
  276. 275
  277. 276
  278. 277
  279. 278
  280. 279
  281. 280
  282. 281
  283. 282
  284. 283
  285. 284
  286. 285
  287. 286
  288. 287
  289. 288
  290. 289
  291. 290
  292. 291
  293. 292
  294. 293
  295. 294
  296. 295
  297. 296
  298. 297
  299. 298
  300. 299
  301. 300
  302. 301
  303. 302
  304. 303
  305. 304
  306. 305
  307. 306
  308. 307
  309. 308
  310. 309
  311. 310
  312. 311
  313. 312
  314. 313
  315. 314
  316. 315
  317. 316
  318. 317
  319. 318
  320. 319
  321. 320
  322. 321
  323. 322
  324. 323
  325. 324
  326. 325
  327. 326
  328. 327
  329. 328
  330. 329
  331. 330
  332. 331
  333. 332
  334. 333
  335. 334
  336. 335
  337. 336
  338. 337
  339. 338
  340. 339
  341. 340
  342. 341
  343. 342
  344. 343
  345. 344
  346. 345
  347. 346
  348. 347
  349. 348
  350. 349
  351. 350
  352. 351
  353. 352
  354. 353
  355. 354
  356. 355
  357. 356
  358. 357
  359. 358
  360. 359
  361. 360
  362. 361
  363. 362
  364. 363
  365. 364
  366. 365
  367. 366
  368. 367
  369. 368
  370. 369
  371. 370
  372. 371
  373. 372
  374. 373
  375. 374
  376. 375
  377. 376
  378. 377
  379. 378
  380. 379
  381. 380
  382. 381
  383. 382
  384. 383
  385. 384
  386. 385
  387. 386
  388. 387
  389. 388
  390. 389
  391. 390
  392. 391
  393. 392
  394. 393
  395. 394
  396. 395
  397. 396
  398. 397
  399. 398
  400. 399
  401. 400
  402. 401
  403. 402
  404. 403
  405. 404
  406. 405
  407. 406
  408. 407
  409. 408
  410. 409
  411. 410
  412. 411
  413. 412
  414. 413
  415. 414
  416. 415
  417. 416
  418. 417
  419. 418
  420. 419
  421. 420
  422. 421
  423. 422
  424. 423
  425. 424
  426. 425
  427. 426
  428. 427
  429. 428
  430. 429
  431. 430
  432. 431
  433. 432
  434. 433
  435. 434
  436. 435
  437. 436
  438. 437
  439. 438
  440. 439
  441. 440
  442. 441
  443. 442
  444. 443
  445. 444
  446. 445
  447. 446
  448. 447
  449. 448
  450. 449
  451. 450
  452. 451
  453. 452
  454. 453
  455. 454
  456. 455
  457. 456
  458. 457
  459. 458
  460. 459
  461. 460
  462. 461
  463. 462
  464. 463
  465. 464
  466. 465
  467. 466
  468. 467
  469. 468
  470. 469
  471. 470
  472. 471
  473. 472
  474. 473
  475. 474
  476. 475
  477. 476
  478. 477
  479. 478
  480. 479
  481. 480
  482. 481
  483. 482
  484. 483
  485. 484
  486. 485
  487. 486
  488. 487
  489. 488
  490. 489
  491. 490
  492. 491
  493. 492
  494. 493
  495. 494
  496. 495
  497. 496
  498. 497
  499. 498
  500. 499
  501. 500
  502. 501
  503. 502
  504. 503
  505. 504
  506. 505
  507. 506
  508. 507
  509. 508
  510. 509
  511. 510
  512. 511
  513. 512
  514. 513
  515. 514
  516. 515
  517. 516
  518. 517
  519. 518
  520. 519
  521. 520
  522. 521
  523. 522
  524. 523
  525. 524
  526. 525
  527. 526
  528. 527
  529. 528
  530. 529
  531. 530
  532. 531
  533. 532
  534. 533
  535. 534
  536. 535
  537. 536
  538. 537
  539. 538
  540. 539
  541. 540
  542. 541
  543. 542
  544. 543
  545. 544
  546. 545
  547. 546
  548. 547
  549. 548
  550. 549
  551. 550
  552. 551
  553. 552
  554. 553
  555. 554
  556. 555
  557. 556
  558. 557
  559. 558
  560. 559
  561. 560
  562. 561
  563. 562
  564. 563
  565. 564
  566. 565
  567. 566
  568. 567
  569. 568
  570. 569
  571. 570
  572. 571
  573. 572
  574. 573
  575. 574
  576. 575
  577. 576
  578. 577
  579. 578
  580. 579
  581. 580
  582. 581
  583. 582
  584. 583
  585. 584
  586. 585
  587. 586
  588. 587
  589. 588
  590. 589
  591. 590
  592. 591
  593. 592
  594. 593
  595. 594
  596. 595
  597. 596
  598. 597
  599. 598
  600. 599
  601. 600
  602. 601
  603. 602
  604. 603
  605. 604
  606. 605
  607. 606
  608. 607
  609. 608
  610. 609
  611. 610
  612. 611
  613. 612
  614. 613
  615. 614
  616. 615
  617. 616
  618. 617
  619. 618
  620. 619
  621. 620
  622. 621
  623. 622
  624. 623
  625. 624
  626. 625
  627. 626
  628. 627
  629. 628
  630. 629
  631. 630
  632. 631
  633. 632
  634. 633
  635. 634
  636. 635
  637. 636
  638. 637
  639. 638
  640. 639
  641. 640
  642. 641
  643. 642
  644. 643
  645. 644
  646. 645
  647. 646
  648. 647
  649. 648
  650. 649
  651. 650
  652. 651
  653. 652
  654. 653
  655. 654
  656. 655
  657. 656
  658. 657
  659. 658
  660. 659
  661. 660
  662. 661
  663. 662
  664. 663
  665. 664
  666. 665
  667. 666
  668. 667
  669. 668
  670. 669
  671. 670
  672. 671
  673. 672
  674. 673
  675. 674
  676. 675
  677. 676
  678. 677
  679. 678
  680. 679
  681. 680
  682. 681
  683. 682
  684. 683
  685. 684
  686. 685
  687. 686
  688. 687
  689. 688
  690. 689
  691. 690
  692. 691
  693. 692
  694. 693
  695. 694
  696. 695
  697. 696
  698. 697
  699. 698
  700. 699
  701. 700
  702. 701
  703. 702
  704. 703
  705. 704
  706. 705
  707. 706
  708. 707
  709. 708
  710. 709
  711. 710
  712. 711
  713. 712
  714. 713
  715. 714
  716. 715
  717. 716
  718. 717
  719. 718
  720. 719
  721. 720
  722. 721
  723. 722
  724. 723
  725. 724
  726. 725
  727. 726
  728. 727
  729. 728
  730. 729
  731. 730
  732. 731
  733. 732
  734. 733
  735. 734
  736. 735
  737. 736
  738. 737
  739. 738
  740. 739
  741. 740
  742. 741
  743. 742
  744. 743
  745. 744
  746. 745
  747. 746
  748. 747
  749. 748
  750. 749
  751. 750
  752. 751
  753. 752
  754. 753
  755. 754
  756. 755
  757. 756
  758. 757
  759. 758
  760. 759
  761. 760
  762. 761
  763. 762
  764. 763
  765. 764
  766. 765
  767. 766
  768. 767
  769. 768
  770. 769
  771. 770
  772. 771
  773. 772
  774. 773
  775. 774
  776. 775
  777. 776
  778. 777
  779. 778
  780. 779
  781. 780
  782. 781
  783. 782
  784. 783
  785. 784
  786. 785
  787. 786
  788. 787
  789. 788
  790. 789
  791. 790
  792. 791
  793. 792
  794. 793
  795. 794
  796. 795
  797. 796
  798. 797
  799. 798
  800. 799
  801. 800
  802. 801
  803. 802
  804. 803
  805. 804
  806. 805
  807. 806
  808. 807
  809. 808
  810. 809
  811. 810
  812. 811
  813. 812
  814. 813
  815. 814
  816. 815
  817. 816
  818. 817
  819. 818
  820. 819
  821. 820
  822. 821
  823. 822
  824. 823
  825. 824
  826. 825
  827. 826
  828. 827
  829. 828
  830. 829
  831. 830
  832. 831
  833. 832
  834. 833
  835. 834
  836. 835
  837. 836
  838. 837
  839. 838
  840. 839
  841. 840
  842. 841
  843. 842
  844. 843
  845. 844
  846. 845
  847. 846
  848. 847
  849. 848
  850. 849
  851. 850
  852. 851
  853. 852
  854. 853
  855. 854
  856. 855
  857. 856
  858. 857
  859. 858
  860. 859
  861. 860
  862. 861
  863. 862
  864. 863
  865. 864
  866. 865
  867. 866
  868. 867
  869. 868
  870. 869
  871. 870
  872. 871
  873. 872
  874. 873
  875. 874
  876. 875
  877. 876
  878. 877
  879. 878
  880. 879
  881. 880
  882. 881
  883. 882
  884. 883
  885. 884
  886. 885
  887. 886
  888. 887
  889. 888
  890. 889
  891. 890
  892. 891
  893. 892
  894. 893
  895. 894
  896. 895
  897. 896
  898. 897
  899. 898
  900. 899
  901. 900
  902. 901
  903. 902
  904. 903
  905. 904
  906. 905
  907. 906
  908. 907
  909. 908
  910. 909
  911. 910
  912. 911
  913. 912
  914. 913
  915. 914
  916. 915
  917. 916
  918. 917
  919. 918
  920. 919
  921. 920
  922. 921
  923. 922
  924. 923
  925. 924
  926. 925
  927. 926
  928. 927
  929. 928
  930. 929
  931. 930
  932. 931
  933. 932
  934. 933
  935. 934
  936. 935
  937. 936
  938. 937
  939. 938
  940. 939
  941. 940
  942. 941
  943. 942
  944. 943
  945. 944
  946. 945
  947. 946
  948. 947
  949. 948
  950. 949
  951. 950
  952. 951
  953. 952
  954. 953
  955. 954
  956. 955
  957. 956
  958. 957
  959. 958
  960. 959
  961. 960
  962. 961
  963. 962
  964. 963
  965. 964
  966. 965
  967. 966
  968. 967
  969. 968
  970. 969
  971. 970
  972. 971
  973. 972
  974. 973
  975. 974
  976. 975
  977. 976
  978. 977
  979. 978
  980. 979
  981. 980
  982. 981
  983. 982
  984. 983
  985. 984
  986. 985
  987. 986
  988. 987
  989. 988
  990. 989
  991. 990
  992. 991
  993. 992
  994. 993
  995. 994
  996. 995
  997. 996
  998. 997
  999. 998
  1000. 999
  1001. 1000
  1002. 1001
  1003. 1002
  1004. 1003
  1005. 1004
  1006. 1005
  1007. 1006
  1008. 1007
  1009. 1008
  1010. 1009
  1011. 1010
  1012. 1011
  1013. 1012
  1014. 1013
  1015. 1014
  1016. 1015
  1017. 1016
  1018. 1017
  1019. 1018
  1020. 1019
  1021. 1020
  1022. 1021
  1023. 1022
  1024. 1023
  1025. 1024
  1026. 1025
  1027. 1026
  1028. 1027
  1029. 1028
  1030. 1029
  1031. 1030
  1032. 1031
  1033. 1032
  1034. 1033
  1035. 1034
  1036. 1035
  1037. 1036
  1038. 1037
  1039. 1038
  1040. 1039
  1041. 1040
  1042. 1041
  1043. 1042
  1044. 1043
  1045. 1044
  1046. 1045
  1047. 1046
  1048. 1047
  1049. 1048
  1050. 1049
  1051. 1050
  1052. 1051
  1053. 1052
  1054. 1053
  1055. 1054
  1056. 1055
  1057. 1056
  1058. 1057
  1059. 1058
  1060. 1059
  1061. 1060
  1062. 1061
  1063. 1062
  1064. 1063
  1065. 1064
  1066. 1065
  1067. 1066
  1068. 1067
  1069. 1068
  1070. 1069
  1071. 1070
  1072. 1071
  1073. 1072
  1074. 1073
  1075. 1074
  1076. 1075
  1077. 1076
  1078. 1077
  1079. 1078
  1080. 1079
  1081. 1080
  1082. 1081
  1083. 1082
  1084. 1083
  1085. 1084
  1086. 1085
  1087. 1086
  1088. 1087
  1089. 1088
  1090. 1089
  1091. 1090
  1092. 1091
  1093. 1092
  1094. 1093
  1095. 1094
  1096. 1095
  1097. 1096
  1098. 1097
  1099. 1098
  1100. 1099
  1101. 1100
  1102. 1101
  1103. 1102
  1104. 1103
  1105. 1104
  1106. 1105
  1107. 1106
  1108. 1107
  1109. 1108
  1110. 1109
  1111. 1110
  1112. 1111
  1113. 1112
  1114. 1113
  1115. 1114
  1116. 1115
  1117. 1116
  1118. 1117
  1119. 1118
  1120. 1119
  1121. 1120
  1122. 1121
  1123. 1122
  1124. 1123
  1125. 1124
  1126. 1125
  1127. 1126
  1128. 1127
  1129. 1128
  1130. 1129
  1131. 1130
  1132. 1131
  1133. 1132
  1134. 1133
  1135. 1134
  1136. 1135
  1137. 1136
  1138. 1137
  1139. 1138
  1140. 1139
  1141. 1140
  1142. 1141
  1143. 1142
  1144. 1143
  1145. 1144
  1146. 1145
  1147. 1146
  1148. 1147
  1149. 1148
  1150. 1149
  1151. 1150
  1152. 1151
  1153. 1152
  1154. 1153
  1155. 1154
  1156. 1155
  1157. 1156
  1158. 1157
  1159. 1158
  1160. 1159
  1161. 1160
  1162. 1161
  1163. 1162
  1164. 1163
  1165. 1164
  1166. 1165
  1167. 1166
  1168. 1167
  1169. 1168
  1170. 1169
  1171. 1170
  1172. 1171
  1173. 1172
  1174. 1173
  1175. 1174
  1176. 1175
  1177. 1176
  1178. 1177
  1179. 1178
  1180. 1179
  1181. 1180
  1182. 1181
  1183. 1182
  1184. 1183
  1185. 1184
  1186. 1185
  1187. 1186
  1188. 1187
  1189. 1188
  1190. 1189
  1191. 1190
  1192. 1191
  1193. 1192
  1194. 1193
  1195. 1194
  1196. 1195
  1197. 1196
  1198. 1197
  1199. 1198
  1200. 1199
  1201. 1200
  1202. 1201
  1203. 1202
  1204. 1203
  1205. 1204
  1206. 1205
  1207. 1206
  1208. 1207
  1209. 1208
  1210. 1209
  1211. 1210
  1212. 1211
  1213. 1212
  1214. 1213
  1215. 1214
  1216. 1215
  1217. 1216
  1218. 1217
  1219. 1218
  1220. 1219
  1221. 1220
  1222. 1221
  1223. 1222
  1224. 1223
  1225. 1224
  1226. 1225
  1227. 1226
  1228. 1227
  1229. 1228
  1230. 1229
  1231. 1230
  1232. 1231
  1233. 1232
  1234. 1233
  1235. 1234
  1236. 1235
  1237. 1236
  1238. 1237
  1239. 1238
  1240. 1239
  1241. 1240
  1242. 1241
  1243. 1242
  1244. 1243
  1245. 1244
  1246. 1245
  1247. 1246
  1248. 1247
  1249. 1248
  1250. 1249
  1251. 1250
  1252. 1251
  1253. 1252
  1254. 1253
  1255. 1254
  1256. 1255
  1257. 1256
  1258. 1257
  1259. 1258
  1260. 1259
  1261. 1260
  1262. 1261
  1263. 1262
  1264. 1263
  1265. 1264
  1266. 1265
  1267. 1266
  1268. 1267
  1269. 1268
  1270. 1269
  1271. 1270
  1272. 1271
  1273. 1272
  1274. 1273
  1275. 1274
  1276. 1275
  1277. 1276
  1278. 1277
  1279. 1278
  1280. 1279
  1281. 1280
  1282. 1281
  1283. 1282
  1284. 1283
  1285. 1284
  1286. 1285
  1287. 1286
  1288. 1287
  1289. 1288
  1290. 1289
  1291. 1290
  1292. 1291
  1293. 1292
  1294. 1293
  1295. 1294
  1296. 1295
  1297. 1296
  1298. 1297
  1299. 1298
  1300. 1299
  1301. 1300
  1302. 1301
  1303. 1302
  1304. 1303
  1305. 1304
  1306. 1305
  1307. 1306
  1308. 1307
  1309. 1308
  1310. 1309
  1311. 1310
  1312. 1311
  1313. 1312
  1314. 1313
  1315. 1314
  1316. 1315
  1317. 1316
  1318. 1317
  1319. 1318
  1320. 1319
  1321. 1320
  1322. 1321
  1323. 1322
  1324. 1323
  1325. 1324
  1326. 1325
  1327. 1326
  1328. 1327
  1329. 1328
  1330. 1329
  1331. 1330
  1332. 1331
  1333. 1332
  1334. 1333
  1335. 1334
  1336. 1335
  1337. 1336
  1338. 1337
  1339. 1338
  1340. 1339
  1341. 1340
  1342. 1341
  1343. 1342
  1344. 1343
  1345. 1344
  1346. 1345
  1347. 1346
  1348. 1347
  1349. 1348
  1350. 1349
  1351. 1350
  1352. 1351
  1353. 1352
  1354. 1353
  1355. 1354
  1356. 1355
  1357. 1356
  1358. 1357
  1359. 1358
  1360. 1359
  1361. 1360
  1362. 1361
  1363. 1362
  1364. 1363
  1365. 1364
  1366. 1365
  1367. 1366
  1368. 1367
  1369. 1368
  1370. 1369
  1371. 1370
  1372. 1371
  1373. 1372
  1374. 1373
  1375. 1374
  1376. 1375
  1377. 1376
  1378. 1377
  1379. 1378
  1380. 1379
  1381. 1380
  1382. 1381
  1383. 1382
  1384. 1383
  1385. 1384
  1386. 1385
  1387. 1386
  1388. 1387
  1389. 1388
  1390. 1389
  1391. 1390
  1392. 1391
  1393. 1392
  1394. 1393
  1395. 1394
  1396. 1395
  1397. 1396
  1398. 1397
  1399. 1398
  1400. 1399
  1401. 1400
  1402. 1401
  1403. 1402
  1404. 1403
  1405. 1404
  1406. 1405
  1407. 1406
  1408. 1407
  1409. 1408
  1410. 1409
  1411. 1410
  1412. 1411
  1413. 1412
  1414. 1413
  1415. 1414
  1416. 1415
  1417. 1416
  1418. 1417
  1419. 1418
  1420. 1419
  1421. 1420
  1422. 1421
  1423. 1422
  1424. 1423
  1425. 1424
  1426. 1425
  1427. 1426
  1428. 1427
  1429. 1428
  1430. 1429
  1431. 1430
  1432. 1431
  1433. 1432
  1434. 1433
  1435. 1434
  1436. 1435
  1437. 1436
  1438. 1437
  1439. 1438
  1440. 1439
  1441. 1440
  1442. 1441
  1443. 1442
  1444. 1443
  1445. 1444
  1446. 1445
  1447. 1446
  1448. #!/bin/bash
  1449.  
  1450. #######################################################################
  1451. #
  1452. # This script builds a SOGo/OpenChange Server on Ubuntu 14.04
  1453. #
  1454. # 2015-07-09 - Gerald Brandt - Original Version
  1455. #
  1456. # This script is GPLv2 Licensed
  1457. #
  1458. #######################################################################
  1459.  
  1460. installback=""
  1461. installstr=""
  1462. hostname=""
  1463. domainname=""
  1464. ipaddress=""
  1465. netmask=""
  1466. gateway=""
  1467. nameserver2=""
  1468. dompart1=""
  1469. dompart2=""
  1470. workgroup=""
  1471. password=""
  1472. timezone=""
  1473. upperdomain=""
  1474. upperhost=""
  1475. upperworkgroup=""
  1476. genpassword=""
  1477. cidr=""
  1478. basenet=""
  1479.  
  1480. #######################################################################
  1481. #
  1482. #
  1483. # @return 0 for failure
  1484. # 1 for success
  1485. #
  1486. # @brief
  1487. # configure the network
  1488. #
  1489. #######################################################################
  1490. configure_network () {
  1491.  
  1492. # configure network
  1493. installstr+="Preparing Network\n"
  1494. dialog --title " Please Wait... " --backtitle "$installback" \
  1495.  --infobox $installstr 15 50 2>.tmp
  1496.  
  1497. echo "Configuring network" >> INSTALL-LOG
  1498. echo "###################################################################################" >> INSTALL-LOG 2>&1
  1499. echo " Configure Network" >> INSTALL-LOG 2>&1
  1500. echo "###################################################################################" >> INSTALL-LOG 2>&1
  1501. echo " "
  1502.  
  1503. # build a proper static ip network
  1504. cp /etc/network/interfaces /etc/network/interfaces-orig >> INSTALL-LOG
  1505. echo "
  1506. auto lo
  1507. iface lo inet loopback
  1508.  
  1509. auto eth0
  1510. iface eth0 inet static
  1511. address $ipaddress
  1512. netmask $netmask
  1513. gateway $gateway
  1514. dns-nameservers $ipaddress
  1515. dns-search $domainname
  1516. " > /etc/network/interfaces
  1517.  
  1518. # add us to the hosts file
  1519. apt-get -y install rpl >> INSTALL-LOG 2>&1
  1520. response=$?
  1521. case $response in
  1522.  100)
  1523.  whiptail --title " ERROR " --backtitle "$installback" \
  1524.  --infobox "Failed to install rpl. See INSTALL-LOG" 10 50
  1525.  
  1526. exit
  1527.  ;;
  1528.  
  1529. esac
  1530.  
  1531. echo "Save old files..." >> INSTALL-LOG 2>&1
  1532. cp /etc/hosts /etc/hosts-orig >> INSTALL-LOG 2>&1
  1533. cp /etc/hostname /etc/hostname-orig >> INSTALL-LOG 2>&1
  1534. cp /etc/resolv.conf /etc/resolv.conf-orig >> INSTALL-LOG 2>&1
  1535. read oldhostname < /etc/hostname
  1536. rpl $oldhostname $hostname /etc/hosts >> INSTALL-LOG 2>&1
  1537. hostname $hostname >> INSTALL-LOG 2>&1
  1538.  
  1539. echo "$ipaddress $hostname.$domainname $hostname" >> /etc/hosts
  1540. echo $hostname > /etc/hostname
  1541.  
  1542. echo "retstart the network"
  1543.  
  1544. # restart the network
  1545. ifdown eth0 >> INSTALL-LOG 2>&1
  1546. service resolvconf restart 2>&1
  1547. ifup eth0 >> INSTALL-LOG 2>&1
  1548.  
  1549. # set the proper name resolution (temp, reboot will reset this properly)
  1550. # we'll get rid of 8.8.8.8 after samba is up
  1551. echo "nameserver $ipaddress" > /etc/resolv.conf
  1552. echo "nameserver 8.8.8.8" >> /etc/resolv.conf
  1553. echo "search $domainname" >> /etc/resolv.conf
  1554. echo "domain $domainname" >> /etc/resolv.conf
  1555.  
  1556.  
  1557. }
  1558.  
  1559.  
  1560. #######################################################################
  1561. #
  1562. # @param none
  1563. #
  1564. # @return 0 for failure
  1565. # 1 for success
  1566. #
  1567. # @brief
  1568. # Modify the fstab for acl's and remount
  1569. #
  1570. #######################################################################
  1571. modify_fstab () {
  1572. installstr+="Modifying fstab\n"
  1573. dialog --title " Please Wait... " --backtitle "$installback" \
  1574.  --infobox $installstr 15 50 2>.tmp
  1575.  
  1576. echo "###################################################################################" >> INSTALL-LOG 2>&1
  1577. echo " Modifying fstab" >> INSTALL-LOG 2>&1
  1578. echo "###################################################################################" >> INSTALL-LOG 2>&1
  1579. echo " "
  1580.  
  1581. # modify the fstab for acl's
  1582. cp /etc/fstab /etc/fstab-orig
  1583. rpl -e "errors=remount-ro" "user_xattr,acl,barrier=1,errors=remount-ro,relatime" /etc/fstab >> INSTALL-LOG 2>&1
  1584.  
  1585. # remount /
  1586. mount -o remount / >> INSTALL-LOG 2>&1
  1587.  
  1588. }
  1589.  
  1590.  
  1591. #######################################################################
  1592. #
  1593. # @return 0 for failure
  1594. # 1 for success
  1595. #
  1596. # @brief
  1597. # We use samba 4 for user auth, so get it installed and running with the proper domain
  1598. #
  1599. #######################################################################
  1600. install_samba () {
  1601.  
  1602. echo "###################################################################################" >> INSTALL-LOG 2>&1
  1603. echo " INSTALL SAMBA" >> INSTALL-LOG 2>&1
  1604. echo "###################################################################################" >> INSTALL-LOG 2>&1
  1605. echo
  1606.  
  1607. installstr+="Samba : install"
  1608. dialog --title " Please Wait... " --backtitle "$installback" \
  1609.  --infobox "$installstr" 15 50 2>.tmp
  1610.  
  1611. echo krb5-config krb5-config/admin_server string $hostname.$domainname > krb5-config
  1612. echo krb5-config krb5-config/kerberos-servers string $hostname.$domainname >> krb5-config
  1613. echo krb5-config krb5-config/default_realm string $domainname >> krb5-config
  1614. echo krb5-config krb5-config/add_servers_realm string $domainname >> krb5-config
  1615. echo krb5-config krb5-config/add_servers boolean false >> krb5-config
  1616.  
  1617. cat krb5-config | debconf-set-selections
  1618.  
  1619. apt-get -y install ntp acl samba samba-dev krb5-user attr smbclient dnsutils python-dnspython winbind ldap-utils >> INSTALL-LOG 2>&1
  1620. #apt-get -y install ntp acl samba samba-dev krb5-user attr smbclient dnsutils python-dnspython winbind ldap-utils >> INSTALL-LOG 2>&1
  1621. response=$?
  1622. case $response in
  1623.  100)
  1624.  whiptail --title " ERROR " --backtitle "$installback" \
  1625.  --infobox "Failed to install Samba. See INSTALL-LOG" 10 50
  1626.  
  1627. exit
  1628.  ;;
  1629.  
  1630. esac
  1631.  
  1632. installstr+=" - config"
  1633. dialog --title " Please Wait... " --backtitle "$installback" \
  1634.  --infobox "$installstr" 15 50 2>.tmp
  1635.  
  1636. service samba stop >> INSTALL-LOG 2>&1
  1637. service smbd stop >> INSTALL-LOG 2>&1
  1638. service samba-ad-dc stop >> INSTALL-LOG 2>&1
  1639.  
  1640.  
  1641. # sometimes, these don't stop
  1642. killall -9 smbd >> INSTALL-LOG 2>&1
  1643. killall -9 nmbd >> INSTALL-LOG 2>&1
  1644. killall -9 samba >> INSTALL-LOG 2>&1
  1645.  
  1646. service ntp stop >> INSTALL-LOG 2>&1
  1647. ntpdate -B ca.pool.ntp.org >> INSTALL-LOG 2>&1
  1648. service ntp start >> INSTALL-LOG 2>&1
  1649.  
  1650.  
  1651. mv /etc/samba/smb.conf /etc/samba/smb.conf-orig >> INSTALL-LOG 2>&1
  1652.  
  1653. #provision samba
  1654. echo running: samba-tool domain provision --realm=$domainname --domain=$upperworkgroup --adminpass=$password --server-role=dc --use-rfc2307 --host-name=$hostname --host-ip=$ipaddress --use-xattrs=yes --dns-backend=SAMBA_INTERNAL >> INSTALL-LOG 2>&1
  1655.  
  1656. samba-tool domain provision --realm=$domainname --domain=$upperworkgroup --adminpass=$password --server-role=dc --use-rfc2307 --host-name=$hostname --host-ip=$ipaddress --use-xattrs=yes --dns-backend=SAMBA_INTERNAL >> INSTALL-LOG 2>&1
  1657.  
  1658. cp /var/lib/samba/private/krb5.conf /etc
  1659.  
  1660. # set the proper name resolution (in order to finish install)
  1661. echo "nameserver $ipaddress" > /etc/resolv.conf
  1662. echo "search $domainname" >> /etc/resolv.conf
  1663.  
  1664.  
  1665. service samba-ad-dc restart >> INSTALL-LOG 2>&1
  1666. samba-tool domain level raise --domain-level 2008_R2 --forest-level 2008_R2 >> INSTALL-LOG 2>&1
  1667. samba-tool domain passwordsettings set --complexity=off >> INSTALL-LOG 2>&1
  1668. samba-tool domain passwordsettings set --min-pwd-length=1 >> INSTALL-LOG 2>&1
  1669.  
  1670. #*****************************************************************
  1671. # TODO TODO TODO
  1672. #
  1673. # figure out how to pass password in so it's not requested
  1674. #
  1675. #*****************************************************************
  1676. samba-tool user setpassword Administrator <<< $password
  1677. #expect -c "
  1678. # spawn samba-tool user setpassword Administrator
  1679. # expect "?assword: "
  1680. # send $password
  1681. # expect eof"
  1682.  
  1683. samba-tool user setexpiry Administrator --noexpiry >> INSTALL-LOG 2>&1
  1684.  
  1685. service samba-ad-dc restart >> INSTALL-LOG 2>&1
  1686.  
  1687. echo "
  1688. # Global parameters
  1689. [global]
  1690. server role = active directory domain controller
  1691. workgroup = $upperworkgroup
  1692. realm = $domainname
  1693. netbios name = $hostname
  1694. passdb backend = samba4
  1695. dns forwarder = $nameserver2
  1696.  
  1697. [netlogon]
  1698. path = /var/lib/samba/sysvol/example.com/scripts
  1699. read only = No
  1700.  
  1701. [sysvol]
  1702. path = /var/lib/samba/sysvol
  1703. read only = No
  1704. " > /etc/samba/smb.conf
  1705.  
  1706. service samba-ad-dc stop >> INSTALL-LOG 2>&1
  1707.  
  1708. # sometimes, these don't stop
  1709. killall -9 smbd >> INSTALL-LOG 2>&1
  1710. killall -9 nmbd >> INSTALL-LOG 2>&1
  1711. killall -9 samba >> INSTALL-LOG 2>&1
  1712.  
  1713. # none of this seems to work, smbd starts and samba-ad-dc doesn't. Neither does ocsmanager
  1714. mv /etc/init/smbd.conf /etc/init/smbd.conf.disabled >> INSTALL-LOG 2>&1
  1715. mv /etc/init/reload-smbd.conf /etc/init/reload-smbd.conf.disabled >> INSTALL-LOG 2>&1
  1716. mv /etc/init/nmbd.conf /etc/init/nmbd.conf.disabled >> INSTALL-LOG 2>&1
  1717. mv /etc/init/samba.conf /etc/init/samba.conf.disabled >> INSTALL-LOG 2>&1
  1718.  
  1719. update-rc.d -f smbd remove >> INSTALL-LOG 2>&1
  1720. update-rc.d -f nmbd remove >> INSTALL-LOG 2>&1
  1721. update-rc.d -f samba remove >> INSTALL-LOG 2>&1
  1722.  
  1723. update-rc.d samba-ad-dc defaults >> INSTALL-LOG 2>&1
  1724.  
  1725. service samba-ad-dc start >> INSTALL-LOG 2>&1
  1726.  
  1727. echo "nameserver $ipaddress" > /etc/resolv.conf
  1728. echo "nameserver 8.8.8.8" >> /etc/resolv.conf
  1729. echo "search $domainname" >> /etc/resolv.conf
  1730. echo "domain $domainname" >> /etc/resolv.conf
  1731.  
  1732. installstr+=" - done\n"
  1733. dialog --title " Please Wait... " --backtitle "$installback" \
  1734.  --infobox "$installstr" 15 50 2>.tmp
  1735.  
  1736. }
  1737.  
  1738. #######################################################################
  1739. #
  1740. # @param
  1741. #
  1742. # @return 0 for failure
  1743. # 1 for success
  1744. #
  1745. # @brief
  1746. # Install dovecot and config to authenticate against samba
  1747. #
  1748. #######################################################################
  1749. install_dovecot () {
  1750. echo "###################################################################################" >> INSTALL-LOG 2>&1
  1751. echo " INSTALL DOVECOT" >> INSTALL-LOG 2>&1
  1752. echo "###################################################################################" >> INSTALL-LOG 2>&1
  1753. echo
  1754. installstr+="Dovecot : install"
  1755. dialog --title " Please Wait... " --backtitle "$installback" --infobox "$installstr" 15 50 2>.tmp
  1756.  
  1757. # create user
  1758. groupadd -g 5000 vmail >> INSTALL-LOG 2>&1
  1759. useradd -m -u 5000 -g 5000 -s /bin/bash -d /var/mail vmail >> INSTALL-LOG 2>&1
  1760. adduser vmail mail >> INSTALL-LOG 2>&1
  1761. chown -R vmail:vmail /var/mail >> INSTALL-LOG 2>&1
  1762.  
  1763. # preseed
  1764. echo "dovecot-core dovecot-core/create-ssl-cert boolean true
  1765. dovecot-core dovecot-core/ssl-cert-name string localhost" | debconf-set-selections
  1766.  
  1767. apt-get -y install dovecot-imapd dovecot-pop3d dovecot-ldap dovecot-managesieved dovecot-sieve dovecot-lmtpd >> INSTALL-LOG 2>&1
  1768. response=$?
  1769. case $response in
  1770.  100)
  1771.  whiptail --title " ERROR " --backtitle "$installback" \
  1772.  --infobox "Failed to install Dovecot. See INSTALL-LOG" 10 50
  1773.  
  1774. exit
  1775.  ;;
  1776.  
  1777. esac
  1778.  
  1779. installstr+=" - config"
  1780. dialog --title " Please Wait... " --backtitle "$installback" \
  1781.  --infobox "$installstr" 15 50 2>.tmp
  1782.  
  1783. echo -e "
  1784. # Enable installed protocols
  1785. !include_try /usr/share/dovecot/protocols.d/*.protocol
  1786.  
  1787. postmaster_address=administrator@$domainname
  1788.  
  1789. # AUTH
  1790. disable_plaintext_auth = yes
  1791. auth_master_user_separator = *
  1792. auth_mechanisms = plain login
  1793.  
  1794. # master users
  1795. #passdb {
  1796. # driver = passwd-file
  1797. # master = yes
  1798. # args = /etc/dovecot/master-users
  1799.  
  1800. # Unless you're using PAM, you probably still want the destination user to
  1801. # be looked up from passdb that it really exists. pass=yes does that.
  1802. #pass = yes
  1803. #}
  1804.  
  1805. # ldap users
  1806. passdb {
  1807. driver = ldap
  1808. args = /etc/dovecot/dovecot-ldap.conf.ext
  1809. }
  1810.  
  1811. userdb {
  1812. driver = ldap
  1813. args = /etc/dovecot/dovecot-ldap.conf.ext
  1814. }
  1815.  
  1816. # trust on 127.0.0.1
  1817. passdb {
  1818. driver = static
  1819. args = nopassword=y allow_nets=127.0.0.1/32
  1820. }
  1821.  
  1822.  
  1823. # LOGGING
  1824. auth_verbose = yes
  1825. mail_debug = no
  1826. plugin {
  1827. # Events to log. Also available: flag_change append
  1828. #mail_log_events = delete undelete expunge copy mailbox_delete mailbox_rename
  1829. # Available fields: uid, box, msgid, from, subject, size, vsize, flags
  1830. # size and vsize are available only for expunge and copy events.
  1831. #mail_log_fields = uid box msgid size
  1832. }
  1833.  
  1834. # MAIL and NAMESPACES
  1835. mail_location = maildir:~/maildir
  1836. mail_uid = vmail
  1837. mail_gid = vmail
  1838. mail_plugins = acl quota
  1839.  
  1840. namespace {
  1841. type = private
  1842. separator = /
  1843. prefix =
  1844. inbox = yes
  1845.  
  1846. mailbox INBOX {
  1847. auto = create
  1848. }
  1849. }
  1850. namespace {
  1851. type = shared
  1852. separator = /
  1853. prefix = shared/%%u/
  1854. location = maildir:%%h/maildir:INDEX=~/maildir/shared/%%u
  1855. subscriptions = no
  1856. list = children
  1857. }
  1858.  
  1859.  
  1860. # MASTER
  1861. service imap-login {
  1862. inet_listener imap {
  1863. #port = 143
  1864. }
  1865. inet_listener imaps {
  1866. #port = 993
  1867. ssl = yes
  1868. }
  1869. # this is suboptimal since imap and imaps will also accept nopass
  1870. inet_listener imap-nopass {
  1871. port = 144
  1872. }
  1873.  
  1874. }
  1875. service pop3-login {
  1876. inet_listener pop3 {
  1877. #port = 110
  1878. }
  1879. inet_listener pop3s {
  1880. #port = 995
  1881. #ssl = yes
  1882. }
  1883. }
  1884. service lmtp {
  1885. unix_listener lmtp {
  1886. #mode = 0666
  1887. }
  1888. # Create inet listener only if you can't use the above UNIX socket
  1889. inet_listener lmtp {
  1890. # Avoid making LMTP visible for the entire internet
  1891. address = 127.0.0.1
  1892. port = 24
  1893. }
  1894. }
  1895. service imap {
  1896. executable = imap postlogin
  1897. }
  1898. service auth {
  1899. # auth_socket_path points to this userdb socket by default. It's typically
  1900. # used by dovecot-lda, doveadm, possibly imap process, etc. Its default
  1901. # permissions make it readable only by root, but you may need to relax these
  1902. # permissions. Users that have access to this socket are able to get a list
  1903. # of all usernames and get results of everyone's userdb lookups.
  1904. unix_listener /var/spool/postfix/private/auth {
  1905. mode = 0660
  1906. user = postfix
  1907. group = postfix
  1908. }
  1909. }
  1910. service postlogin {
  1911. executable = script-login -d rawlog
  1912. unix_listener postlogin {
  1913. }
  1914. }
  1915.  
  1916. # SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>
  1917. ssl = yes
  1918. ssl_cert = </etc/ssl/certs/dovecot.pem
  1919. ssl_key = </etc/ssl/private/dovecot.pem
  1920.  
  1921. # LDA
  1922. quota_full_tempfail = yes
  1923. protocol lda {
  1924. # Space separated list of plugins to load (default is global mail_plugins).
  1925. #mail_plugins = \$mail_plugins
  1926. }
  1927.  
  1928. # PROTOCOLS
  1929. protocol imap {
  1930. mail_plugins = \$mail_plugins autocreate imap_acl imap_quota
  1931. }
  1932. protocol lmtp {
  1933. mail_plugins = \$mail_plugins sieve
  1934. }
  1935.  
  1936. service managesieve-login {
  1937. inet_listener sieve {
  1938. port = 4190
  1939. address = 127.0.0.1
  1940. }
  1941. }
  1942. service managesieve {
  1943. }
  1944. protocol sieve {
  1945. }
  1946.  
  1947. plugin {
  1948. acl = vfile
  1949. acl_shared_dict = file:/var/spool/dovecot/shared-mailboxes.db
  1950.  
  1951. quota_rule = *:storage=2G
  1952. quota_rule2 = Trash:storage=+100M
  1953. quota = dict:::file:%h/dovecot-quota
  1954.  
  1955. sieve = ~/.dovecot.sieve
  1956. sieve_dir = ~/sieve
  1957.  
  1958. autocreate = Trash
  1959. autosubscribe = Trash
  1960. autocreate2 = Drafts
  1961. autosubscribe2 = Drafts
  1962. autocreate3 = Sent
  1963. }
  1964.  
  1965. " > /etc/dovecot/dovecot.conf
  1966.  
  1967. echo -e "
  1968. hosts = 127.0.0.1:389
  1969. dn = cn=administrator,cn=Users,dc=${DOM[0]},dc=${DOM[1]}
  1970. dnpass = $password
  1971. base = cn=Users,dc=${DOM[0]},dc=${DOM[1]}
  1972. auth_bind = yes
  1973. pass_filter = (cn=%n)
  1974. user_filter = (cn=%n)
  1975. user_attrs = cn=home=/var/spool/dovecot/%$
  1976. " > /etc/dovecot/dovecot-ldap.conf.ext
  1977.  
  1978. rpl -e "#C=FI" "C=CA" /usr/share/doc/dovecot-core/dovecot/dovecot-openssl.cnf >> INSTALL-LOG 2>&1
  1979. rpl -e "#ST=" "ST=Manitoba" /usr/share/doc/dovecot-core/dovecot/dovecot-openssl.cnf >> INSTALL-LOG 2>&1
  1980. rpl -e "#L=Helsinki" "L=Winnipeg" /usr/share/doc/dovecot-core/dovecot/dovecot-openssl.cnf >> INSTALL-LOG 2>&1
  1981. rpl -e "#O=Dovecot" "O=$workgroup" /usr/share/doc/dovecot-core/dovecot/dovecot-openssl.cnf >> INSTALL-LOG 2>&1
  1982. rpl -e "CN=imap.example.com" "CN=*.$domainname" /usr/share/doc/dovecot-core/dovecot/dovecot-openssl.cnf >> INSTALL-LOG 2>&1
  1983. rpl -e "emailAddress=postmaster@example.com" "emailAddress=postmaster@$domainname" /usr/share/doc/dovecot-core/dovecot/dovecot-openssl.cnf >> INSTALL-LOG 2>&1
  1984.  
  1985. pushd .
  1986. cd /usr/share/doc/dovecot-core/dovecot >> INSTALL-LOG 2>&1
  1987. chmod +x mkcert.sh >> INSTALL-LOG 2>&1
  1988. ./mkcert.sh >> INSTALL-LOG 2>&1
  1989. popd
  1990. touch /var/log/dovecot.message
  1991. chown vmail.vmail /var/log/dovecot.message
  1992.  
  1993.  
  1994. mkdir /var/spool/dovecot
  1995. chown vmail.vmail /var/spool/dovecot
  1996.  
  1997. service dovecot restart >> INSTALL-LOG 2>&1
  1998.  
  1999. installstr+=" - done\n"
  2000. dialog --title " Please Wait... " --backtitle "$installback" --infobox "$installstr" 15 50 2>.tmp
  2001.  
  2002. }
  2003.  
  2004. #######################################################################
  2005. #
  2006. # @param
  2007. #
  2008. # @return 0 for failure
  2009. # 1 for success
  2010. #
  2011. # @brief
  2012. # Install imapproxy
  2013. #
  2014. #######################################################################
  2015. install_imapproxy () {
  2016. echo "###################################################################################" >> INSTALL-LOG 2>&1
  2017. echo " INSTALL IMAPPROXY" >> INSTALL-LOG 2>&1
  2018. echo "###################################################################################" >> INSTALL-LOG 2>&1
  2019. echo " " >> INSTALL-LOG 2>&1
  2020.  
  2021. #just in case
  2022. service dovecot restart >> INSTALL-LOG 2>&1
  2023.  
  2024.  
  2025. installstr+="IMAP Proxy: install"
  2026. dialog --title " Please Wait... " --backtitle "$installback" --infobox "$installstr" 15 50 2>.tmp
  2027. apt-get -y install imapproxy >> INSTALL-LOG 2>&1
  2028.  
  2029. installstr+=" - config"
  2030. dialog --title " Please Wait... " --backtitle "$installback" \
  2031.  --infobox "$installstr" 15 50 2>.tmp
  2032.  
  2033. echo -e "
  2034. server_hostname localhost
  2035. connect_retries 10
  2036. connect_delay 5
  2037. cache_size 3072
  2038. listen_port 1143
  2039. server_port 143
  2040. cache_expiration_time 300
  2041. proc_username nobody
  2042. proc_groupname nogroup
  2043. stat_filename /var/run/pimpstats
  2044. protocol_log_filename /var/log/imapproxy_protocol.log
  2045. syslog_facility LOG_MAIL
  2046. send_tcp_keepalives no
  2047. enable_select_cache no
  2048. foreground_mode no
  2049. force_tls no
  2050. chroot_directory /var/lib/imapproxy/chroot
  2051. enable_admin_commands no
  2052. " > /etc/imapproxy.conf
  2053.  
  2054. installstr+=" - done\n"
  2055. dialog --title " Please Wait... " --backtitle "$installback" \
  2056.  --infobox "$installstr" 15 50 2>.tmp
  2057.  
  2058. }
  2059.  
  2060.  
  2061.  
  2062. #######################################################################
  2063. #
  2064. # @param
  2065. #
  2066. # @return 0 for failure
  2067. # 1 for success
  2068. #
  2069. # @brief
  2070. # Install postfix and configure to autheticate against ldap
  2071. #
  2072. #######################################################################
  2073. install_postfix () {
  2074. echo "###################################################################################" >> INSTALL-LOG 2>&1
  2075. echo " INSTALL POSTFIX" >> INSTALL-LOG 2>&1
  2076. echo "###################################################################################" >> INSTALL-LOG 2>&1
  2077. echo
  2078. installstr+="Postfix : install"
  2079. dialog --title " Please Wait... " --backtitle "$installback" --infobox "$installstr" 15 50 2>.tmp
  2080.  
  2081. echo postfix postfix/main_mailer_type select Internet Site > postfix-config
  2082. echo postfix postfix/mailname string $domainname >> postfix-config
  2083. echo postfix postfix/destinations string $domainname, localhost, localhost.localdomain >> postfix-config
  2084.  
  2085. cat postfix-config | debconf-set-selections
  2086.  
  2087. apt-get -y install postfix postfix-ldap >> INSTALL-LOG 2>&1
  2088. response=$?
  2089. case $response in
  2090.  100)
  2091.  whiptail --title " ERROR " --backtitle "$installback" \
  2092.  --infobox "Failed to install Postfix. See INSTALL-LOG" 10 50
  2093.  
  2094. exit
  2095.  ;;
  2096.  
  2097. esac
  2098.  
  2099. installstr+=" - config"
  2100. dialog --title " Please Wait... " --backtitle "$installback" \
  2101.  --infobox "$installstr" 15 50 2>.tmp
  2102.  
  2103. echo -e "
  2104. # See /usr/share/postfix/main.cf.dist for a commented, more complete version
  2105.  
  2106.  
  2107. # Debian specific: Specifying a file name will cause the first
  2108. # line of that file to be used as the name. The Debian default
  2109. # is /etc/mailname.
  2110. #myorigin = /etc/mailname
  2111.  
  2112. smtpd_banner = \$myhostname ESMTP \$mail_name (Ubuntu)
  2113. biff = no
  2114.  
  2115. # appending .domain is the MUA's job.
  2116. append_dot_mydomain = no
  2117.  
  2118. # Uncomment the next line to generate "delayed mail" warnings
  2119. #delay_warning_time = 4h
  2120.  
  2121. readme_directory = no
  2122.  
  2123. # TLS parameters
  2124. smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
  2125. smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
  2126. smtpd_use_tls=yes
  2127. smtpd_tls_session_cache_database = btree:\${data_directory}/smtpd_scache
  2128. smtp_tls_session_cache_database = btree:\${data_directory}/smtp_scache
  2129.  
  2130. # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
  2131. # information on enabling SSL in the smtp client.
  2132.  
  2133. smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
  2134. myhostname = $hostname.$domainname
  2135. alias_maps = hash:/etc/aliases
  2136. alias_database = hash:/etc/aliases
  2137. myorigin = /etc/mailname
  2138. mydestination = localhost, \$myhostname, \$mydomain
  2139. relayhost =
  2140. mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 $basenet/$cidr
  2141. mailbox_size_limit = 0
  2142. recipient_delimiter = +
  2143. inet_interfaces = all
  2144. inet_protocols = all
  2145. virtual_alias_maps = ldap:/etc/postfix/people.ldap
  2146. mailbox_transport = lmtp:127.0.0.1:24
  2147.  
  2148. # SASL Auth
  2149. smtpd_sasl_auth_enable = yes
  2150. smtpd_sasl_security_options = noanonymous
  2151. smtpd_sasl_type = dovecot
  2152. smtpd_sasl_path = private/auth
  2153. smtpd_sasl_local_domain = \$myorigin
  2154. broken_sasl_auth_clients = yes
  2155. " > /etc/postfix/main.cf
  2156.  
  2157. echo -e "
  2158. version = 3
  2159. server_port = 389
  2160. timeout = 60
  2161. search_base = cn=Users,dc=${DOM[0]},dc=${DOM[1]}
  2162. query_filter = (mail=%s)
  2163. result_attribute = cn
  2164. bind = yes
  2165. bind_dn = cn=administrator,cn=Users,dc=${DOM[0]},dc=${DOM[1]}
  2166. bind_pw = $password
  2167. server_host = ldap://127.0.0.1:389/
  2168. " > /etc/postfix/people.ldap
  2169.  
  2170. #echo -e "\ndovecot unix - n n - - pipe
  2171. # flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -d \${user}" >> /etc/postfix/master.cf
  2172.  
  2173. service postfix restart >> INSTALL-LOG 2>&1
  2174.  
  2175. installstr+=" - done\n"
  2176. dialog --title " Please Wait... " --backtitle "$installback" \
  2177.  --infobox "$installstr" 15 50 2>.tmp
  2178.  
  2179. }
  2180.  
  2181.  
  2182. #######################################################################
  2183. #
  2184. # @param
  2185. #
  2186. # @return 0 for failure
  2187. # 1 for success
  2188. #
  2189. # @brief
  2190. # install mysql for sogos (and later on ocsmanagers) use
  2191. #
  2192. #######################################################################
  2193. install_mysql () {
  2194. echo "###################################################################################" >> INSTALL-LOG 2>&1
  2195. echo " INSTALL MySQL" >> INSTALL-LOG 2>&1
  2196. echo "###################################################################################" >> INSTALL-LOG 2>&1
  2197. echo
  2198. installstr+="MySQL : install"
  2199. dialog --title " Please Wait... " --backtitle "$installback" --infobox "$installstr" 15 50 2>.tmp
  2200.  
  2201. # set up the preseed
  2202. # we use the user supplied admin password for the mysql db
  2203. echo "mysql-server-5.5 mysql-server/root_password password $password
  2204. mysql-server-5.5 mysql-server/root_password seen true
  2205. mysql-server-5.5 mysql-server/root_password_again password $password
  2206. mysql-server-5.5 mysql-server/root_password_again seen true
  2207. " | debconf-set-selections
  2208.  
  2209. apt-get -y install mysql-server mysql-client python-mysqldb >> INSTALL-LOG 2>&1
  2210. response=$?
  2211. case $response in
  2212.  100)
  2213.  whiptail --title " ERROR " --backtitle "$installback" \
  2214.  --infobox "Failed to install MySQL. See INSTALL-LOG" 10 50
  2215.  
  2216. exit
  2217.  ;;
  2218.  
  2219. esac
  2220.  
  2221. installstr+=" - config"
  2222. dialog --title " Please Wait... " --backtitle "$installback" \
  2223.  --infobox "$installstr" 15 50 2>.tmp
  2224.  
  2225.  
  2226. service mysql restart >> INSTALL-LOG 2>&1
  2227.  
  2228. installstr+=" - done\n"
  2229. dialog --title " Please Wait... " --backtitle "$installback" \
  2230.  --infobox "$installstr" 15 50 2>.tmp
  2231.  
  2232. }
  2233.  
  2234.  
  2235. #######################################################################
  2236. #
  2237. # @param
  2238. #
  2239. # @return 0 for failure
  2240. # 1 for success
  2241. #
  2242. # @brief
  2243. # Install the SOGo server
  2244. #
  2245. #######################################################################
  2246. install_sogo () {
  2247. echo "###################################################################################" >> INSTALL-LOG 2>&1
  2248. echo " INSTALL SOGo" >> INSTALL-LOG 2>&1
  2249. echo "###################################################################################" >> INSTALL-LOG 2>&1
  2250. echo
  2251. installstr+="SOGo : install"
  2252. dialog --title " Please Wait... " --backtitle "$installback" --infobox "$installstr" 15 50 2>.tmp
  2253.  
  2254. # set up the preseed
  2255. echo "tmpreaper tmpreaper/TMPREAPER_TIME note
  2256. tmpreaper tmpreaper/confignowexists note
  2257. tmpreaper tmpreaper/readsecurity note
  2258. tmpreaper tmpreaper/readsecurity_upgrading note" | debconf-set-selections
  2259.  
  2260. #apt-get -y install sogo sogo-activesync libwbxml2-0 python-mysqldb python-sievelib >> INSTALL-LOG 2>&1
  2261. apt-get -y install sogo sogo-activesync >> INSTALL-LOG 2>&1
  2262. response=$?
  2263. case $response in
  2264.  100)
  2265.  whiptail --title " ERROR " --backtitle "$installback" \
  2266.  --infobox "Failed to install SOGo. See INSTALL-LOG" 10 50
  2267.  
  2268. exit
  2269.  ;;
  2270.  
  2271. esac
  2272.  
  2273. mysql --password="$password" --user=root mysql -e "CREATE DATABASE sogo CHARACTER SET utf8 ; CREATE USER 'sogo'@'localhost' IDENTIFIED BY '$genpassword' ; GRANT ALL PRIVILEGES ON sogo.* TO 'sogo'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES;" >> INSTALL-LOG 2>&1
  2274.  
  2275. installstr+=" - config"
  2276. dialog --title " Please Wait... " --backtitle "$installback" \
  2277.  --infobox "$installstr" 15 50 2>.tmp
  2278.  
  2279. samba-tool user add sogo '$password' >> INSTALL-LOG 2>&1
  2280.  
  2281. #make a good sogo.conf
  2282.  
  2283. echo "
  2284. {
  2285. SOGoUserSources = (
  2286. {
  2287. CNFieldName = cn;
  2288. IDFieldName = cn;
  2289. UIDFieldName = sAMAccountName;
  2290. baseDN = \"cn=Users,dc=${DOM[0]},dc=${DOM[1]}\";
  2291. bindDN = \"cn=administrator,cn=Users,dc=${DOM[0]},dc=${DOM[1]}\";
  2292. bindFields = (sAMAccountName);
  2293. bindPassword = \"$password\";
  2294. canAuthenticate = YES;
  2295. displayName = \"Shared Addresses\";
  2296. hostname = \"ldap://127.0.0.1:389/\";
  2297. id = public;
  2298. isAddressBook = YES;
  2299. type = ldap;
  2300. }
  2301. );
  2302. SOGoAppointmentSendEMailNotifications = YES;
  2303. //SOGoSuperUsernames = (administrator);
  2304.  
  2305. SOGoProfileURL = mysql://sogo:$genpassword@127.0.0.1:3306/sogo/sogo_user_profile;
  2306. OCSFolderInfoURL = mysql://sogo:$genpassword@127.0.0.1:3306/sogo/sogo_folder_info;
  2307. OCSEMailAlarmsFolderURL = mysql://sogo:$genpassword@127.0.0.1:3306/sogo/sogo_alarms_folder;
  2308. OCSSessionsFolderURL = mysql://sogo:$genpassword@127.0.0.1:3306/sogo/sogo_sessions_info;
  2309.  
  2310. SOGoSieveScriptsEnabled = YES;
  2311. SOGoForwardEnabled = YES;
  2312. SOGoVacationEnabled = YES;
  2313. SOGoEnableEMailAlarms = YES;
  2314. SOGoTimeZone = $timezone;
  2315. SOGoIMAPServer = 127.0.0.1:1143;
  2316. SOGoSieveServer = sieve://127.0.0.1:4190;
  2317. SOGoMailingMechanism = smtp;
  2318. SOGoSMTPServer = 127.0.0.1;
  2319. SOGoCalendarDefaultRoles = (\"PublicDAndTViewer\");
  2320.  
  2321. /* Debugging */
  2322. //LDAPDebugEnabled = YES;
  2323. //MySQL4DebugEnabled = YES;
  2324. //OCSFolderManagerSQLDebugEnabled = YES;
  2325. //PGDebugEnabled = YES;
  2326. //SOGoDebugRequests = YES;
  2327. //WODebugTakeValues = YES;
  2328. SOGoUIxDebugEnabled = YES;
  2329. //SaxDebugReaderFactory = YES;
  2330. //SaxObjectDecoderDebugEnabled = YES;
  2331. //SoDebugObjectTraversal = YES;
  2332. //SoSecurityManagerDebugEnabled = YES;
  2333. //VSSaxDriverDebugEnabled = YES;
  2334. //WODebugResourceLookup = YES;
  2335. //WEResourceManagerDebugEnabled = YES;
  2336. //WEResourceManagerComponentDebugEnabled = YES;
  2337. }
  2338.  
  2339. " > /etc/sogo/sogo.conf
  2340.  
  2341.  
  2342. # the Ubuntu startup scripts specifies the number of threads. The commndline overrides
  2343. # the config, so we need to change that
  2344. rpl -e "PREFORK=3" "PREFORK=10" /etc/init.d/sogo >> INSTALL-LOG 2>&1
  2345.  
  2346.  
  2347. # get cronjobs installed
  2348. echo "
  2349. * * * * * sogo /usr/sbin/sogo-ealarms-notify
  2350. 0 0 * * * sogo /usr/sbin/sogo-tool expire-autoreply -p /etc/sogo/sieve.creds
  2351. " >> /etc/crontab
  2352.  
  2353.  
  2354. echo "administrator:$password
  2355. " > /etc/sogo/sieve.creds
  2356.  
  2357. service samba-ad-dc start >> INSTALL-LOG 2>&1
  2358. service sogo restart >> INSTALL-LOG 2>&1
  2359.  
  2360. installstr+=" - done\n"
  2361. dialog --title " Please Wait... " --backtitle "$installback" \
  2362.  --infobox "$installstr" 15 50 2>.tmp
  2363.  
  2364.  
  2365. }
  2366.  
  2367. #######################################################################
  2368. #
  2369. # @param
  2370. #
  2371. # @return 0 for failure
  2372. # 1 for success
  2373. #
  2374. # @brief
  2375. # We use samba 4 for user auth, so get it installed and running with the proper domain
  2376. #
  2377. #######################################################################
  2378. install_apache () {
  2379. echo "###################################################################################" >> INSTALL-LOG 2>&1
  2380. echo " INSTALL Apache" >> INSTALL-LOG 2>&1
  2381. echo "###################################################################################" >> INSTALL-LOG 2>&1
  2382. echo
  2383. installstr+="Apache : install"
  2384. dialog --title " Please Wait... " --backtitle "$installback" --infobox "$installstr" 15 50 2>.tmp
  2385.  
  2386. #apt-get -y install apache2 apache2-mpm-prefork apache2-utils libapache2-mod-wsgi apachetop >> INSTALL-LOG 2>&1
  2387. apt-get -y install apache2 apache2-utils libapache2-mod-wsgi apachetop >> INSTALL-LOG 2>&1
  2388. response=$?
  2389. case $response in
  2390.  100)
  2391.  whiptail --title " ERROR " --backtitle "$installback" \
  2392.  --infobox "Failed to install SOGo MySQL Connector. See INSTALL-LOG" 10 50
  2393.  
  2394. exit
  2395.  ;;
  2396.  
  2397. esac
  2398.  
  2399. installstr+=" - config"
  2400. dialog --title " Please Wait... " --backtitle "$installback" \
  2401.  --infobox "$installstr" 15 50 2>.tmp
  2402.  
  2403. a2dismod mpm_event >> INSTALL-LOG 2>&1
  2404.  
  2405. a2enmod mpm_prefork >> INSTALL-LOG 2>&1
  2406. a2enmod proxy >> INSTALL-LOG 2>&1
  2407. a2enmod proxy_http >> INSTALL-LOG 2>&1
  2408. a2enmod wsgi >> INSTALL-LOG 2>&1
  2409. a2enmod headers >> INSTALL-LOG 2>&1
  2410. a2enmod rewrite >> INSTALL-LOG 2>&1
  2411. a2enmod ssl >> INSTALL-LOG 2>&1
  2412.  
  2413. a2dismod reqtimeout >> INSTALL-LOG 2>&1
  2414.  
  2415. a2ensite default-ssl >> INSTALL-LOG 2>&1
  2416.  
  2417. # temp for bad placment by the .debs
  2418. mv /etc/apache2/conf.d/SOGo.conf /etc/apache2/conf-available >> INSTALL-LOG 2>&1
  2419.  
  2420.  
  2421. rpl -e "443" "80" /etc/apache2/conf-available/SOGo.conf >> INSTALL-LOG 2>&1
  2422. rpl -e "yourhostname" "$hostname.$domainname" /etc/apache2/conf-available/SOGo.conf >> INSTALL-LOG 2>&1
  2423. rpl -e "http://yourhostname" "http://$hostname.$domainname" /etc/apache2/conf-available/SOGo.conf >> INSTALL-LOG 2>&1
  2424.  
  2425.  
  2426. # turn on activesync
  2427. rpl -e "#ProxyPass /Micro" "ProxyPass /Micro" /etc/apache2/conf-available/SOGo.conf >> INSTALL-LOG 2>&1
  2428. rpl -e "# http://127.0.0.1:20000" " http://127.0.0.1:20000" /etc/apache2/conf-available/SOGo.conf >> INSTALL-LOG 2>&1
  2429. rpl -e "# retry=60" " retry=60" /etc/apache2/conf-available/SOGo.conf >> INSTALL-LOG 2>&1
  2430.  
  2431. # add remote hosts
  2432. rpl -e " RequestHeader unset" "# RequestHeader unset" /etc/apache2/conf-available/SOGo.conf >> INSTALL-LOG 2>&1
  2433. rpl -e " AddDefaultCharset" " RequestHeader set "x-webobjects-remote-host" %{REMOTE_HOST}e env=REMOTE_HOST\n AddDefaultCharset" /etc/apache2/conf-available/SOGo.conf >> INSTALL-LOG 2>&1
  2434.  
  2435. a2enconf SOGo >> INSTALL-LOG 2>&1
  2436.  
  2437. echo -e "
  2438. ## We use mod_rewrite to pass remote address to the SOGo proxy.
  2439. # The remote address will appear in SOGo's log files and in the X-Forward
  2440. # header of emails.
  2441. RewriteEngine On
  2442. RewriteRule ^/SOGo/(.*)$ /SOGo/$1 [env=REMOTE_HOST:%{REMOTE_ADDR},PT]
  2443. " >> /etc/apache2/conf-available/SOGo.conf
  2444.  
  2445.  
  2446. service apache2 restart >> INSTALL-LOG 2>&1
  2447. service sogo restart >> INSTALL-LOG 2>&1
  2448.  
  2449. installstr+=" - done\n"
  2450. dialog --title " Please Wait... " --backtitle "$installback" \
  2451.  --infobox "$installstr" 15 50 2>.tmp
  2452.  
  2453. }
  2454.  
  2455. #######################################################################
  2456. #
  2457. # @param
  2458. #
  2459. # @return 0 for failure
  2460. # 1 for success
  2461. #
  2462. # @brief
  2463. # saslauthd and related tools
  2464. #
  2465. #######################################################################
  2466. install_saslauthd () {
  2467. echo "###################################################################################" >> INSTALL-LOG 2>&1
  2468. echo " INSTALL SASLAuthD" >> INSTALL-LOG 2>&1
  2469. echo "###################################################################################" >> INSTALL-LOG 2>&1
  2470. echo
  2471. installstr+="saslauthd : install"
  2472. dialog --title " Please Wait... " --backtitle "$installback" --infobox "$installstr" 15 50 2>.tmp
  2473.  
  2474. apt-get -y install sasl2-bin >> INSTALL-LOG 2>&1
  2475. response=$?
  2476. case $response in
  2477.  100)
  2478.  whiptail --title " ERROR " --backtitle "$installback" \
  2479.  --infobox "Failed to install saslauthd. See INSTALL-LOG" 10 50
  2480.  
  2481. exit
  2482.  ;;
  2483.  
  2484. esac
  2485.  
  2486. installstr+=" - config"
  2487. dialog --title " Please Wait... " --backtitle "$installback" \
  2488.  --infobox "$installstr" 15 50 2>.tmp
  2489.  
  2490. echo "
  2491. START=yes
  2492. DESC=\"SASL Authentication Daemon\"
  2493. NAME=\"saslauthd\"
  2494. MECHANISMS=\"ldap\"
  2495. MECH_OPTIONS=\"\"
  2496. THREADS=5
  2497. OPTIONS=\"-c -m /var/run/saslauthd\"
  2498. " > /etc/default/saslauthd
  2499.  
  2500. echo "
  2501. ldap_servers: ldap://127.0.0.1:389/
  2502. ldap_version: 3
  2503. ldap_auth_method: bind
  2504. ldap_bind_dn: cn=administrator,cn=Users,dc=${DOM[0]},dc=${DOM[1]}
  2505. ldap_bind_pw: $password
  2506. ldap_search_base: cn=Users,dc=${DOM[0]},dc=${DOM[1]}
  2507. ldap_filter: cn=%U
  2508. ldap_scope: sub
  2509. " > /etc/saslauthd.conf
  2510.  
  2511. service saslauthd start
  2512.  
  2513. installstr+=" - done\n"
  2514. dialog --title " Please Wait... " --backtitle "$installback" \
  2515.  --infobox "$installstr" 15 50 2>.tmp
  2516.  
  2517.  
  2518. }
  2519.  
  2520. #######################################################################
  2521. #
  2522. # @param
  2523. #
  2524. # @return 0 for failure
  2525. # 1 for success
  2526. #
  2527. # @brief
  2528. # We use samba 4 for user auth, so get it installed and running with the proper domain
  2529. #
  2530. #######################################################################
  2531. install_openchange () {
  2532. echo "###################################################################################" >> INSTALL-LOG 2>&1
  2533. echo " INSTALL Openchange" >> INSTALL-LOG 2>&1
  2534. echo "###################################################################################" >> INSTALL-LOG 2>&1
  2535. echo
  2536. installstr+="OpenChange: install"
  2537. dialog --title " Please Wait... " --backtitle "$installback" --infobox "$installstr" 15 50 2>.tmp
  2538.  
  2539. apt-get -y install openchangeserver sogo-openchange openchangeproxy python-ocsmanager python-mysqldb openchange-ocsmanager openchange-rpcproxy python-sievelib python-spyne python-rpclib >> INSTALL-LOG 2>&1
  2540. response=$?
  2541. case $response in
  2542.  100)
  2543.  whiptail --title " ERROR " --backtitle "$installback" \
  2544.  --infobox "Failed to install OpenChange. See INSTALL-LOG" 10 50
  2545.  
  2546. exit
  2547.  ;;
  2548.  
  2549. esac
  2550.  
  2551. installstr+=" - config"
  2552. dialog --title " Please Wait... " --backtitle "$installback" \
  2553.  --infobox "$installstr" 15 50 2>.tmp
  2554.  
  2555. #create the ocsmanager file
  2556. echo "
  2557. [DEFAULT]
  2558. debug = true
  2559. email_to = administrator@$domainname
  2560. smtp_server = localhost
  2561. error_email_from = administrator@$domainname
  2562.  
  2563. [main]
  2564. auth = ldap
  2565. mapistore_root = /var/lib/samba/private
  2566. mapistore_data = /var/lib/samba/private/mapistore
  2567. debug = yes
  2568.  
  2569. [auth:file]
  2570.  
  2571. [auth:ldap]
  2572. host = ldap://127.0.0.1
  2573. port = 389
  2574. bind_dn = cn=administrator,cn=Users,dc=${DOM[0]},dc=${DOM[1]}
  2575. bind_pw = $password
  2576. basedn = cn=Users,dc=${DOM[0]},dc=${DOM[1]}
  2577.  
  2578. [auth:single]
  2579. username = openchange
  2580. # password is test
  2581. password = {SSHA}I6Hy5Wv0wuxyXvMBFWFQDVVN12_CLaX9
  2582.  
  2583. [server:main]
  2584. use = egg:Paste#http
  2585. host = 127.0.0.1
  2586. port = 5000
  2587. protocol_version = HTTP/1.1
  2588.  
  2589. [app:main]
  2590. use = egg:ocsmanager
  2591. full_stack = true
  2592. static_files = true
  2593. cache_dir = %(here)s/data
  2594. beaker.session.key = ocsmanager
  2595. beaker.session.secret = SDyKK3dKyDgW0mlpqttTMGU1f
  2596. app_instance_uuid = {ee533ebc-f266-49d1-ae10-d017ee6aa98c}
  2597. NTLMAUTHHANDLER_WORKDIR = /var/cache/ntlmauthhandler
  2598. SAMBA_HOST = 127.0.0.1
  2599.  
  2600. [rpcproxy:ldap]
  2601. host = localhost
  2602. port = 389
  2603. basedn = CN=Users,DC=${DOM[0]},DC=${DOM[1]}
  2604. set debug = true
  2605.  
  2606. [autodiscover]
  2607.  
  2608. [autodiscover:rpcproxy]
  2609. enabled = true
  2610.  
  2611. [outofoffice]
  2612.  
  2613. [outofoffice:file]
  2614. sieve_script_path = /var/vmail/\$domain/\$user/sieve-script
  2615. sieve_script_path_mkdir = false
  2616.  
  2617. [outofoffice:managesieve]
  2618. secret = secret
  2619.  
  2620. # Logging configuration
  2621. [loggers]
  2622. keys = root
  2623.  
  2624. [handlers]
  2625. keys = console
  2626.  
  2627. [formatters]
  2628. keys = generic
  2629.  
  2630. [logger_root]
  2631. level = INFO
  2632. handlers = console
  2633.  
  2634. [handler_console]
  2635. class = StreamHandler
  2636. args = (sys.stderr,)
  2637. level = NOTSET
  2638. formatter = generic
  2639.  
  2640. [formatter_generic]
  2641. format = %(asctime)s %(levelname)-5.5s [%(name)s] [%(threadName)s] %(message)s
  2642. " > /etc/ocsmanager/ocsmanager.ini
  2643.  
  2644.  
  2645. # replace the smb.conf file with the one we need
  2646. echo "
  2647. # Global parameters
  2648. [global]
  2649. server role = active directory domain controller
  2650. workgroup = $upperworkgroup
  2651. realm = $domainname
  2652. netbios name = $hostname
  2653. passdb backend = samba4
  2654. dns forwarder = $nameserver2
  2655.  
  2656. ### Configuration required by OpenChange server ###
  2657. dsdb:schema update allowed = true
  2658. dcerpc endpoint servers = +epmapper, +mapiproxy, +dnsserver
  2659. dcerpc_mapiproxy:server = true
  2660. dcerpc_mapiproxy:interfaces = exchange_emsmdb, exchange_nsp, exchange_ds_rfr
  2661.  
  2662. mapistore:namedproperties = mysql
  2663. namedproperties:mysql_user = openchange-user
  2664. namedproperties:mysql_pass = $genpassword
  2665. namedproperties:mysql_host = localhost
  2666. namedproperties:mysql_db = openchange
  2667.  
  2668. mapistore:indexing_backend = mysql://openchange-user:$genpassword@localhost/openchange
  2669. mapiproxy:openchangedb = mysql://openchange-user:$genpassword@localhost/openchange
  2670. ### Configuration required by OpenChange server ###
  2671.  
  2672. [netlogon]
  2673. path = /var/lib/samba/sysvol/$domainname/scripts
  2674. read only = No
  2675.  
  2676. [sysvol]
  2677. path = /var/lib/samba/sysvol
  2678. read only = No
  2679. " > /etc/samba/smb.conf
  2680.  
  2681. #configure mysql for Openchnage
  2682. echo "running: mysql --password="$password" --user=root mysql -e \"CREATE USER 'openchange-user'@'localhost' IDENTIFIED BY '$genpassword';GRANT ALL PRIVILEGES ON openchange.* TO 'openchange-user'@'localhost' WITH GRANT OPTION;FLUSH PRIVILEGES;\"" >> INSTALL-LOG 2>&1
  2683.  
  2684. mysql --password="$password" --user=root mysql -e "CREATE USER 'openchange-user'@'localhost' IDENTIFIED BY '$genpassword';GRANT ALL PRIVILEGES ON openchange.* TO 'openchange-user'@'localhost' WITH GRANT OPTION;FLUSH PRIVILEGES;" >> INSTALL-LOG 2>&1
  2685.  
  2686.  
  2687. service samba-ad-dc start >> INSTALL-LOG 2>&1
  2688.  
  2689. openchange_provision --standalone >> INSTALL-LOG 2>&1
  2690. openchange_provision --openchangedb --openchangedb-uri mysql://openchange-user:$genpassword@localhost/openchange >> INSTALL-LOG 2>&1
  2691.  
  2692. # tell samba to use mysql backend
  2693. #rpl -e "[global]" "[global]\n\tmapistore:namedproperties = mysql\n\tnamedproperties:mysql_user = openchange-user\n\tnamedproperties:mysql_pass = $genpassword\n\tnamedproperties:mysql_host = localhost\n\tnamedproperties:mysql_db = openchange\n\n\tmapistore:indexing_backend = mysql://openchange-user:$genpassword@localhost/openchange\n\tmapiproxy:openchangedb = mysql://openchange-user:$genpassword@localhost/openchange\n" /etc/samba/smb.conf >> INSTALL-LOG 2>&1
  2694.  
  2695. # create new openchange users
  2696. openchange_newuser --create Administrator >> INSTALL-LOG 2>&1
  2697.  
  2698. # restart samba
  2699. service samba-ad-dc restart >> INSTALL-LOG 2>&1
  2700. service openchange-ocsmanager restart >> INSTALL-LOG 2>&1
  2701.  
  2702. # set the proper name resolution (temp, reboot will reset this properly)
  2703. # we'll get rid of 8.8.8.8 after samba is up
  2704. echo "nameserver $ipaddress" > /etc/resolv.conf
  2705. echo "nameserver 8.8.8.8" >> /etc/resolv.conf
  2706. echo "search $domainname" >> /etc/resolv.conf
  2707. echo "domain $domainname" >> /etc/resolv.conf
  2708.  
  2709. # temp for bad placment by the .debs
  2710. mv /etc/apache2/conf.d/ocsmanager.conf /etc/apache2/conf-available >> INSTALL-LOG 2>&1
  2711. mv /etc/apache2/conf.d/rpcproxy.conf /etc/apache2/conf-available >> INSTALL-LOG 2>&1
  2712.  
  2713. a2enconf ocsmanager >> INSTALL-LOG 2>&1
  2714. a2enconf rpcproxy >> INSTALL-LOG 2>&1
  2715.  
  2716. rpl -e "</Directory>" " Require all granted\n</Directory>" /etc/apache2/conf-available/rpcproxy.conf >> INSTALL-LOG 2>&1
  2717.  
  2718. update-rc.d openchange-ocsmanager defaults >> INSTALL-LOG 2>&1
  2719.  
  2720. service apache2 restart >> INSTALL-LOG 2>&1
  2721.  
  2722. service samba-ad-dc start >> INSTALL-LOG 2>&1
  2723. service openchange-ocsmanager restart >> INSTALL-LOG 2>&1
  2724. service sogo restart >> INSTALL-LOG 2>&1
  2725.  
  2726. installstr+=" - done\n"
  2727. dialog --title " Please Wait... " --backtitle "$installback" \
  2728.  --infobox "$installstr" 15 50 2>.tmp
  2729.  
  2730. }
  2731.  
  2732. # Get the Network destination from the IP & Subnet mask
  2733. get_network_address() {
  2734.  SaveIFS=$IFS
  2735.  IFS=.
  2736.  typeset -a IParr=($1)
  2737.  typeset -a NMarr=($2)
  2738.  IFS=$SaveIFS
  2739.  
  2740. echo $((${IParr[0]} & ${NMarr[0]})).$((${IParr[1]} & ${NMarr[1]})).$((${IParr[2]} & ${NMarr[2]})).$((${IParr[3]} & ${NMarr[3]}))
  2741. }
  2742.  
  2743. # Function calculates number of bit in a netmask
  2744. #
  2745. mask2cidr() {
  2746.  nbits=0
  2747.  IFS=.
  2748.  for dec in $1 ; do
  2749.  case $dec in
  2750.  255) let nbits+=8;;
  2751.  254) let nbits+=7;;
  2752.  252) let nbits+=6;;
  2753.  248) let nbits+=5;;
  2754.  240) let nbits+=4;;
  2755.  224) let nbits+=3;;
  2756.  192) let nbits+=2;;
  2757.  128) let nbits+=1;;
  2758.  0);;
  2759.  *) echo "Error: $dec is not recognised"; exit 1
  2760.  esac
  2761.  done
  2762.  echo "$nbits"
  2763. }
  2764.  
  2765. #######################################################################
  2766. #
  2767. # @param
  2768. #
  2769. # @return 0 for failure
  2770. # 1 for success
  2771. #
  2772. # @brief
  2773. #
  2774. #
  2775. #######################################################################
  2776. template () {
  2777. echo "hello"
  2778.  
  2779. }
  2780.  
  2781. echo Building an Active Directory Master and SOGo Server > INSTALL-LOG 2>&1
  2782. echo >> INSTALL-LOG 2>&1
  2783. echo Preparing install environment... >> INSTALL-LOG 2>&1
  2784.  
  2785. installstr=""
  2786. installback="Majentis Active Directory/SOGo/OpenChange Install v0.8.0"
  2787.  
  2788. whiptail --title " Please Wait... " --backtitle "$installback" \
  2789.  --infobox "Preparing install environment" 15 50 2>.tmp
  2790.  
  2791. # Get the SOGo repo online
  2792. cp /etc/apt/sources.list /etc/apt/sources.list-orig
  2793. echo "deb http://inverse.ca/ubuntu trusty trusty" >> /etc/apt/sources.list
  2794. apt-key adv --keyserver keys.gnupg.net --recv-key 0x810273C4 >> INSTALL-LOG 2>&1
  2795. apt-get update >> INSTALL-LOG 2>&1
  2796.  
  2797. # I just prefer dialog, though I use whiptail for errors, since it changes the background color (whiptail doesn't work over ssh?)
  2798. apt-get -y install dialog debconf-utils joe htop expect >> INSTALL-LOG 2>&1
  2799. response=$?
  2800. case $response in
  2801.  100)
  2802.  echo "Failed to prepare install environment. See INSTALL-LOG\n" >> INSTALL-LOG
  2803.  whiptail --title " ERROR " --backtitle "$installback" \
  2804.  --infobox "Failed to prepare install environment. See INSTALL-LOG" 10 50
  2805.  
  2806. exit
  2807.  ;;
  2808.  
  2809. esac
  2810.  
  2811. # getting server information
  2812.  
  2813. dialog --title " Static IP Address " --backtitle "$installback" --inputbox "Enter this server's static IP address" 15 50 2>.tmp
  2814. ipaddress=`cat .tmp`
  2815.  
  2816. dialog --title " Netmask " --backtitle "$installback" --inputbox "Enter this server's netmask" 15 50 2>.tmp
  2817. netmask=`cat .tmp`
  2818.  
  2819. dialog --title " Gateway IP Address " --backtitle "$installback" --inputbox "Enter this server's gateway IP address" 15 50 2>.tmp
  2820. gateway=`cat .tmp`
  2821.  
  2822. dialog --title " External Nameserver IP Address " --backtitle "$installback" --inputbox "Enter this server's external namserver\n (i.e. 8.8.8.8)" 15 50 2>.tmp
  2823. nameserver2=`cat .tmp`
  2824.  
  2825. dialog --title " Domain Name " --backtitle "$installback" --inputbox "Enter this server's domain name\n (i.e. fisheye.com)" 15 50 2>.tmp
  2826. domainname=`cat .tmp`
  2827.  
  2828. dialog --title " Workgroup Name " --backtitle "$installback" --inputbox "Enter this server's workgroup / domain name\n (i.e. fisheye)" 15 50 2>.tmp
  2829. workgroup=`cat .tmp`
  2830.  
  2831. dialog --title " System Hostname " --backtitle "$installback" --inputbox "Enter this server's hostname\n (i.e. pdc)" 15 50 2>.tmp
  2832. hostname=`cat .tmp`
  2833.  
  2834. dialog --title " Administrator password " --backtitle "$installback" --inputbox "The password must contain lowercase letters,\nuppercase letters, and numbers.\n\nIf it doesn't, the install will fail." 0 0 2>.tmp
  2835. password=`cat .tmp`
  2836.  
  2837. timezone=`cat /etc/timezone`
  2838.  
  2839. dialog --title " Confirmation " --backtitle "$installback" --yesno "Is the following information correct:\n\n
  2840. System Name: $hostname.$domainname\n
  2841. Domain: $workgroup\n
  2842. IP address: $ipaddress/$netmask\n
  2843. Gateway: $gateway\n
  2844. External DNS Server: $nameserver2\n
  2845. Administrator password: $password\n
  2846. Timezone: $timezone" 0 0 2>.tmp
  2847. response=$?
  2848. case $response in
  2849.  1)
  2850.  exit
  2851.  ;;
  2852.  255)
  2853.  exit
  2854.  ;;
  2855. esac
  2856.  
  2857. echo -e "System Name: $hostname.$domainname\n
  2858. Domain: $workgroup\n
  2859. IP address: $ipaddress/$netmask\n
  2860. Gateway: $gateway\n
  2861. External DNS Server: $nameserver2\n
  2862. Administrator password: $password\n
  2863. Timezone: $timezone" >> INSTALL-LOG
  2864.  
  2865. # uppercase some info
  2866. upperdomain=${domainname^^}
  2867. upperhost=${hostname^^}
  2868. upperworkgroup=${workgroup^^}
  2869.  
  2870. # split domain up
  2871. OLDIFS="$IFS"
  2872. IFS='.'; DOM=($domainname)
  2873. IFS="$OLDIFS"
  2874.  
  2875. # generate the password used for DB access
  2876. genpassword=$(date +%s | sha256sum | base64 | head -c 16)
  2877.  
  2878. # get network info
  2879. basenet=$(get_network_address $ipaddress $netmask)
  2880. cidr=$(mask2cidr $netmask)
  2881.  
  2882. configure_network
  2883. modify_fstab
  2884. install_saslauthd
  2885. install_samba
  2886. install_dovecot
  2887. install_postfix
  2888. install_mysql
  2889. install_sogo
  2890. install_apache
  2891. install_openchange
  2892.  
  2893. install_imapproxy
Add Comment
Please, Sign In to add comment