forked from raspiblitz/raspiblitz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_sdcard.sh
executable file
·1307 lines (1165 loc) · 48.7 KB
/
build_sdcard.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
#########################################################################
# Build your SD card image based on:
# raspios_arm64-2020-08-24
# https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2021-04-09/
# SHA256: a30a3650c3ef22a69f6f025760c6b04611a5992961a8c2cd44468f1c429d68bb
##########################################################################
# setup fresh SD card with image above - login per SSH and run this script:
##########################################################################
echo ""
echo "*****************************************"
echo "* RASPIBLITZ SD CARD IMAGE SETUP v1.7 *"
echo "*****************************************"
echo "For details on optional parameters - see build script source code:"
# 1st optional paramater: NO-INTERACTION
# ----------------------------------------
# When 'true' then no questions will be ask on building .. so it can be used in build scripts
# for containers or as part of other build scripts (default is false)
noInteraction="$1"
if [ ${#noInteraction} -eq 0 ]; then
noInteraction="false"
fi
if [ "${noInteraction}" != "true" ] && [ "${noInteraction}" != "false" ]; then
echo "ERROR: NO-INTERACTION parameter needs to be either 'true' or 'false'"
exit 1
else
echo "1) will use NO-INTERACTION --> '${noInteraction}'"
fi
# 2nd optional paramater: FATPACK
# -------------------------------
# could be 'true' or 'false' (default)
# When 'true' it will pre-install needed frameworks for additional apps and features
# as a convenience to safe on install and update time for additional apps.
# When 'false' it will just install the bare minimum and additional apps will just
# install needed frameworks and libraries on demand when activated by user.
# Use 'false' if you want to run your node without: go, dot-net, nodejs, docker, ...
fatpack="$2"
if [ ${#fatpack} -eq 0 ]; then
fatpack="false"
fi
if [ "${fatpack}" != "true" ] && [ "${fatpack}" != "false" ]; then
echo "ERROR: FATPACK parameter needs to be either 'true' or 'false'"
exit 1
else
echo "2) will use FATPACK --> '${fatpack}'"
fi
# 3rd optional paramater: GITHUB-USERNAME
# ---------------------------------------
# could be any valid github-user that has a fork of the raspiblitz repo - 'rootzoll' is default
# The 'raspiblitz' repo of this user is used to provisioning sd card
# with raspiblitz assets/scripts later on.
# If this parameter is set also the branch needs to be given (see next parameter).
githubUser="$3"
if [ ${#githubUser} -eq 0 ]; then
githubUser="rootzoll"
fi
echo "3) will use GITHUB-USERNAME --> '${githubUser}'"
# 4th optional paramater: GITHUB-BRANCH
# -------------------------------------
# could be any valid branch of the given GITHUB-USERNAME forked raspiblitz repo - 'dev' is default
githubBranch="$4"
if [ ${#githubBranch} -eq 0 ]; then
githubBranch="dev"
fi
echo "4) will use GITHUB-BRANCH --> '${githubBranch}'"
# 5th optional paramater: DISPLAY-CLASS
# ----------------------------------------
# Could be 'hdmi', 'headless' or 'lcd'
# On 'false' the standard video output is used (HDMI) by default.
# https://github.com/rootzoll/raspiblitz/issues/1265#issuecomment-813369284
displayClass="$5"
if [ ${#displayClass} -eq 0 ] || [ "${displayClass}" == "false" ]; then
displayClass="hdmi"
fi
if [ "${displayClass}" != "hdmi" ] && [ "${displayClass}" != "lcd" ] && [ "${displayClass}" != "headless" ]; then
echo "ERROR: DISPLAY-CLASS parameter needs to be 'lcd', 'hdmi' or 'headless'"
exit 1
else
echo "5) will use DISPLAY-CLASS --> '${displayClass}'"
fi
# 6th optional paramater: TWEAK-BOOTDRIVE
# ---------------------------------------
# could be 'true' (default) or 'false'
# If 'true' it will try (based on the base OS) to optimize the boot drive.
# If 'false' this will skipped.
tweakBootdrives="$6"
if [ ${#tweakBootdrives} -eq 0 ]; then
tweakBootdrives="true"
fi
if [ "${tweakBootdrives}" != "true" ] && [ "${tweakBootdrives}" != "false" ]; then
echo "ERROR: TWEAK-BOOTDRIVE parameter needs to be either 'true' or 'false'"
exit 1
else
echo "6) will use TWEAK-BOOTDRIVE --> '${tweakBootdrives}'"
fi
# 7th optional paramater: WIFI
# ---------------------------------------
# could be 'false' or 'true' (default) or a valid WIFI country code like 'US' (default)
# If 'false' WIFI will be deactivated by default
# If 'true' WIFI will be activated by with default country code 'US'
# If any valid wifi country code Wifi will be activated with that country code by default
modeWifi="$7"
if [ ${#modeWifi} -eq 0 ] || [ "${modeWifi}" == "true" ]; then
modeWifi="US"
fi
echo "7) will use WIFI --> '${modeWifi}'"
# 8th optional paramater: TESTTORDOMAIN
# ---------------------------------------
# could be 'true'(default) or 'false'
# Avoid pinging Tor domain if the user knows it is blocked.
# the users governement prohibits Tor usage, he can avoid pinging Tor domain with 'false'.
# Default is 'true' cause this is a rare ocasion for certain people.
# If 'true' will ping torproject.org. If there is no response from pinging, will add Tor sources with tor://
# If 'false' will not ping torproject.org. Will add Tor sources with tor://
testTorDomain="$8"
if [ ${#testTorDomain} -eq 0 ]; then
testTorDomain="true"
fi
if [ "${testTorDomain}" != "true" ] && [ "${testTorDomain}" != "false" ]; then
echo "ERROR: TEST-TOR-DOMAIN parameter needs to be either 'true' or 'false'"
exit 1
else
echo "8) will use TEST-TOR-DOMAIN --> '${testTorDomain}'"
fi
# 9th optional paramater: ADDBRIDGES
# ---------------------------------------
# could be 'true' or 'false'(default)
# Default is 'false' cause this is a rare ocasion for certain people.
# If 'true' will add bridges if there is a 'torrc' file on the 'home' folder.
# If 'false' will skip adding bridges.
addBridges="$9"
if [ ${#addBridges} -eq 0 ]; then
addBridges="false"
fi
if [ "${addBridges}" != "true" ] && [ "${addBridges}" != "false" ]; then
echo "ERROR: ADD-BRIDGES parameter needs to be either 'true' or 'false'"
exit 1
elif [ "${addBridges}" = "true" ] && [ ! -f ./torrc ]; then
echo "User chose to use bridges but 'torrc' file not found on home folder."
echo "Will exit now for the user safety."
exit 1
else
echo "9) will use ADD-BRIDGES --> '${addBridges}'"
fi
# AUTO-DETECTION: CPU-ARCHITECTURE
# ---------------------------------------
# keep in mind that DietPi for Raspberry is also a stripped down Raspbian
isARM=$(uname -m | grep -c 'arm')
isAARCH64=$(uname -m | grep -c 'aarch64')
isX86_64=$(uname -m | grep -c 'x86_64')
cpu="?"
if [ ${isARM} -gt 0 ]; then
cpu="arm"
elif [ ${isAARCH64} -gt 0 ]; then
cpu="aarch64"
elif [ ${isX86_64} -gt 0 ]; then
cpu="x86_64"
else
echo "!!! FAIL !!!"
echo "Can only build on ARM, aarch64, x86_64 not on:"
uname -m
exit 1
fi
echo "X) will use CPU-ARCHITECTURE --> '${cpu}'"
# AUTO-DETECTION: OPERATINGSYSTEM and DISTRIBUTION
# ---------------------------------------
baseimage="?"
isDietPi=$(uname -n | grep -c 'DietPi')
isRaspbian=$(grep -c 'Raspbian' /etc/os-release 2>/dev/null)
isDebian=$(grep -c 'Debian' /etc/os-release 2>/dev/null)
isUbuntu=$(grep -c 'Ubuntu' /etc/os-release 2>/dev/null)
isNvidia=$(uname -a | grep -c 'tegra')
if [ ${isRaspbian} -gt 0 ]; then
baseimage="raspbian"
fi
if [ ${isDebian} -gt 0 ]; then
if [ $(uname -n | grep -c 'rpi') -gt 0 ] && [ ${isAARCH64} -gt 0 ]; then
baseimage="debian_rpi64"
elif [ $(uname -n | grep -c 'raspberrypi') -gt 0 ] && [ ${isAARCH64} -gt 0 ]; then
baseimage="raspios_arm64"
elif [ ${isAARCH64} -gt 0 ] || [ ${isARM} -gt 0 ] ; then
baseimage="armbian"
else
baseimage="debian"
fi
fi
if [ ${isUbuntu} -gt 0 ]; then
baseimage="ubuntu"
fi
if [ ${isDietPi} -gt 0 ]; then
baseimage="dietpi"
fi
if [ "${baseimage}" = "?" ]; then
cat /etc/os-release 2>/dev/null
echo "!!! FAIL: Base Image cannot be detected or is not supported."
exit 1
fi
echo "X) will use OPERATINGSYSTEM ---> '${baseimage}'"
distribution=$(lsb_release -sc)
echo "X) will use DISTRIBUTION ---> '${distribution}'"
# USER-CONFIRMATION
if [ "${noInteraction}" != "true" ]; then
echo -n "Do you agree with all parameters above? (yes/no) "
read installRaspiblitzAnswer
if [ "$installRaspiblitzAnswer" != "yes" ] ; then
echo "Build canceled."
exit 1
fi
fi
echo "Building RaspiBlitz ..."
# cronometer
start=$SECONDS
sleep 3
echo ""
# cd goes to /root, it is needed to stay in user logged in.
echo "*** Save current /home/user path ***"
userPath=$(pwd)
userRunning=$(pwd | cut -c7-20)
echo "User path is: ${userPath}"
echo "User logged is: ${userRunning}"
echo ""
# Ease commenting and uncommenting deb-src.
echo "*** Separate sources to different files ***"
sudo cp /etc/apt/sources.list /etc/apt/sources.list.orig
sudo rm -rf /etc/apt/sources.list
sudo rm -rf /etc/apt/sources.list.d/*
sudo touch /etc/apt/sources.list.d/deb.list
sudo touch /etc/apt/sources.list.d/deb-src.list
sudo touch /etc/apt/sources.list.d/tor.list
sudo touch /etc/apt/sources.list.d/tor-src.list
sudo touch /etc/apt/sources.list.d/tor-apttor.list
sudo touch /etc/apt/sources.list.d/tor-src-apttor.list
echo "*** Adding distro Sources to sources.list ***"
if [ "${baseimage}" = "debian" ] || [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "raspios_arm64" ] || [ "${baseimage}" = "debian_rpi64" ] || [ "${baseimage}" = "armbian" ] || [ "${baseimage}" = "dietpi" ]; then
sudo tee -a /etc/apt/sources.list.d/deb.list << EOF
deb https://deb.debian.org/debian ${distribution} main contrib non-free
deb https://deb.debian.org/debian-security/ ${distribution}/updates main contrib non-free
deb https://deb.debian.org/debian ${distribution}-updates main contrib non-free
EOF
sudo tee -a /etc/apt/sources.list.d/deb-src.list << EOF
deb-src https://deb.debian.org/debian ${distribution} main contrib non-free
EOF
elif [ "${baseimage}" = "ubuntu" ]; then
sudo tee -a /etc/apt/sources.list.d/deb.list << EOF
deb http://archive.ubuntu.com/ubuntu/ ${distribution} main
deb http://archive.ubuntu.com/ubuntu/ ${distribution}/updates main
deb http://archive.ubuntu.com/ubuntu/ ${distribution}-updates main
EOF
sudo tee -a /etc/apt/sources.list.d/deb-src.list << EOF
deb-src http://archive.ubuntu.com/ubuntu/ ${distribution} main
EOF
fi
echo "deb-src for ${baseimage} ${distribution} is available"
echo ""
echo "*** Update and Upgrade ${baseimage} ${distribution} sources ***"
sudo apt update
sudo apt dist-upgrade -f -y
echo ""
# INSTALL TOR BRIDGES PACKAGE
# Doesnt work the repo version. Only works building from source on ARM (32/64 bit).
# The last version for Buster (Stable) today (apr/2021) is obfs4proxy 0.0.7-4. https://tracker.debian.org/pkg/obfs4proxy
# Warnings will appear of not using the v1.11 golang, but will work anyway.
echo "*** Compile obfs4proxy from source ***"
mkdir -p obfs4proxy
cd obfs4proxy/
sudo apt install -y obfs4proxy
sudo apt source obfs4proxy
sudo apt build-dep -y obfs4proxy
cd obfs4proxy-*
dpkg-buildpackage -b -uc
cd ..
dpkg -i obfs4proxy_*.deb
sudo apt update
sudo apt --only-upgrade install obfs4proxy
cd ..
sudo rm -rf obfs4proxy
cd ${userPath}
echo "# Installed $(obfs4proxy --version)"
echo ""
echo "# Commenting deb-src ..."
sudo sed -i 's/^/#/' /etc/apt/sources.list.d/deb-src.list
echo "deb-src are commented now"
echo ""
# MASK TOR
# Tor will just start after user has the possibility to input bridges to mask he is using Tor
# This is for security reasons if someone is in danger to no appear in the radar.
echo "*** Mask Tor before installing ***"
echo "# Preventing Tor from start before user configuration"
sudo systemctl mask [email protected]
isTorMasked=$(sudo systemctl is-enabled tor@default)
sleep 3
if [ ${isTorMasked} != "masked" ]; then
echo "Failed to mask Tor, open an issue on github"
exit 0
else
echo "Tor is masked now"
fi
echo ""
# INSTALL TOR
# Tor will be installed from Distro repo for who dont have acces to www.torproject.org
# Afraid of gov detecting you use Tor? https://github.com/rootzoll/raspiblitz/issues/592#issuecomment-491826661
# This will give you the option to use Tor Pluggable Transport Bridges to mask you are using Tor.
# Tor domain blocked https://github.com/rootzoll/raspiblitz/issues/2054
echo "*** INSTALL TOR BY DEFAULT ***"
sudo apt install -y dirmngr apt-transport-tor tor torsocks nyx
echo ""
# Test Tor domain. Will add tor:// if he choses to ping but dont can't reach.
if [ "${testTorDomain}" = "true" ]; then
echo "Testing connection to torproject.org"
statusTorDomain=$(sudo ping -c 3 torproject.org | grep -c '3 received')
echo "Status=${statusTorDomain}"
if [ ${statusTorDomain} -gt 0 ]; then
echo "You can reach torproject.org via CLEARNET. But Tor connections could still be blocked, add bridges if you desire."
echo "Reaching Tor sources will be acquired using apt-transport-https."
else
echo "!!! WARNING: You can NOT reach torproject.org via CLEARNET. You should configure bridges."
echo "Reaching Tor sources will be acquired using apt-transport-tor."
fi
elif [ "${testTorDomain}" = "false" ]; then
echo "You chose not to ping https://www.torproject.org domain."
echo "Reaching Tor sources will be acquired using apt-transport-tor."
fi
echo ""
# Add 'torrc' home folder file to /etc/tor/torrc. The user needs to place a torrc named file.
if [ "${addBridges}" = "true" ]; then
if [ ! -f "${userPath}"/torrc ]; then
echo "User chose to use bridges but 'torrc' file not found on home folder."
echo "Will exit now for the user safety."
exit 0
elif [ -f "${userPath}"/torrc ]; then
echo "Adding bridges specified by the user."
echo "" | sudo tee -a "${userPath}"/torrc
sudo cp /etc/tor/torrc /etc/tor/torrc.orig
sudo rm /etc/tor/torrc
sudo cp "${userPath}"/torrc /etc/tor/torrc
# backup bridges in case something goes wrong
sudo cp "${userPath}"/torrc /etc/tor/bridges
sudo chmod 644 /etc/tor/torrc
sudo chown -R debian-tor:debian-tor /var/run/tor/ 2>/dev/null
fi
else
echo "Skipping adding bridges."
fi
echo ""
# tor@default vanished from unit file warning if normal. This message will stop after reboot.
# Doing 'update-rc.d tor enable' will enable Tor on boot after unit vanishing.
# systemctl restart because it could be already started from a failed build before, so we can see the right bootstrap logs. Start dont singal to reboot the service.
echo "*** Unmask Tor ***"
sudo systemctl unmask [email protected]
sudo systemctl daemon-reload
sudo systemctl reset-failed
sudo update-rc.d tor enable
sudo systemctl restart [email protected]
## sleep long enough to bootstrap when using bridges (usually has a delay to bootstrap).
echo "Sleeping for 40 seconds. Waiting for Tor to fully bootstrap"
sleep 40
# Dont show full logs (systemctl), cause bridges IP and Descriptors are displayed here and cant be hidden by Tor configuration.
sudo systemctl status tor@default | grep running && sudo systemctl status tor@default | grep Bootstrapped
echo ""
# check if Tor is functional
echo "*** Check if Tor service is functional ***"
torRunning=$(curl --connect-timeout 10 --socks5-hostname 127.0.0.1:9050 https://check.torproject.org 2>/dev/null | grep "Congratulations. This browser is configured to use Tor." -c)
if [ ${torRunning} -gt 0 ]; then
echo "You are all good - Tor is running. You reached Tor Project."
else
echo "!!! FAIL: Tor is not running ... exiting now."
echo "Correct the file /etc/tor/torrc manually before running this script again. Debug [email protected] with 'sudo journalctl -eu tor@default'."
echo "If you chose to use bridges, correct the 'torrc' file on your home folder."
exit 1
fi
echo ""
echo "*** Adding KEYS deb.torproject.org ***"
# fix for v1.6 base image https://github.com/rootzoll/raspiblitz/issues/1906#issuecomment-755299759
# fix for v1.7 tor domain blocked https://github.com/rootzoll/raspiblitz/issues/2054#issuecomment-800383278
# will use torsocks anyway, cause Tor needs to be running for whom needs it the most, and it will exit above on the test if not working.
torsocks wget -qO- http://apow7mjfryruh65chtdydfmqfpj5btws7nbocgtaovhvezgccyjazpqd.onion/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | sudo gpg --import
sudo gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
torKeyAvailable=$(sudo gpg --list-keys | grep -c "A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89")
if [ ${torKeyAvailable} -eq 0 ]; then
echo "!!! FAIL: Was not able to import deb.torproject.org key"
exit 1
fi
echo "OK - key added"
echo ""
# deb-src from Tor repo will be uncommented on internet.tor.sh to build it from source when calling the Update option in that script.
echo "*** Adding Tor Sources to sources lists ***"
if [ "${baseimage}" = "debian" ] || [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "raspios_arm64" ] || [ "${baseimage}" = "debian_rpi64" ] || [ "${baseimage}" = "armbian" ] || [ "${baseimage}" = "dietpi" ] || [ "${baseimage}" = "ubuntu" ]; then
if [ ${statusTorDomain} -eq 0 ] || [ "${testTorDomain}" = "false" ];then
echo "- adding 'deb tor+http://' for Tor to /etc/apt/sources.list.d/tor-apttor.list"
sudo tee -a /etc/apt/sources.list.d/tor-apttor.list << EOF
deb tor+http://apow7mjfryruh65chtdydfmqfpj5btws7nbocgtaovhvezgccyjazpqd.onion/torproject.org ${distribution} main
EOF
echo "- adding 'deb-src tor+http://' for Tor to /etc/apt/sources.list.d/tor-src-apttor.list"
sudo tee -a /etc/apt/sources.list.d/tor-src-apttor.list << EOF
#deb-src tor+http://apow7mjfryruh65chtdydfmqfpj5btws7nbocgtaovhvezgccyjazpqd.onion/torproject.org ${distribution} main
EOF
echo "OK - Tor sources added"
else
echo "- adding 'deb https://' for Tor to /etc/apt/sources.list.d/tor.list"
sudo tee -a /etc/apt/sources.list.d/tor.list << EOF
deb https://deb.torproject.org/torproject.org ${distribution} main
EOF
echo "- adding 'deb-src https://' for Tor to /etc/apt/sources.list.d/tor-src.list"
sudo tee -a /etc/apt/sources.list.d/tor-src.list << EOF
#deb-src https://deb.torproject.org/torproject.org ${distribution} main
EOF
echo "OK - Tor sources added"
fi
else
echo "!!! FAIL: No Tor sources for OS: ${baseimage}"
exit 1
fi
echo ""
# Now Tor will be installed in the latest version from Tor Project repo.
echo "*** Install & Enable Tor ***"
sudo apt update
sudo apt install -y tor torsocks nyx
echo ""
# FIXING LOCALES
# https://github.com/rootzoll/raspiblitz/issues/138
# https://daker.me/2014/10/how-to-fix-perl-warning-setting-locale-failed-in-raspbian.html
# https://stackoverflow.com/questions/38188762/generate-all-locales-in-a-docker-image
if [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "dietpi" ] || \
[ "${baseimage}" = "raspios_arm64" ]||[ "${baseimage}" = "debian_rpi64" ]; then
echo ""
echo "*** FIXING LOCALES FOR BUILD ***"
sudo sed -i "s/^# en_US.UTF-8 UTF-8.*/en_US.UTF-8 UTF-8/g" /etc/locale.gen
sudo sed -i "s/^# en_US ISO-8859-1.*/en_US ISO-8859-1/g" /etc/locale.gen
sudo locale-gen
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
if [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "dietpi" ]; then
export LC_ALL=en_US.UTF-8
# https://github.com/rootzoll/raspiblitz/issues/684
sudo sed -i "s/^ SendEnv LANG LC.*/# SendEnv LANG LC_*/g" /etc/ssh/ssh_config
# remove unneccesary files
sudo rm -rf /home/pi/MagPi
# https://www.reddit.com/r/linux/comments/lbu0t1/microsoft_repo_installed_on_all_raspberry_pis/
sudo rm -f /etc/apt/sources.list.d/vscode.list
sudo rm -f /etc/apt/trusted.gpg.d/microsoft.gpg
fi
if [ ! -f /etc/apt/sources.list.d/raspi.list ]; then
echo "# Add the archive.raspberrypi.org/debian/ to the sources.list"
echo "deb http://archive.raspberrypi.org/debian/ buster main" | sudo tee /etc/apt/sources.list.d/raspi.list
fi
fi
# remove some (big) packages that are not needed
sudo apt remove -y --purge libreoffice* oracle-java* chromium-browser nuscratch scratch sonic-pi minecraft-pi plymouth python2 vlc
sudo apt clean
sudo apt -y autoremove
if [ -f "/usr/bin/python3.7" ]; then
# make sure /usr/bin/python exists (and calls Python3.7 in Buster)
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1
echo "python calls python3.7"
elif [ -f "/usr/bin/python3.8" ]; then
# use python 3.8 if available
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
sudo ln -s /usr/bin/python3.8 /usr/bin/python3.7
echo "python calls python3.8"
else
echo "!!! FAIL !!!"
echo "There is no tested version of python present"
exit 1
fi
# update debian
echo ""
echo "*** UPDATE ***"
sudo apt update -y
sudo apt upgrade -f -y
echo ""
echo "*** PREPARE ${baseimage} ***"
# make sure the pi user is present
if [ "$(compgen -u | grep -c dietpi)" -gt 0 ];then
echo "# Renaming dietpi user to pi"
sudo usermod -l pi dietpi
elif [ "$(compgen -u | grep -c pi)" -eq 0 ];then
echo "# Adding the user pi"
sudo adduser --disabled-password --gecos "" pi
sudo adduser pi sudo
fi
# special prepare when Raspbian
if [ "${baseimage}" = "raspbian" ]||[ "${baseimage}" = "raspios_arm64" ]||\
[ "${baseimage}" = "debian_rpi64" ]; then
sudo apt install -y raspi-config
# do memory split (16MB)
sudo raspi-config nonint do_memory_split 16
# set to wait until network is available on boot (0 seems to yes)
sudo raspi-config nonint do_boot_wait 0
# set WIFI country so boot does not block
if [ "${modeWifi}" != "false" ]; then
# this will undo the softblock of rfkill on RaspiOS
sudo raspi-config nonint do_wifi_country $modeWifi
fi
# see https://github.com/rootzoll/raspiblitz/issues/428#issuecomment-472822840
configFile="/boot/config.txt"
max_usb_current="max_usb_current=1"
max_usb_currentDone=$(grep -c "$max_usb_current" $configFile)
if [ ${max_usb_currentDone} -eq 0 ]; then
echo "" | sudo tee -a $configFile
echo "# Raspiblitz" | sudo tee -a $configFile
echo "$max_usb_current" | sudo tee -a $configFile
else
echo "$max_usb_current already in $configFile"
fi
# run fsck on sd root partition on every startup to prevent "maintenance login" screen
# see: https://github.com/rootzoll/raspiblitz/issues/782#issuecomment-564981630
# see https://github.com/rootzoll/raspiblitz/issues/1053#issuecomment-600878695
# use command to check last fsck check: sudo tune2fs -l /dev/mmcblk0p2
if [ "${tweakBootdrives}" == "true" ]; then
echo "* running tune2fs"
sudo tune2fs -c 1 /dev/mmcblk0p2
else
echo "* skipping tweakBootdrives"
fi
# edit kernel parameters
kernelOptionsFile=/boot/cmdline.txt
fsOption1="fsck.mode=force"
fsOption2="fsck.repair=yes"
fsOption1InFile=$(grep -c ${fsOption1} ${kernelOptionsFile})
fsOption2InFile=$(grep -c ${fsOption2} ${kernelOptionsFile})
if [ ${fsOption1InFile} -eq 0 ]; then
sudo sed -i "s/^/$fsOption1 /g" "$kernelOptionsFile"
echo "$fsOption1 added to $kernelOptionsFile"
else
echo "$fsOption1 already in $kernelOptionsFile"
fi
if [ ${fsOption2InFile} -eq 0 ]; then
sudo sed -i "s/^/$fsOption2 /g" "$kernelOptionsFile"
echo "$fsOption2 added to $kernelOptionsFile"
else
echo "$fsOption2 already in $kernelOptionsFile"
fi
fi
# special prepare when Nvidia Jetson Nano
if [ ${isNvidia} -eq 1 ] ; then
# disable GUI on boot
sudo systemctl set-default multi-user.target
fi
echo ""
echo "*** CONFIG ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#raspi-config
# set new default password for root user
echo "root:raspiblitz" | sudo chpasswd
echo "pi:raspiblitz" | sudo chpasswd
# prepare auto-start of 00infoLCD.sh script on pi user login (just kicks in if auto-login of pi is activated in HDMI or LCD mode)
if [ "${baseimage}" = "raspbian" ]||[ "${baseimage}" = "raspios_arm64" ]||\
[ "${baseimage}" = "debian_rpi64" ]||[ "${baseimage}" = "armbian" ]||\
[ "${baseimage}" = "ubuntu" ]; then
homeFile=/home/pi/.bashrc
autostartDone=$(grep -c "automatic start the LCD" $homeFile)
if [ ${autostartDone} -eq 0 ]; then
# bash autostart for pi
# run as exec to dont allow easy physical access by keyboard
# see https://github.com/rootzoll/raspiblitz/issues/54
sudo bash -c 'echo "# automatic start the LCD info loop" >> /home/pi/.bashrc'
sudo bash -c 'echo "SCRIPT=/home/admin/00infoLCD.sh" >> /home/pi/.bashrc'
sudo bash -c 'echo "# replace shell with script => logout when exiting script" >> /home/pi/.bashrc'
sudo bash -c 'echo "exec \$SCRIPT" >> /home/pi/.bashrc'
echo "autostart LCD added to $homeFile"
else
echo "autostart LCD already in $homeFile"
fi
elif [ "${baseimage}" = "dietpi" ]; then
homeFile=/home/dietpi/.bashrc
autostartDone=$(grep -c "automatic start the LCD" $homeFile)
if [ ${autostartDone} -eq 0 ]; then
# bash autostart for dietpi
sudo bash -c 'echo "# automatic start the LCD info loop" >> /home/dietpi/.bashrc'
sudo bash -c 'echo "SCRIPT=/home/admin/00infoLCD.sh" >> /home/dietpi/.bashrc'
sudo bash -c 'echo "# replace shell with script => logout when exiting script" >> /home/dietpi/.bashrc'
sudo bash -c 'echo "exec \$SCRIPT" >> /home/dietpi/.bashrc'
echo "autostart LCD added to $homeFile"
else
echo "autostart LCD already in $homeFile"
fi
else
echo "WARN: Script Autostart not available for baseimage(${baseimage}) - may just run on 'headless'"
fi
# change log rotates
# see https://github.com/rootzoll/raspiblitz/issues/394#issuecomment-471535483
echo "/var/log/syslog" >> ./rsyslog
echo "{" >> ./rsyslog
echo " rotate 7" >> ./rsyslog
echo " daily" >> ./rsyslog
echo " missingok" >> ./rsyslog
echo " notifempty" >> ./rsyslog
echo " delaycompress" >> ./rsyslog
echo " compress" >> ./rsyslog
echo " postrotate" >> ./rsyslog
echo " invoke-rc.d rsyslog rotate > /dev/null" >> ./rsyslog
echo " endscript" >> ./rsyslog
echo "}" >> ./rsyslog
echo "" >> ./rsyslog
echo "/var/log/mail.info" >> ./rsyslog
echo "/var/log/mail.warn" >> ./rsyslog
echo "/var/log/mail.err" >> ./rsyslog
echo "/var/log/mail.log" >> ./rsyslog
echo "/var/log/daemon.log" >> ./rsyslog
echo "{" >> ./rsyslog
echo " rotate 4" >> ./rsyslog
echo " size=100M" >> ./rsyslog
echo " missingok" >> ./rsyslog
echo " notifempty" >> ./rsyslog
echo " compress" >> ./rsyslog
echo " delaycompress" >> ./rsyslog
echo " sharedscripts" >> ./rsyslog
echo " postrotate" >> ./rsyslog
echo " invoke-rc.d rsyslog rotate > /dev/null" >> ./rsyslog
echo " endscript" >> ./rsyslog
echo "}" >> ./rsyslog
echo "" >> ./rsyslog
echo "/var/log/kern.log" >> ./rsyslog
echo "/var/log/auth.log" >> ./rsyslog
echo "{" >> ./rsyslog
echo " rotate 4" >> ./rsyslog
echo " size=100M" >> ./rsyslog
echo " missingok" >> ./rsyslog
echo " notifempty" >> ./rsyslog
echo " compress" >> ./rsyslog
echo " delaycompress" >> ./rsyslog
echo " sharedscripts" >> ./rsyslog
echo " postrotate" >> ./rsyslog
echo " invoke-rc.d rsyslog rotate > /dev/null" >> ./rsyslog
echo " endscript" >> ./rsyslog
echo "}" >> ./rsyslog
echo "" >> ./rsyslog
echo "/var/log/user.log" >> ./rsyslog
echo "/var/log/lpr.log" >> ./rsyslog
echo "/var/log/cron.log" >> ./rsyslog
echo "/var/log/debug" >> ./rsyslog
echo "/var/log/messages" >> ./rsyslog
echo "{" >> ./rsyslog
echo " rotate 4" >> ./rsyslog
echo " weekly" >> ./rsyslog
echo " missingok" >> ./rsyslog
echo " notifempty" >> ./rsyslog
echo " compress" >> ./rsyslog
echo " delaycompress" >> ./rsyslog
echo " sharedscripts" >> ./rsyslog
echo " postrotate" >> ./rsyslog
echo " invoke-rc.d rsyslog rotate > /dev/null" >> ./rsyslog
echo " endscript" >> ./rsyslog
echo "}" >> ./rsyslog
sudo mv ./rsyslog /etc/logrotate.d/rsyslog
sudo chown root:root /etc/logrotate.d/rsyslog
sudo service rsyslog restart
echo ""
echo "*** SOFTWARE UPDATE ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#software-update
# installs like on RaspiBolt
sudo apt install -y htop git curl bash-completion vim jq dphys-swapfile bsdmainutils
# installs bandwidth monitoring for future statistics
sudo apt install -y vnstat
# prepare for format data drive
sudo apt install -y parted dosfstools
# prepare for BTRFS data drive raid
sudo apt install -y btrfs-progs
# network tools
sudo apt install -y autossh telnet
# prepare for display graphics mode
# see https://github.com/rootzoll/raspiblitz/pull/334
sudo apt install -y fbi
# prepare for powertest
sudo apt install -y sysbench
# check for dependencies on DietPi, Ubuntu, Armbian
sudo apt install -y build-essential
# add armbian-config
if [ "${baseimage}" = "armbian" ]; then
# add armbian config
sudo apt install armbian-config -y
fi
# dependencies for python
sudo apt install -y python3-venv python3-dev python3-wheel python3-jinja2 python3-pip
# make sure /usr/bin/pip exists (and calls pip3 in Debian Buster)
sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
# rsync is needed to copy from HDD
sudo apt install -y rsync
# install ifconfig
sudo apt install -y net-tools
#to display hex codes
sudo apt install -y xxd
# setuptools needed for Nyx
sudo pip install setuptools
# netcat for 00infoBlitz.sh
sudo apt install -y netcat
# install OpenSSH client + server
sudo apt install -y openssh-client
sudo apt install -y openssh-sftp-server
sudo apt install -y sshpass
# install killall, fuser
sudo apt install -y psmisc
# install firewall
sudo apt install -y ufw
# make sure sqlite3 is available
sudo apt install -y sqlite3
sudo apt clean
sudo apt -y autoremove
echo ""
echo "*** ADDING MAIN USER admin ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#adding-main-user-admin
# using the default password 'raspiblitz'
sudo adduser --disabled-password --gecos "" admin
echo "admin:raspiblitz" | sudo chpasswd
sudo adduser admin sudo
sudo chsh admin -s /bin/bash
# configure sudo for usage without password entry
echo '%sudo ALL=(ALL) NOPASSWD:ALL' | sudo EDITOR='tee -a' visudo
# WRITE BASIC raspiblitz.info to sdcard
echo "baseimage=${baseimage}" > /home/admin/raspiblitz.info
echo "cpu=${cpu}" >> /home/admin/raspiblitz.info
echo "displayClass=headless" >> /home/admin/raspiblitz.info
sudo mv ./raspiblitz.info /home/admin/raspiblitz.info
sudo chmod 755 /home/admin/raspiblitz.info
echo ""
echo "*** ADDING SERVICE USER bitcoin"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#adding-the-service-user-bitcoin
# create user and set default password for user
sudo adduser --disabled-password --gecos "" bitcoin
echo "bitcoin:raspiblitz" | sudo chpasswd
echo ""
echo "*** ADDING GROUPS FOR CREDENTIALS STORE ***"
# access to credentials (e.g. macaroon files) in a central location is managed with unix groups and permissions
sudo /usr/sbin/groupadd --force --gid 9700 lndadmin
sudo /usr/sbin/groupadd --force --gid 9701 lndinvoice
sudo /usr/sbin/groupadd --force --gid 9702 lndreadonly
sudo /usr/sbin/groupadd --force --gid 9703 lndinvoices
sudo /usr/sbin/groupadd --force --gid 9704 lndchainnotifier
sudo /usr/sbin/groupadd --force --gid 9705 lndsigner
sudo /usr/sbin/groupadd --force --gid 9706 lndwalletkit
sudo /usr/sbin/groupadd --force --gid 9707 lndrouter
echo ""
echo "*** Python DEFAULT libs & dependencies ***"
# for setup shell scripts
sudo apt -y install dialog bc python3-dialog
# libs (for global python scripts)
sudo -H python3 -m pip install grpcio==1.36.1
sudo -H python3 -m pip install googleapis-common-protos==1.53.0
sudo -H python3 -m pip install toml==0.10.1
sudo -H python3 -m pip install j2cli==0.3.10
sudo -H python3 -m pip install requests[socks]==2.21.0
echo ""
echo "*** SHELL SCRIPTS AND ASSETS ***"
# copy raspiblitz repo from github
cd /home/admin/
sudo -u admin git config --global user.name "${githubUser}"
sudo -u admin git config --global user.email "[email protected]"
sudo -u admin rm -rf /home/admin/raspiblitz
sudo -u admin git clone -b ${githubBranch} https://github.com/${githubUser}/raspiblitz.git
sudo -u admin cp -r /home/admin/raspiblitz/home.admin/*.* /home/admin
sudo -u admin cp -r /home/admin/raspiblitz/home.admin/.tmux.conf /home/admin
sudo -u admin chmod +x *.sh
sudo -u admin cp -r /home/admin/raspiblitz/home.admin/assets /home/admin/
sudo -u admin cp -r /home/admin/raspiblitz/home.admin/config.scripts /home/admin/
sudo -u admin chmod +x /home/admin/config.scripts/*.sh
# install newest version of BlitzPy
blitzpy_wheel=$(ls -trR /home/admin/raspiblitz/home.admin/BlitzPy/dist | grep -E "*any.whl" | tail -n 1)
blitzpy_version=$(echo ${blitzpy_wheel} | grep -oE "([0-9]\.[0-9]\.[0-9])")
echo ""
echo "*** INSTALLING BlitzPy Version: ${blitzpy_version} ***"
sudo -H /usr/bin/python -m pip install "/home/admin/raspiblitz/home.admin/BlitzPy/dist/${blitzpy_wheel}" >/dev/null 2>&1
# make sure lndlibs are patched for compatibility for both Python2 and Python3
if ! grep -Fxq "from __future__ import absolute_import" /home/admin/config.scripts/lndlibs/rpc_pb2_grpc.py; then
sed -i -E '1 a from __future__ import absolute_import' /home/admin/config.scripts/lndlibs/rpc_pb2_grpc.py
fi
if ! grep -Eq "^from . import.*" /home/admin/config.scripts/lndlibs/rpc_pb2_grpc.py; then
sed -i -E 's/^(import.*_pb2)/from . \1/' /home/admin/config.scripts/lndlibs/rpc_pb2_grpc.py
fi
# add /sbin to path for all
sudo bash -c "echo 'PATH=\$PATH:/sbin' >> /etc/profile"
echo ""
echo "*** RASPIBLITZ EXTRAS ***"
# for background processes
sudo apt -y install screen
# for multiple (detachable/background) sessions when using SSH
# https://github.com/rootzoll/raspiblitz/issues/990
sudo apt -y install tmux
# optimization for torrent download
sudo bash -c "echo 'net.core.rmem_max = 4194304' >> /etc/sysctl.conf"
sudo bash -c "echo 'net.core.wmem_max = 1048576' >> /etc/sysctl.conf"
# install a command-line fuzzy finder (https://github.com/junegunn/fzf)
sudo apt -y install fzf
sudo bash -c "echo '' >> /home/admin/.bashrc"
sudo bash -c "echo '# https://github.com/rootzoll/raspiblitz/issues/1784' >> /home/admin/.bashrc"
sudo bash -c "echo 'NG_CLI_ANALYTICS=ci' >> /home/admin/.bashrc"
homeFile=/home/admin/.bashrc
keyBindings="source /usr/share/doc/fzf/examples/key-bindings.bash"
keyBindingsDone=$(grep -c "$keyBindings" $homeFile)
if [ ${keyBindingsDone} -eq 0 ]; then
sudo bash -c "echo 'source /usr/share/doc/fzf/examples/key-bindings.bash' >> /home/admin/.bashrc"
echo "key-bindings added to $homeFile"
else
echo "key-bindings already in $homeFile"
fi
homeFile=/home/admin/.bashrc
autostart="automatically start main menu"
autostartDone=$(grep -c "$autostart" $homeFile)
if [ ${autostartDone} -eq 0 ]; then
# bash autostart for admin
sudo bash -c "echo '# shortcut commands' >> /home/admin/.bashrc"
sudo bash -c "echo 'source /home/admin/_commands.sh' >> /home/admin/.bashrc"
sudo bash -c "echo '# automatically start main menu for admin unless' >> /home/admin/.bashrc"
sudo bash -c "echo '# when running in a tmux session' >> /home/admin/.bashrc"
sudo bash -c "echo 'if [ -z \"\$TMUX\" ]; then' >> /home/admin/.bashrc"
sudo bash -c "echo ' ./00raspiblitz.sh' >> /home/admin/.bashrc"
sudo bash -c "echo 'fi' >> /home/admin/.bashrc"
echo "autostart added to $homeFile"
else
echo "autostart already in $homeFile"
fi
sudo bash -c "echo '' >> /home/admin/.bashrc"
sudo bash -c "echo '# Raspiblitz' >> /home/admin/.bashrc"
echo ""
echo "*** SWAP FILE ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#moving-the-swap-file
# but just deactivating and deleting old (will be created alter when user adds HDD)
sudo dphys-swapfile swapoff
sudo dphys-swapfile uninstall
echo ""
echo "*** INCREASE OPEN FILE LIMIT ***"
# based on https://github.com/Stadicus/guides/blob/master/raspibolt/raspibolt_20_pi.md#increase-your-open-files-limit
sudo sed --in-place -i "56s/.*/* soft nofile 128000/" /etc/security/limits.conf
sudo bash -c "echo '* hard nofile 128000' >> /etc/security/limits.conf"
sudo bash -c "echo 'root soft nofile 128000' >> /etc/security/limits.conf"
sudo bash -c "echo 'root hard nofile 128000' >> /etc/security/limits.conf"
sudo bash -c "echo '# End of file' >> /etc/security/limits.conf"
sudo sed --in-place -i "23s/.*/session required pam_limits.so/" /etc/pam.d/common-session
sudo sed --in-place -i "25s/.*/session required pam_limits.so/" /etc/pam.d/common-session-noninteractive
sudo bash -c "echo '# end of pam-auth-update config' >> /etc/pam.d/common-session-noninteractive"
# *** fail2ban ***
# based on https://stadicus.github.io/RaspiBolt/raspibolt_21_security.html
echo "*** HARDENING ***"
sudo apt install -y --no-install-recommends python3-systemd fail2ban
# *** CACHE DISK IN RAM ***
echo "Activating CACHE RAM DISK ... "
sudo /home/admin/config.scripts/blitz.cache.sh on
# *** Wifi, Bluetooth & other configs ***
if [ "${baseimage}" = "raspbian" ]||[ "${baseimage}" = "raspios_arm64" ]||\
[ "${baseimage}" = "debian_rpi64" ]; then
if [ "${modeWifi}" == "false" ]; then
echo ""
echo "*** DISABLE WIFI ***"
sudo systemctl disable wpa_supplicant.service
sudo ifconfig wlan0 down
fi
echo ""
echo "*** DISABLE BLUETOOTH ***"
configFile="/boot/config.txt"
disableBT="dtoverlay=disable-bt"
disableBTDone=$(grep -c "$disableBT" $configFile)
if [ ${disableBTDone} -eq 0 ]; then
# disable bluetooth module
sudo echo "" >> $configFile
sudo echo "# Raspiblitz" >> $configFile
echo 'dtoverlay=pi3-disable-bt' | sudo tee -a $configFile
echo 'dtoverlay=disable-bt' | sudo tee -a $configFile
else
echo "disable BT already in $configFile"
fi
# remove bluetooth services
sudo systemctl disable bluetooth.service
sudo systemctl disable hciuart.service
# remove bluetooth packages
sudo apt remove -y --purge pi-bluetooth bluez bluez-firmware
echo
# disable audio
echo "*** DISABLE AUDIO (snd_bcm2835) ***"
sudo sed -i "s/^dtparam=audio=on/# dtparam=audio=on/g" /boot/config.txt
echo
# disable DRM VC4 V3D
echo "*** DISABLE DRM VC4 V3D driver ***"
dtoverlay=vc4-fkms-v3d
sudo sed -i "s/^dtoverlay=vc4-fkms-v3d/# dtoverlay=vc4-fkms-v3d/g" /boot/config.txt
echo
# I2C fix (make sure dtparam=i2c_arm is not on)
# see: https://github.com/rootzoll/raspiblitz/issues/1058#issuecomment-739517713
sudo sed -i "s/^dtparam=i2c_arm=.*//g" /boot/config.txt
fi
# *** FATPACK *** (can be activated by parameter - see details at start of script)
if [ "${fatpack}" == "true" ]; then
echo "*** FATPACK ***"
echo "* Adding nodeJS Framework ..."
sudo /home/admin/config.scripts/bonus.nodejs.sh on
if [ "$?" != "0" ]; then
echo "FATPACK FAILED"
exit 1
fi
echo "* Optional Packages (may be needed for extended features)"
sudo apt-get install -y qrencode