forked from egystory/Librekernel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp-installation-script.sh
executable file
·2774 lines (2348 loc) · 94.2 KB
/
app-installation-script.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# ---------------------------------------------
# Variables list
# ---------------------------------------------
PROCESSOR="Not Detected" # Processor type (ARM/Intel/AMD)
HARDWARE="Not Detected" # Hardware type (Board/Physical/Virtual)
PLATFORM="Not Detected" # Platform type (U12/U14/D7/D8/T7)
EXT_INTERFACE="Not Detected" # External Interface (Connected to Internet)
INT_INTERFACE="Not Detected" # Internal Interface (Connected to local network)
# ----------------------------------------------
# Env Variables
# ----------------------------------------------
export GIT_SSL_NO_VERIFY=true
export INSTALL_HOME=`pwd`
export DEBIAN_FRONTEND=noninteractive
#----------------------------------------------
# This function detects platform.
#
# Suitable platform are:
#
# * Ubuntu 12.04
# * Ubuntu 14.04
# * Debian GNU/Linux 7
# * Debian GNU/Linux 8
# * Trisquel 7
# ----------------------------------------------
get_platform ()
{
echo "Detecting platform ..." | tee /var/libre_install.log
FILE=/etc/issue
if cat $FILE | grep "Ubuntu 12.04" >> /var/libre_install.log; then
PLATFORM="U12"
elif cat $FILE | grep "Ubuntu 14.04" >> /var/libre_install.log; then
PLATFORM="U14"
elif cat $FILE | grep "Debian GNU/Linux 7" >> /var/libre_install.log; then
PLATFORM="D7"
elif cat $FILE | grep "Debian GNU/Linux 8" >> /var/libre_install.log; then
PLATFORM="D8"
elif cat $FILE | grep "Trisquel GNU/Linux 7.0" >> /var/libre_install.log; then
PLATFORM="T7"
else
echo "ERROR: UNKNOWN PLATFORM" | tee -a /var/libre_install.log
exit
fi
echo "Platform: $PLATFORM" | tee -a /var/libre_install.log
}
# ----------------------------------------------
# check_internet
# ----------------------------------------------
check_internet ()
{
# Removing firewall
iptables -F
iptables -t nat -F
iptables -t mangle -F
echo "Checking Internet access ..." | tee -a /var/libre_install.log
if ! ping -c1 8.8.8.8 >> /var/libre_install.log; then
echo "You need internet to proceed. Exiting" | tee -a /var/libre_install.log
exit 1
fi
echo "Checking DNS resolution ..." | tee -a /var/libre_install.log
if ! getent hosts github.com >> /var/libre_install.log; then
echo "You need DNS resolution to proceed... Exiting" | tee -a /var/libre_install.log
exit 1
fi
echo "Showing the interface configuration ..." | tee -a /var/libre_install.log
CLINKUP=$(ip link |grep UP |grep eth | cut -d: -f2 |sed -n 1p)
CWANIP=$(wget -qO- ipinfo.io/ip)
CLANIP=$(ifconfig $CLINKUP | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
CNETMASK=$(ifconfig $CLINKUP | grep 'Mask:' | cut -d: -f4 | awk '{ print $1}')
CGWIP=$(route -n | grep 'UG[ \t]' | awk '{print $2}')
CDNS=$(cat /etc/resolv.conf | cut -d: -f2 | awk '{ print $2}')
echo 'Wired interface:' $CLINKUP
echo 'Public IP:' $CWANIP
echo 'LAN IP:' $CLANIP
echo 'Netmask:' $CNETMASK
echo 'Gateway:' $CGWIP
echo 'DNS Servers:' $CDNS
}
# ----------------------------------------------
# check_root
# ----------------------------------------------
check_root ()
{
echo "Checking user root ..." | tee -a /var/libre_install.log
if [ "$(whoami)" != "root" ]; then
echo "You need to be root to proceed. Exiting" | tee -a /var/libre_install.log
exit 2
fi
}
# ----------------------------------------------
# configure_repositories
# ----------------------------------------------
configure_repositories ()
{
# Configuring main repositories before any installation
cat << EOF > /etc/apt/sources.list
deb http://ftp.debian.org/debian jessie main
deb http://ftp.debian.org/debian jessie-updates main
deb http://security.debian.org jessie/updates main
deb http://ftp.debian.org/debian jessie-backports main
deb-src http://ftp.debian.org/debian jessie main
deb-src http://ftp.debian.org/debian jessie-updates main
deb-src http://security.debian.org jessie/updates main
deb-src http://ftp.debian.org/debian jessie-backports main
EOF
echo "Time sync ..." | tee -a /var/libre_install.log
# Installing ntpdate package
apt-get update >> /var/libre_install.log
apt-get -y --force-yes install ntp ntpdate >> /var/libre_install.log
# Time synchronization
/etc/init.d/ntp stop >> /var/libre_install.log 2>> /var/libre_install.log
if ntpdate -u ntp.ubuntu.com; then
echo "Date and time have been set" | tee -a /var/libre_install.log
elif ntpdate -u 0.ubuntu.pool.ntp.org; then
echo "Date and time have been set" | tee -a /var/libre_install.log
elif ntpdate -u 1.ubuntu.pool.ntp.org; then
echo "Date and time have been set" | tee -a /var/libre_install.log
elif ntpdate -u 2.ubuntu.pool.ntp.org; then
echo "Date and time have been set" | tee -a /var/libre_install.log
elif ntpdate -u 3.ubuntu.pool.ntp.org; then
echo "Date and time have been set" | tee -a /var/libre_install.log
elif [ $? -ne 0 ]; then
echo "Error: unable to set time" | tee -a /var/libre_install.log
exit 3
fi
/etc/init.d/ntp restart >> /var/libre_install.log 2>> /var/libre_install.log
date | tee -a /var/libre_install.log
# Configuring hostname and domain name
echo "librerouter" > /etc/hostname
echo "127.0.0.1 localhost.librenet librerouter localhost" > /etc/hosts
sysctl kernel.hostname=librerouter
echo "Configuring repositories ... " | tee -a /var/libre_install.log
# echo "adding unauthenticated upgrade"
apt-get -y --force-yes --allow-unauthenticated upgrade
echo "
Acquire::https::dl.dropboxusercontent.com::Verify-Peer \"false\";
Acquire::https::deb.nodesource.com::Verify-Peer \"false\";
" > /etc/apt/apt.conf.d/apt.conf
# Preparing repositories for Ubuntu 12.04 GNU/Linux
if [ $PLATFORM = "U12" ]; then
# Configuring repositories for Ubuntu 12.04
echo "Updating repositories in Ubuntu 12.04"
# echo "deb http://security.ubuntu.com/ubuntu precise-security main" >> /etc/apt/sources.list
echo "Installing apt-transport-https ..."
apt-get install -y --force-yes apt-transport-https 2>&1 > /var/apt-get-install-aptth.log
if [ $? -ne 0 ]; then
echo "Error: Unable to install apt-transport-https"
exit 3
fi
# Prepare owncloud repo
echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/Debian_7.0/ /' > /etc/apt/sources.list.d/owncloud.list
wget http://download.opensuse.org/repositories/isv:/ownCloud:/community/Debian_7.0/Release.key -O- | apt-key add -
# Prepare Sogo repo
apt-key adv --keyserver keys.gnupg.net --recv-key 0x810273C4
echo 'deb http://packages.inverse.ca/SOGo/nightly/3/ubuntu/ precise precise' > /etc/apt/sources.list.d/sogo.list
# Preparing yacy repo
echo 'deb http://debian.yacy.net ./' > /etc/apt/sources.list.d/yacy.list
apt-key advanced --keyserver pgp.net.nz --recv-keys 03D886E7
# preparing i2p repo
echo 'deb http://deb.i2p2.no/ precise main' >/etc/apt/sources.list.d/i2p.list
echo 'deb-src http://deb.i2p2.no/ precise main' >>/etc/apt/sources.list.d/i2p.list
# preparing tor repo
# preparing webmin repo
echo 'deb http://download.webmin.com/download/repository sarge contrib' > /etc/apt/sources.list.d/webmin.list
echo 'deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib' >> /etc/apt/sources.list.d/webmin.list
wget "http://www.webmin.com/jcameron-key.asc" -O- | apt-key add -
# Preparing repositories for Ubuntu 14.04 GNU/Linux
elif [ $PLATFORM = "U14" ]; then
# Configuring repositories for Ubuntu 14.04
echo "Updating repositories in Ubuntu 14.04"
# echo "deb http://security.ubuntu.com/ubuntu trusty-security main" >> /etc/apt/sources.list
#apt-get update 2>&1 > /var/apt-get-update-default.log
echo "Installing apt-transport-https ..."
apt-get install -y --force-yes apt-transport-https 2>&1 > /var/apt-get-install-aptth.log
if [ $? -ne 0 ]; then
echo "Error: Unable to install apt-transport-https"
exit 3
fi
# Prepare owncloud repo
echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/Debian_7.0/ /' > /etc/apt/sources.list.d/owncloud.list
wget http://download.opensuse.org/repositories/isv:/ownCloud:/community/Debian_7.0/Release.key -O- | apt-key add -
# Prepare Sogo repo
apt-key adv --keyserver keys.gnupg.net --recv-key 0x810273C4
echo 'deb http://packages.inverse.ca/SOGo/nightly/3/ubuntu/ trusty trusty' > /etc/apt/sources.list.d/sogo.list
# Preparing yacy repo
echo 'deb http://debian.yacy.net ./' > /etc/apt/sources.list.d/yacy.list
apt-key advanced --keyserver pgp.net.nz --recv-keys 03D886E7
# preparing i2p repo
#echo 'deb http://deb.i2p2.no/ trusty main' >/etc/apt/sources.list.d/i2p.list
#echo 'deb-src http://deb.i2p2.no/ trusty main' >>/etc/apt/sources.list.d/i2p.list
echo -ne '\n' | apt-add-repository ppa:i2p-maintainers/i2p
# preparing tor repo
# preparing webmin repo
echo 'deb http://download.webmin.com/download/repository sarge contrib' > /etc/apt/sources.list.d/webmin.list
echo 'deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib' >> /etc/apt/sources.list.d/webmin.list
wget "http://www.webmin.com/jcameron-key.asc" -O- | apt-key add -
# Preparing repositories for Debian 7 GNU/Linux
elif [ $PLATFORM = "D7" ]; then
# Configuring repositories for Debian 7
echo "deb http://ftp.us.debian.org/debian wheezy main non-free contrib" > /etc/apt/sources.list
echo "deb http://ftp.debian.org/debian/ wheezy-updates main contrib non-free" >> /etc/apt/sources.list
echo "deb http://security.debian.org/ wheezy/updates main contrib non-free" >> /etc/apt/sources.list
# There is a need to install apt-transport-https
# package before preparing third party repositories
echo "Updating repositories ..."
apt-get update 2>&1 > /var/apt-get-update-default.log
echo "Installing apt-transport-https ..."
apt-get install -y --force-yes apt-transport-https 2>&1 > /var/apt-get-install-aptth.log
if [ $? -ne 0 ]; then
echo "Error: Unable to install apt-transport-https"
exit 3
fi
# Prepare owncloud repo
echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/Debian_7.0/ /' > /etc/apt/sources.list.d/owncloud.list
wget http://download.opensuse.org/repositories/isv:/ownCloud:/community/Debian_7.0/Release.key -O- | apt-key add -
# Prepare Sogo repo
apt-key adv --keyserver keys.gnupg.net --recv-key 0x810273C4
echo 'deb http://packages.inverse.ca/SOGo/nightly/3/debian/ wheezy wheezy' > /etc/apt/sources.list.d/sogo.list
# Prepare prosody repo
# echo 'deb http://packages.prosody.im/debian wheezy main' > /etc/apt/sources.list.d/prosody.list
# wget https://prosody.im/files/prosody-debian-packages.key -O- | apt-key add -
# Prepare tahoe repo
echo 'deb https://dl.dropboxusercontent.com/u/18621288/debian wheezy main' > /etc/apt/sources.list.d/tahoei2p.list
apt-key advanced --keyserver pgp.net.nz --recv-keys 8CF6E896B3C01B09
# W: GPG error: https://dl.dropboxusercontent.com wheezy Release: The following signatures were invalid: KEYEXPIRED 1460252357
# Prepare yacy repo
echo 'deb http://debian.yacy.net ./' > /etc/apt/sources.list.d/yacy.list
apt-key advanced --keyserver pgp.net.nz --recv-keys 03D886E7
# Prepare i2p repo
echo 'deb http://deb.i2p2.no/ wheezy main' > /etc/apt/sources.list.d/i2p.list
wget --no-check-certificate https://geti2p.net/_static/i2p-debian-repo.key.asc -O- | apt-key add -
# Prepare tor repo
echo 'deb http://deb.torproject.org/torproject.org wheezy main' > /etc/apt/sources.list.d/tor.list
apt-key advanced --keyserver pgp.net.nz --recv-keys 74A941BA219EC810
# Prepare Webmin repo
echo 'deb http://download.webmin.com/download/repository sarge contrib' > /etc/apt/sources.list.d/webmin.list
if [ -e jcameron-key.asc ]; then
rm -r jcameron-key.asc
fi
wget http://www.webmin.com/jcameron-key.asc
apt-key add jcameron-key.asc
# Preparing repositories for Debian 8 GNU/Linux
elif [ $PLATFORM = "D8" ]; then
# Avoid macchanger asking for information
export DEBIAN_FRONTEND=noninteractive
# Configuring Repositories for Debian 8
#echo "deb http://ftp.es.debian.org/debian/ jessie main" > /etc/apt/sources.list
#echo "deb http://ftp.es.debian.org/debian/ jessie-updates main" >> /etc/apt/sources.list
#echo "deb http://security.debian.org/ jessie/updates main" >> /etc/apt/sources.list
cat << EOF > /etc/apt/sources.list
deb http://ftp.debian.org/debian jessie main
deb http://ftp.debian.org/debian jessie-updates main
deb http://security.debian.org jessie/updates main
deb http://ftp.debian.org/debian jessie-backports main
deb-src http://ftp.debian.org/debian jessie main
deb-src http://ftp.debian.org/debian jessie-updates main
deb-src http://security.debian.org jessie/updates main
deb-src http://ftp.debian.org/debian jessie-backports main
EOF
# There is a need to install apt-transport-https
# package before preparing third party repositories
echo "Updating repositories ..." | tee -a /var/libre_install.log
apt-get update 2>&1 > /var/apt-get-update-default.log
echo "Installing apt-transport-https ..." | tee -a /var/libre_install.log
apt-get install -y --force-yes apt-transport-https 2>&1 > /var/apt-get-install-aptth.log
if [ $? -ne 0 ]; then
echo "Error: Unable to install apt-transport-https" | tee -a /var/libre_install.log
exit 3
fi
# Prepare owncloud repo
echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/Debian_8.0/ /' > /etc/apt/sources.list.d/owncloud.list
wget http://download.opensuse.org/repositories/isv:/ownCloud:/community/Debian_8.0/Release.key -O- | apt-key add -
# Prepare Sogo repo
apt-key adv --keyserver keys.gnupg.net --recv-key 0x810273C4
echo 'deb http://packages.inverse.ca/SOGo/nightly/3/debian/ jessie jessie' > /etc/apt/sources.list.d/sogo.list
# Prepare prosody repo
# echo 'deb http://packages.prosody.im/debian wheezy main' > /etc/apt/sources.list.d/prosody.list
# wget https://prosody.im/files/prosody-debian-packages.key -O- | apt-key add -
# Prepare tahoe repo
echo 'deb https://dl.dropboxusercontent.com/u/18621288/debian wheezy main' > /etc/apt/sources.list.d/tahoei2p.list
# Prepare yacy repo
echo 'deb http://debian.yacy.net ./' > /etc/apt/sources.list.d/yacy.list
apt-key advanced --keyserver pgp.net.nz --recv-keys 03D886E7
# Prepare i2p repo
echo 'deb http://deb.i2p2.no/ stable main' > /etc/apt/sources.list.d/i2p.list
wget --no-check-certificate https://geti2p.net/_static/i2p-debian-repo.key.asc -O- | apt-key add -
# Prepare tor repo
echo 'deb http://deb.torproject.org/torproject.org jessie main' > /etc/apt/sources.list.d/tor.list
gpg --keyserver pgp.net.nz --recv 886DDD89
gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | apt-key add -
# Prepare Webmin repo
echo 'deb http://download.webmin.com/download/repository sarge contrib' > /etc/apt/sources.list.d/webmin.list
if [ -e jcameron-key.asc ]; then
rm -r jcameron-key.asc
fi
wget http://www.webmin.com/jcameron-key.asc
apt-key add jcameron-key.asc
# Prepare kibaba repo
wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | apt-key add -
echo "deb https://packages.elastic.co/kibana/4.6/debian stable main" > /etc/apt/sources.list.d/kibana.list
# Prepare lohstash repo
wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | apt-key add -
echo "deb https://packages.elastic.co/logstash/2.4/debian stable main" > /etc/apt/sources.list.d/elastic.list
# Prepare backports repo (suricata, roundcube)
# echo 'deb http://ftp.debian.org/debian jessie-backports main' > /etc/apt/sources.list.d/backports.list
# Prepare bro repo
# wget http://download.opensuse.org/repositories/network:bro/Debian_8.0/Release.key -O- | apt-key add -
# echo 'deb http://download.opensuse.org/repositories/network:/bro/Debian_8.0/ /' > /etc/apt/sources.list.d/bro.list
# Prepare elastic repo
# wget https://packages.elastic.co/GPG-KEY-elasticsearch -O- | apt-key add -
# echo "deb http://packages.elastic.co/kibana/4.5/debian stable main" > /etc/apt/sources.list.d/kibana.list
# echo "deb https://packages.elastic.co/logstash/2.3/debian stable main" > /etc/apt/sources.list.d/logstash.list
# echo "deb https://packages.elastic.co/elasticsearch/2.x/debian stable main" > /etc/apt/sources.list.d/elastic.list
# Prepare passenger repo
# apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
# echo "deb https://oss-binaries.phusionpassenger.com/apt/passenger jessie main" > /etc/apt/sources.list.d/passenger.list
# Preparing repositories for Trisquel GNU/Linux 7.0
elif [ $PLATFORM = "T7" ]; then
# Avoid macchanger asking for information
export DEBIAN_FRONTEND=noninteractive
# Configuring repositories for Trisquel 7
echo "deb http://fr.archive.trisquel.info/trisquel/ belenos main" > /etc/apt/sources.list
echo "deb-src http://fr.archive.trisquel.info/trisquel/ belenos main" >> /etc/apt/sources.list
echo "deb http://fr.archive.trisquel.info/trisquel/ belenos-security main" >> /etc/apt/sources.list
echo "deb-src http://fr.archive.trisquel.info/trisquel/ belenos-security main" >> /etc/apt/sources.list
echo "deb http://fr.archive.trisquel.info/trisquel/ belenos-updates main" >> /etc/apt/sources.list
echo "deb-src http://fr.archive.trisquel.info/trisquel/ belenos-updates main" >> /etc/apt/sources.list
# There is a need to install apt-transport-https
# package before preparing third party repositories
echo "Updating repositories ..."
apt-get update 2>&1 > /var/apt-get-update-default.log
if [ $? -ne 0 ]; then
echo "ERROR: UNABLE TO UPDATE REPOSITORIES"
exit 10
else
echo "Updating done successfully"
fi
echo "Installing apt-transport-https ..."
apt-get install -y --force-yes apt-transport-https 2>&1 > /var/apt-get-install-aptth.log
if [ $? -ne 0 ]; then
echo "ERROR: UNABLE TO INSTALL PACKAGES: apt-transport-https"
exit 11
else
echo "Installation done successfully"
fi
echo "Preparing third party repositories ..."
# Prepare yacy repo
echo 'deb http://debian.yacy.net ./' > /etc/apt/sources.list.d/yacy.list
apt-key advanced --keyserver pgp.net.nz --recv-keys 03D886E7
# Prepare i2p repo
echo 'deb http://deb.i2p2.no/ stable main' > /etc/apt/sources.list.d/i2p.list
wget --no-check-certificate https://geti2p.net/_static/i2p-debian-repo.key.asc -O- | apt-key add -
# Prepare tahoe repo
echo 'deb https://dl.dropboxusercontent.com/u/18621288/debian wheezy main' > /etc/apt/sources.list.d/tahoei2p.list
# Prepare tor repo
echo 'deb http://deb.torproject.org/torproject.org wheezy main' > /etc/apt/sources.list.d/tor.list
gpg --keyserver pgp.net.nz --recv 886DDD89
gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | apt-key add -
# Prepare Webmin repo
echo 'deb http://download.webmin.com/download/repository sarge contrib' > /etc/apt/sources.list.d/webmin.list
if [ -e jcameron-key.asc ]; then
rm -r jcameron-key.asc
fi
wget http://www.webmin.com/jcameron-key.asc
apt-key add jcameron-key.asc
else
echo "ERROR: UNKNOWN PLATFORM"
exit 4
fi
}
# ----------------------------------------------
# Function to configure WLAN AP
# ----------------------------------------------
install_apmode()
{
echo "Preparing wlan AP script ..."
mkdir -p /root/libre_scripts/
rm -rf /root/libre_scripts/apmode.sh
echo "Downloading apmode script ..."
wget --no-check-certificate https://raw.githubusercontent.com/Librerouter/Librekernel/gh-pages/apmode.sh
if [ $? -ne 0 ]; then
echo "Unable to download apmode script. Exiting ..."
exit 1
fi
# Moving script to permanent location
mv apmode.sh /root/libre_scripts/
chmod +x /root/libre_scripts/apmode.sh
}
# ----------------------------------------------
# install_packages
# ----------------------------------------------
install_packages()
{
echo "Updating repositories packages ... " | tee -a /var/libre_install.log
apt-get update 2>&1 > /var/apt-get-update.log
echo "Installing packages ... " | tee -a /var/libre_install.log
# Installing Packages for Debian 7 GNU/Linux
if [ $PLATFORM = "D7" ]; then
DEBIAN_FRONTEND=noninteractive
apt-get install -y --force-yes \
privoxy nginx php5-common \
php5-fpm php5-cli php5-json php5-mysql php5-curl php5-intl \
php5-mcrypt php5-memcache php-xml-parser php-pear unbound owncloud \
node npm apache2-mpm-prefork- apache2-utils- apache2.2-bin- \
apache2.2-common- openjdk-7-jre-headless phpmyadmin php5 \
mysql-server php5-gd php5-imap smarty3 git ntpdate macchanger \
bridge-utils hostapd isc-dhcp-server hostapd bridge-utils \
curl macchanger ntpdate tor bc sudo lsb-release dnsutils \
ca-certificates-java openssh-server ssh wireless-tools usbutils \
unzip debian-keyring subversion build-essential libncurses5-dev \
i2p i2p-keyring yacy virtualenv pwgen \
killyourtv-keyring i2p-tahoe-lafs squidguard \
c-icap clamav clamav-daemon gcc make libcurl4-gnutls-dev libicapapi-dev \
deb.torproject.org-keyring u-boot-tools console-tools \
gnupg openssl python-virtualenv python-pip python-lxml git \
libjpeg62-turbo libjpeg62-turbo-dev zlib1g-dev python-dev webmin \
postfix mailutils aptitude fail2ban libsodium-dev libsystemd-dev \
2>&1 > /var/apt-get-install.log
# Installing Packages for Debian 8 GNU/Linux
elif [ $PLATFORM = "D8" ]; then
DEBIAN_FRONTEND=noninteractive
# libs and tools
apt-get install -y --force-yes \
php5-common php5-fpm php5-cli php5-json php5-mysql \
php5-curl php5-intl php5-mcrypt php5-memcache \
php-xml-parser php-pear phpmyadmin php5 mailutils \
apache2- apache2-mpm-prefork- apache2-utils- apache2.2-bin- \
apache2.2-common- rpcbind- exim4- \
openjdk-7-jre-headless uwsgi \
php5-gd php5-imap smarty3 git ntpdate macchanger \
bridge-utils hostapd librrd-dev \
curl macchanger ntpdate bc sudo lsb-release dnsutils \
ca-certificates-java openssh-server ssh wireless-tools usbutils \
unzip debian-keyring subversion build-essential libncurses5-dev \
i2p-keyring virtualenv pwgen gcc g++ make automake \
killyourtv-keyring i2p-tahoe-lafs libcurl4-gnutls-dev \
libicapapi-dev libssl-dev perl screen aptitude \
deb.torproject.org-keyring u-boot-tools php-zeta-console-tools \
gnupg openssl python-virtualenv python-pip python-lxml git \
libjpeg62-turbo libjpeg62-turbo-dev zlib1g-dev python-dev \
libxml2-dev libxslt1-dev python-jinja2 python-pgpdump spambayes \
flex bison libpcap-dev libnet1-dev libpcre3-dev iptables-dev \
libnetfilter-queue-dev libdumbnet-dev autoconf rails \
roundcube-mysql roundcube-plugins ntop libndpi-bin \
argus-server argus-client libnids-dev flow-tools libfixbuf3 \
libgd-perl libgd-graph-perl rrdtool librrd-dev librrds-perl \
libsqlite3-dev libtool elasticsearch conky ruby bundler \
pmacct tomcat7 dpkg-dev devscripts javahelper openjdk-7-jdk ant \
librrds-perl libapache2-mod-php5- apache2-prefork-dev \
libmysqlclient-dev wkhtmltopdf libpcre3 mysql-server \
mysql-client-5.5 iw rfkill npm \
2>&1 > /var/apt-get-install_1.log
# services
apt-get install -y --force-yes \
privoxy unbound owncloud isc-dhcp-server \
yacy c-icap clamav clamav-daemon squidguard \
tor i2p roundcube tinyproxy prosody \
memcached sogo \
postfix-mysql dovecot-mysql dovecot-imapd postgrey \
amavis spamassassin php5-imap fail2ban libsodium-dev libsystemd-dev \
2>&1 > /var/apt-get-install_2.log
#bro passenger logstash kibana nginx nginx-extras libcurl4-openssl-dev \
# Installing Packages for Trisquel 7.0 GNU/Linux
elif [ $PLATFORM = "T7" ]; then
DEBIAN_FRONTEND=noninteractive
apt-get install -y --force-yes \
privoxy nginx php5-common \
php5-fpm php5-cli php5-json php5-mysql php5-curl php5-intl \
php5-mcrypt php5-memcache php-xml-parser php-pear unbound owncloud \
node npm apache2-mpm-prefork- apache2-utils- apache2.2-bin- \
apache2.2-common- openjdk-7-jre-headless phpmyadmin php5 \
mysql-server php5-gd php5-imap smarty3 git ntpdate macchanger \
bridge-utils hostapd isc-dhcp-server hostapd bridge-utils \
curl macchanger ntpdate tor bc sudo lsb-release dnsutils \
ca-certificates-java openssh-server ssh wireless-tools usbutils \
unzip debian-keyring subversion build-essential libncurses5-dev \
i2p i2p-keyring yacy virtualenv pwgen \
killyourtv-keyring i2p-tahoe-lafs squidguard \
c-icap clamav clamav-daemon gcc make libcurl4-gnutls-dev libicapapi-dev \
deb.torproject.org-keyring u-boot-tools console-setup \
gnupg openssl python-virtualenv python-pip python-lxml git \
libjpeg62-turbo libjpeg62-turbo-dev zlib1g-dev python-dev \
postfix mailutils aptitude fail2ban \
2>&1 > /var/apt-get-install.log
# Installing Packages for Ubuntu 14.04 GNU/Linux
elif [ $PLATFORM = "U14" -o $PLATFORM = "U12" ]; then
DEBIAN_FRONTEND=noninteractive
apt-get install -y --force-yes \
pwgen debconf-utils privoxy nginx php5-common \
php5-fpm php5-cli php5-json php5-mysql php5-curl php5-intl \
php5-mcrypt php5-memcache php-xml-parser php-pear unbound owncloud \
node npm apache2-mpm-prefork- apache2-utils- apache2.2-bin- \
apache2.2-common- openjdk-7-jre-headless phpmyadmin php5 \
mysql-server-5.6 php5-gd php5-imap smarty3 git ntpdate macchanger \
bridge-utils hostapd isc-dhcp-server hostapd bridge-utils \
curl macchanger ntpdate tor bc sudo lsb-release dnsutils \
ca-certificates-java openssh-server ssh wireless-tools usbutils \
unzip debian-keyring subversion build-essential libncurses5-dev \
i2p yacy tahoe-lafs \
c-icap clamav clamav-daemon gcc make libcurl4-gnutls-dev \
libicapapi-dev u-boot-tools console-tools* squidguard \
gnupg openssl python-virtualenv python-pip python-lxml git \
zlib1g-dev python-dev webmin fail2ban libsystemd-dev \
postfix mailutils aptitude \
2>&1 > /var/apt-get-install.log
fi
if [ $? -ne 0 ]; then
echo "Error: unable to install packages" | tee -a /var/libre_install.log
exit 3
fi
# Getting classified domains list from shallalist.de
if [ ! -e /opt/shallalist.tar.gz ]; then
echo "Getting classified domains list ..." | tee -a /var/libre_install.log
wget -P /opt/ http://www.shallalist.de/Downloads/shallalist.tar.gz
if [ $? -ne 0 ]; then
echo "Error: Unable to download domain list. Exithing" | tee -a /var/libre_install.log
exit 5
fi
fi
# Getting Friendica
echo "Getting Friendica ..." | tee -a /var/libre_install.log
if [ ! -e /var/www/friendica ]; then
cd /var/www
git clone https://github.com/friendica/friendica.git
if [ $? -ne 0 ]; then
echo "Error: unable to download friendica" | tee -a /var/libre_install.log
exit 3
fi
cd friendica
git clone https://github.com/friendica/friendica-addons.git addon
if [ $? -ne 0 ]; then
echo "Error: unable to download friendica addons" | tee -a /var/libre_install.log
exit 3
fi
chown -R www-data:www-data /var/www/friendica/view/smarty3
chmod g+w /var/www/friendica/view/smarty3
touch /var/www/friendica/.htconfig.php
chown www-data:www-data /var/www/friendica/.htconfig.php
chmod g+rwx /var/www/friendica/.htconfig.php
fi
# Getting DNSCrypt
if [ ! -e dnscrypt-proxy ]; then
echo "Getting & Installing DNSCrypt ..."
git clone https://github.com/jedisct1/dnscrypt-proxy.git dnscrypt-proxy
cd dnscrypt-proxy
./autogen.sh
./configure --with-systemd && make
make install
cd .. && rm -rf dnscrypt-proxy
if [ $? -ne 0 ]; then
echo "Error: Unable to download DNSCrypt. Exiting" | tee -a /var/libre_install.log
exit 5
fi
fi
}
# ----------------------------------------------
# This function checks hardware
# Hardware can be.
# 1. ARM for odroid board.
# 2. INTEL or AMD for Physical/Virtual machine.
# Function gets Processor and Hardware types and saves
# them in PROCESSOR and HARDWARE variables.
# ----------------------------------------------
get_hardware()
{
echo "Detecting hardware ..." | tee -a /var/libre_install.log
# Checking CPU for ARM and saving
# Processor and Hardware types in
# PROCESSOR and HARDWARE variables
if grep ARM /proc/cpuinfo >> /var/libre_install.log 2>>/var/libre_install.log; then
PROCESSOR="ARM"
HARDWARE=`cat /proc/cpuinfo | grep Hardware | awk {'print $3'}`
# Checking CPU for Intel and saving
# Processor and Hardware types in
# PROCESSOR and HARDWARE variables
elif grep Intel /proc/cpuinfo >> /var/libre_install.log 2>>/var/libre_install.log; then
PROCESSOR="Intel"
HARDWARE=`dmidecode -s system-product-name`
# Checking CPU for AMD and saving
# Processor and Hardware types in
# PROCESSOR and HARDWARE variables
elif grep AMD /proc/cpuinfo >> /var/libre_install.log 2>>/var/libre_install.log; then
PROCESSOR="AMD"
HARDWARE=`dmidecode -s system-product-name`
fi
# Detecting Architecture
ARCH=`uname -m`
# Printing Processor Hardware and Architecture types
echo "Processor: $PROCESSOR" | tee -a /var/libre_install.log
echo "Hardware: $HARDWARE" | tee -a /var/libre_install.log
echo "Architecture: $ARCH" | tee -a /var/libre_install.log
}
# ----------------------------------------------
# This script checks requirements for Physical
# Machines.
#
# Minimum requirements are:
#
# * 2 Network Interfaces.
# * 4 GB Physical Memory (RAM).
# * 16 GB Free Space On Hard Drive.
#
# ----------------------------------------------
check_requirements()
{
echo "Checking requirements ..." | tee -a /var/libre_install.log
# This variable contains network interfaces quantity.
# NET_INTERFACES=`ls /sys/class/net/ | grep -w 'eth0\|eth1\|wlan0\|wlan1' | wc -l`
# This variable contains total physical memory size.
echo -n "Physical memory size: " | tee -a /var/libre_install.log
MEMORY=`grep MemTotal /proc/meminfo | awk '{print $2}'`
echo "$MEMORY KB" | tee -a /var/libre_install.log
# This variable contains total free space on root partition.
echo -n "Root partition size: " | tee -a /var/libre_install.log
STORAGE=`df / | grep -w "/" | awk '{print $4}'`
echo "$STORAGE KB" | tee -a /var/libre_install.log
# Checking network interfaces quantity.
# if [ $NET_INTERFACES -le 1 ]; then
# echo "You need at least 2 network interfaces. Exiting"
# exit 4
# fi
# Checking physical memory size.
if [ $MEMORY -le 1900000 ]; then
echo "You need at least 2GB of RAM. Exiting" | tee -a /var/libre_install.log
exit 5
fi
# Checking free space.
MIN_STORAGE=12000000
STORAGE2=`echo $STORAGE | awk -F. {'print $1'}`
if [ $STORAGE2 -lt $MIN_STORAGE ]; then
echo "You need at least 16GB of free space. Exiting" | tee -a /var/libre_install.log
exit 6
fi
# Checking architecture.
if [ "$ARCH" != "x86_64" ]; then
echo "You need amd64 architecture to continue. Exiting" | tee -a /var/libre_install.log
exit 7
fi
}
# ----------------------------------------------
# This function enables DHCP client and checks
# for Internet on predefined network interface.
#
# Steps to define interface are:
#
# 1. Checking Internet access.
# *
# *
# ***** If success.
# *
# * 2. Get Interface name
# *
# ***** If no success.
# *
# * 2. Checking for DHCP server and Internet in
# * network connected to eth0.
# *
# ***** If success.
# * *
# * * 2. Enable DHCP client on eth0 and
# * default route to eth0
# *
# ***** If no success.
# *
# * 2. Checking for DHCP server and Internet
# * in network connected to eth1
# *
# ***** If success.
# * *
# * * 3. Enable DHCP client on eth1.
# *
# *
# ***** If no success.
# *
# * 3. Warn user and exit with error.
#
# ----------------------------------------------
get_interfaces()
{
# Check internet Connection. If Connection exist then get
# and save Internet side network interface name in
# EXT_INTERFACE variable
if ping -c1 8.8.8.8 >> /var/libre_install.log 2>>/var/libre_install.log; then
EXT_INTERFACE=`route -n | awk {'print $1 " " $8'} | grep "0.0.0.0" | awk {'print $2'} | sed -n '1p'`
echo "Internet connection established on interface $EXT_INTERFACE" | tee -a /var/libre_install.log
else
# Test all available ethernet interfaces for internet connection.
# Useful if there are more than two ethernet interfaces.
for i in `ifconfig -s | awk '{print $1}' | grep eth`
do
iface="$i"
echo "Getting Internet access on eth0"
echo "# interfaces(5) file used by ifup(8) and ifdown(8) " > /etc/network/interfaces
echo -e "auto lo\niface lo inet loopback\n" >> /etc/network/interfaces
echo -e "auto $iface\niface $iface inet dhcp" >> /etc/network/interfaces
/etc/init.d/networking restart
if ping -c1 8.8.8.8 >> /var/libre_install.log 2>>/var/libre_install.log; then
echo "Internet conection established on: $iface"
EXT_INTERFACE="$iface"
break
fi
done
if [ ! -z $EXT_INTERFACE ]; then
echo "Warning: Unable to get Internet access on available interfaces"
echo "Please plugin Internet cable and enable DHCP on gateway"
echo "Error: Unable to get Internet access. Exiting" | tee -a /var/libre_install.log
exit 7
fi
fi
# Getting internal interface name
INT_INTERFACE=`ls /sys/class/net/ | grep -w 'eth0\|eth1\|wlan0\|wlan1' | grep -v "$EXT_INTERFACE" | sed -n '1p'`
echo "Internal interface: $INT_INTERFACE" | tee -a /var/libre_install.log
}
# ----------------------------------------------
# This scripts check odroid board to find out if
# it assembled or not.
# There are list of additional modules that need
# to be connected to board.
# Additional modules are.
# 1. ssd 8gbc10
# 2. HDD 2TB
# 3. 2xWlan interfaces
# 4. TFT screen
# ----------------------------------------------
check_assemblance()
{
echo "Checking assemblance ..." | tee -a /var/libre_install.log
echo "Checking network interfaces ..."
# Script should detect 4 network
# interfaces.
# 1. eth0
# 2. eth1
# 3. wlan0
# 4. wlan1
if ! ls /sys/class/net/ | grep -w 'eth0'; then
echo "Error: Interface eth0 is not connected. Exiting"
exit 8
elif ! ls /sys/class/net/ | grep -w 'eth1'; then
echo "Error: Interface eth1 is not connected. Exiting"
exit 9
elif ! ls /sys/class/net/ | grep -w 'wlan0'; then
echo "Error: Interface wlan0 is not connected. Exiting"
exit 10
elif ! ls /sys/class/net/ | grep -w 'wlan1'; then
echo "Error: Interface wlan1 is not connected. Exiting"
exit 11
fi
echo "Network interfaces checking finished. OK" | tee -a /var/libre_install.log
echo ""
}
# ----------------------------------------------
# Function to install libressl
# ----------------------------------------------
install_libressl()
{
echo "Installing libressl ..." | tee -a /var/libre_install.log
if [ ! -e libressl-2.4.2 ]; then
echo "Downloading libressl ..." | tee -a /var/libre_install.log
cd $INSTALL_HOME
wget http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.4.2.tar.gz
if [ $? -ne 0 ]; then
echo "Error: unable to download libressl" | tee -a /var/libre_install.log
exit 3
fi
tar -xzf libressl-2.4.2.tar.gz
fi
echo "Building libressl ..." | tee -a /var/libre_install.log
cd $INSTALL_HOME
cd libressl-2.4.2/
./configure
make && make install
if [ $? -ne 0 ]; then
echo "Error: unable to install libressl. Exiting ..." | tee -a /var/libre_install.log
exit 3
fi
cd ../
# Cleanup
rm -rf libressl-2.4.2.tar.gz
}
# ----------------------------------------------
# Function to install modsecurity
# ----------------------------------------------
install_modsecurity()
{
echo "Installing modsecurity ..." | tee -a /var/libre_install.log
if [ ! -e /usr/src/modsecurity ]; then
echo "Downloading modsecurity ..." | tee -a /var/libre_install.log
cd /usr/src/
git clone https://github.com/SpiderLabs/ModSecurity.git modsecurity
if [ $? -ne 0 ]; then
echo "Error: unable to download modsecurity. Exiting ..." | tee -a /var/libre_install.log
exit 3
fi
fi
echo "Building modsecurity ..." | tee -a /var/libre_install.log
cd /usr/src/modsecurity
./autogen.sh
./configure --enable-standalone-module --disable-mlogc
make
if [ $? -ne 0 ]; then
echo "Error: unable to install modsecurity. Exiting ..." | tee -a /var/libre_install.log
exit 3
fi
# Downloading the OWASP Core Rule Set
cd /usr/src/
git clone https://github.com/SpiderLabs/owasp-modsecurity-crs.git
cd owasp-modsecurity-crs
cp -R base_rules/ /etc/nginx/
cd $INSTALL_HOME
}
# ---------------------------------------------------------
# Function to install WAF-FLE (Modsecurity GUI)
# ---------------------------------------------------------
install_waffle() {
echo "Installing WAF-FLE ..." | tee -a /var/libre_install.log
# installing dependencies
apt-get install -y --force-yes php5-geoip php-apc
mkdir -p /usr/local/waf-fle/
cd /usr/local/waf-fle/
rm -rf /usr/local/waf-fle/*
if [ ! -e waf-fle-master.zip ]; then
echo "Downloading waf-fle ..." | tee -a /var/libre_install.log
wget https://github.com/klaubert/waf-fle/archive/master.zip
if [ $? -ne 0 ]; then
echo "Unable to download waf-fle. Exiting ..." | tee -a /var/libre_install.log
exit 3
fi
fi
# Decompressing package
unzip master.zip -d /usr/local/waf-fle/
cp -r /usr/local/waf-fle/waf-fle-master/* /usr/local/waf-fle/
rm -rf /usr/local/waf-fle/waf-fle-master/
# Download MaxMind GeoIP Database
mkdir /usr/share/GeoIP/
cd /usr/share/GeoIP/
rm -r /usr/share/GeoIP/*
if [ ! -e GeoIP.dat.gz ]; then
echo "Downloading GeoIP.dat ..." | tee -a /var/libre_install.log
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
if [ $? -ne 0 ]; then
echo "Unable to download GeoIP.dat. Exiting ..." | tee -a /var/libre_install.log
exit 3
fi
fi