-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoinstall_old2.sh
859 lines (777 loc) · 28.5 KB
/
autoinstall_old2.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
#!/bin/bash
BGreen="\033[1;32m" # Green
BRed="\033[1;31m" # Red
BBlue="\033[1;34m" # Blue
NC="\033[0m" # No Color
####################################
SKIN=skin.carpc
Ver=-1.0.5
REPOSITORY=repository.maltsev_kodi
BaseSkin=skin.estuary
KODI=/home/pi/.kodi/addons/
####################################
ModelPI=/proc/device-tree/model
alias apt-get="apt-get --assume-yes"
network() {
ping -c1 -w1 raspberrypi.org 2>/dev/null 1>/dev/null
if [ "$?" = 0 ]; then
echo ${BGreen}'Successfully'${NC}
else
whiptail --title "ERROR" --msgbox "Inernet Connection is Missing \nRestart installer!" 10 60
exit 0
fi
}
update() {
apt-get update --allow-releaseinfo-change && 2>/dev/null 1>/dev/null
apt-get update -y 2>/dev/null 1>/dev/null
if [ "$?" = 0 ]; then
echo ${BGreen}'\\nSuccessfully'${NC}
else
whiptail --title "ERROR" --msgbox "Update Packets \nRestart installer!" 10 60
exit 0
fi
}
upgrade() {
apt-get upgrade -y 2>/dev/null 1>/dev/null
if [ "$?" = 0 ]; then
echo ${BGreen}'\\nSuccessfully'${NC}
else
whiptail --title "ERROR" --msgbox "Update Packets \nRestart installer!" 10 60
exit 0
fi
}
is_installed() {
dpkg -s "$1" > /dev/null 2>&1
}
samba() {
if is_installed "samba"; then
echo ${BGreen}'Successfully'${NC}
else
echo ${BGreen}'Installing'${NC}
if grep -q 'VERSION="10 (buster)"' /etc/os-release; then
echo "samba-common samba-common/workgroup string WORKGROUP" | debconf-set-selections
echo "samba-common samba-common/dhcp boolean true" | debconf-set-selections
echo "samba-common samba-common/do_debconf boolean true" | debconf-set-selections
fi
apt-get install -y samba 2>/dev/null 1>/dev/null
if [ "$?" = 0 ]; then
echo ${BGreen}'Successfully'${NC}
else
whiptail --title "SAMBA" --msgbox "ERROR Installing \nRestart installer!" 10 60
exit 0
fi
fi
if is_installed "samba"; then
if ! grep -q "/home/pi/" /etc/samba/smb.conf; then
cat <<'EOF' >> /etc/samba/smb.conf
[rns]
path = /home/pi/
create mask = 0775
directory mask = 0775
writeable = yes
browseable = yes
public = yes
force user = pi
guest ok = yes
EOF
fi
fi
}
kodi() {
if is_installed "kodi"; then
echo ${BGreen}'Successfully'${NC}
else
echo ${BGreen}'Installing'${NC}
apt-get install -y kodi 2>/dev/null 1>/dev/null
if [ "$?" = 0 ]; then
echo ${BGreen}'Successfully'${NC}
else
whiptail --title "KODI" --msgbox "ERROR Installing \nRestart installer!" 10 60
exit 0
fi
fi
if is_installed "kodi"; then
apt-get install -y kodi-pvr-iptvsimple 2>/dev/null 1>/dev/null
sed -i '/service.xbmc.versioncheck/d' /usr/share/kodi/system/addon-manifest.xml #Disable versioncheck
if ! grep -q "/usr/bin/kodi-standalone" /etc/systemd/system/kodi.service; then
cat <<'EOF' > /etc/systemd/system/kodi.service
[Unit]
Description=Kodi Media Center
[Service]
User=pi
Group=pi
Type=simple
ExecStart=/usr/bin/kodi-standalone
Restart=always
RestartSec=15
[Install]
WantedBy=multi-user.target
EOF
fi
fi
if grep -q "/usr/bin/kodi-standalone" /etc/systemd/system/kodi.service; then
systemctl enable kodi && systemctl start kodi
fi
}
kodi_status() {
if is_installed "kodi"; then
if (systemctl -q is-active kodi.service); then
systemctl stop kodi.service
sleep 5
fi
if (systemctl -q is-active kodi.service); then
systemctl stop kodi.service
sleep 10
fi
else
whiptail --title "KODI" --msgbox "ERROR Installing \nRestart installer!" 10 60
exit 0
fi
}
canutils() {
if is_installed "can-utils"; then
echo ${BGreen}'Successfully'${NC}
else
echo ${BGreen}'Installing'${NC}
apt install -y can-utils 2>/dev/null 1>/dev/null
if [ "$?" = 0 ]; then
echo ${BGreen}'Successfully'${NC}
else
whiptail --title "CAN-UTILS" --msgbox "ERROR Installing \nRestart installer!" 10 60
exit 0
fi
fi
if is_installed "can-utils"; then
if grep -q 'VERSION="10 (buster)"' /etc/os-release; then
if ! grep -q "auto can0" /etc/network/interfaces; then
cat <<'EOF' >> /etc/network/interfaces
auto can0
iface can0 inet manual
pre-up /sbin/ip link set can0 type can bitrate 100000
up /sbin/ifconfig can0 up
down /sbin/ifconfig can0 down
EOF
fi
else
cat <<'EOF' > /etc/systemd/network/80-can.network
[Match]
Name=can0
[CAN]
BitRate=100K
EOF
systemctl restart systemd-networkd &&
systemctl enable systemd-networkd
fi
fi
}
pythoncan() {
if is_installed "python-can"; then
echo ${BGreen}'Successfully'${NC}
else
echo ${BGreen}'Installing'${NC}
if grep -q 'VERSION="10 (buster)"' /etc/os-release; then
apt install -y python-can 2>/dev/null 1>/dev/null
if [ "$?" = 0 ]; then
echo ${BGreen}'Successfully'${NC}
else
whiptail --title "PYTHON-CAN" --msgbox "ERROR Installing \nRestart installer!" 10 60
exit 0
fi
else
apt install -y python3-can 2>/dev/null 1>/dev/null
if [ "$?" = 0 ]; then
echo ${BGreen}'Successfully'${NC}
else
whiptail --title "PYTHON-CAN" --msgbox "ERROR Installing \nRestart installer!" 10 60
exit 0
fi
fi
fi
}
overlay() {
if ! grep -q 'VERSION="10 (buster)"' /etc/os-release; then
if is_installed "overlayroot"; then
echo ${BGreen}'Successfully'${NC}
else
echo ${BGreen}'Installing Overlay SD card'${NC}
apt-get install -y overlayroot 2>/dev/null 1>/dev/null
if [ "$?" = 0 ]; then
echo ${BGreen}'Successfully'${NC}
else
whiptail --title "Overlay SD card" --msgbox "ERROR Installing \nRestart installer!" 10 60
exit 0
fi
fi
fi
}
usbmount() {
if grep -q 'VERSION="10 (buster)"' /etc/os-release; then
if is_installed "usbmount"; then
echo ${BGreen}'Successfully'${NC}
else
echo ${BGreen}'Installing USBMOUNT'${NC}
apt-get install -y usbmount 2>/dev/null 1>/dev/null
if [ "$?" = 0 ]; then
echo ${BGreen}'Successfully'${NC}
else
whiptail --title "USBMOUNT" --msgbox "ERROR Installing \nRestart installer!" 10 60
exit 0
fi
fi
if is_installed "usbmount"; then
version="$(dpkg-query --showformat="\${Version}" --show usbmount 2>&1)"
if ! [ "$version" = '0.0.24' ]; then
mkdir /home/pi/tmpu && cd /home/pi/tmpu
if ! [ -e /home/pi/tmpu/usbmount_0.0.24_all.deb ] ; then
wget -t 100 https://github.com/nicokaiser/usbmount/releases/download/0.0.24/usbmount_0.0.24_all.deb 2>/dev/null 1>/dev/null
fi
if [ -e /home/pi/tmpu/usbmount_0.0.24_all.deb ] ; then
dpkg -i usbmount_0.0.24_all.deb 2>/dev/null 1>/dev/null
cd /home/pi && rm -Rf /home/pi/tmpu
fi
sed -i 's/FS_MOUNTOPTIONS=""/FS_MOUNTOPTIONS="-fstype=vfat,iocharset=utf8,gid=1000,dmask=0007,fmask=0007"/' /etc/usbmount/usbmount.conf &&
sed -i 's/FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus"/FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus ntfs fuseblk"/' /etc/usbmount/usbmount.conf
fi
echo ${BGreen}$version${NC}
fi
fi
}
bluetooth() {
if is_installed "pulseaudio"; then
echo ${BGreen}'Pulseaudio Successfully'${NC}
else
hostnamectl set-hostname --pretty "rns"
apt install -y --no-install-recommends pulseaudio 2>/dev/null 1>/dev/null
if [ $? -eq 0 ]; then
echo ${BGreen}'Pulseaudio Successfully'${NC}
else
whiptail --title "PULSE AUDIO" --msgbox "ERROR Installing \nRestart installer!" 10 60
exit 0
fi
usermod -a -G pulse-access root
usermod -a -G bluetooth pulse
if ! grep -q '/run/pulse/native' /etc/pulse/client.conf; then
mv /etc/pulse/client.conf /etc/pulse/client.conf.orig
cat <<'EOF' >> /etc/pulse/client.conf
default-server = /run/pulse/native
autospawn = no
EOF
fi
sed -i '/^load-module module-native-protocol-unix$/s/$/ auth-cookie-enabled=0 auth-anonymous=1/' /etc/pulse/system.pa
cat <<'EOF' > /etc/systemd/system/pulseaudio.service
[Unit]
Description=Sound Service
[Install]
WantedBy=multi-user.target
[Service]
Type=notify
PrivateTmp=true
ExecStart=/usr/bin/pulseaudio --daemonize=no --system --disallow-exit --disable-shm --exit-idle-time=-1 --log-target=journal --realtime --no-cpu-limit
Restart=on-failure
EOF
systemctl enable --now pulseaudio.service
systemctl --global mask pulseaudio.socket
fi
if is_installed "bluez-tools"; then
echo ${BGreen}'\\nBluez-Tools Successfully'${NC}
else
echo ${BGreen}'\\nInstalling Bluez-Tools'${NC}
apt install -y --no-install-recommends bluez-tools 2>/dev/null 1>/dev/null
if [ $? -eq 0 ]; then
echo ${BGreen}'\\nSuccessfully'${NC}
else
whiptail --title "bluez-tools" --msgbox "ERROR Installing \nRestart installer!" 10 60
exit 0
fi
fi
if is_installed "pulseaudio-module-bluetooth"; then
echo ${BGreen}'\\nPulseaudio-Module-Bluetooth Successfully'${NC}
else
echo ${BGreen}'\\nInstalling Pulseaudio-Module-Bluetooth'${NC}
apt install -y --no-install-recommends pulseaudio-module-bluetooth 2>/dev/null 1>/dev/null
if [ ! $? -eq 0 ]; then
whiptail --title "pulseaudio-module-bluetooth" --msgbox "ERROR Installing \nRestart installer!" 10 60
exit 0
fi
cat <<'EOF' > /etc/bluetooth/main.conf
[General]
Class = 0x200414
DiscoverableTimeout = 0
[Policy]
AutoEnable=true
EOF
mkdir -p /etc/systemd/system/[email protected]
cat <<'EOF' > /etc/systemd/system/[email protected]/override.conf
[Service]
Type=oneshot
EOF
cat <<'EOF' > /etc/systemd/system/[email protected]
[Unit]
Description=Bluetooth Agent
Requires=bluetooth.service
After=bluetooth.service
[Service]
ExecStartPre=/usr/bin/bluetoothctl discoverable on
ExecStartPre=/bin/hciconfig %I piscan
ExecStartPre=/bin/hciconfig %I sspmode 1
ExecStart=/usr/bin/bt-agent --capability=NoInputNoOutput
RestartSec=5
Restart=always
KillSignal=SIGUSR1
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable [email protected]
usermod -a -G bluetooth pulse
if ! grep -q 'module-bluetooth-discover' /etc/pulse/system.pa; then
echo "load-module module-bluetooth-policy" >> /etc/pulse/system.pa
echo "load-module module-bluetooth-discover" >> /etc/pulse/system.pa
fi
fi
if ! grep -q 'bluetoothctl discoverable on' /usr/local/bin/bluetooth-udev; then
cat <<'EOF' > /usr/local/bin/bluetooth-udev
#!/bin/bash
if [[ ! $NAME =~ ^\"([0-9A-F]{2}[:-]){5}([0-9A-F]{2})\"$ ]]; then exit 0; fi
action=$(expr "$ACTION" : "\([a-zA-Z]\+\).*")
if [ "$action" = "add" ]; then
bluetoothctl discoverable off
fi
if [ "$action" = "remove" ]; then
bluetoothctl discoverable on
fi
EOF
chmod 755 /usr/local/bin/bluetooth-udev
cat <<'EOF' > /etc/udev/rules.d/99-bluetooth-udev.rules
SUBSYSTEM=="input", GROUP="input", MODE="0660"
KERNEL=="input[0-9]*", RUN+="/usr/local/bin/bluetooth-udev"
EOF
fi
if ! grep -q 'defaults.ctl.card 0' /etc/asound.conf; then
cat <<'EOF' > /etc/asound.conf
defaults.ctl.card 0
defaults.ctl.card 0
EOF
fi
}
skin_download() {
if grep -q 'VERSION="10 (buster)"' /etc/os-release; then
if ! [ -e /tmp/$SKIN$Ver.zip ] ; then
echo ${BGreen}'DOWNLOADING' $SKIN$Ver${NC}
wget -t 100 -P /tmp https://github.com/maltsevvv/repository-kodi/raw/master/kodi18/$SKIN/$SKIN$Ver.zip > /dev/null 2>&1
fi
elif grep -q 'VERSION="11 (bullseye)"' /etc/os-release; then
if ! [ -e /tmp/$SKIN$Ver.zip ] ; then
echo ${BGreen}'DOWNLOADING' $SKIN$Ver${NC}
wget -t 100 -P /tmp https://github.com/maltsevvv/repository-kodi/raw/master/kodi19/$SKIN/$SKIN$Ver.zip > /dev/null 2>&1
fi
elif grep -q 'VERSION="12 (bookworm)"' /etc/os-release; then
if ! [ -e /tmp/$SKIN$Ver.zip ] ; then
echo ${BGreen}'DOWNLOADING' $SKIN$Ver${NC}
wget -t 100 -P /tmp https://github.com/maltsevvv/repository-kodi/raw/master/kodi20/$SKIN/$SKIN$Ver.zip > /dev/null 2>&1
fi
fi
if ! [ -e /tmp/$REPOSITORY.zip ] ; then
echo ${BGreen}'\\nDOWNLOADING' $REPOSITORY.zip${NC}
wget -t 100 -P /tmp https://github.com/maltsevvv/repository-kodi/raw/master/$REPOSITORY.zip > /dev/null 2>&1
fi
}
skin_install() {
if [ -e /tmp/$SKIN$Ver.zip ] ; then
echo ${BGreen}'\\nUNZIP' $SKIN$Ver${NC}
unzip -o /tmp/$SKIN$Ver.zip -d $KODI > /dev/null 2>&1
fi
if [ -e /tmp/$REPOSITORY.zip ] ; then
echo ${BGreen}'\\nUNZIP' $REPOSITORY${NC}
unzip -o /tmp/$REPOSITORY.zip -d $KODI > /dev/null 2>&1
fi
}
kodi_set() {
if ! grep -q $SKIN /usr/share/kodi/system/addon-manifest.xml; then
echo ${BGreen}$SKIN '\\nto addon-manifest.xml'${NC}
sed -i -e '$i \ <addon optional="true">'$SKIN'</addon>' /usr/share/kodi/system/addon-manifest.xml
fi
if ! grep -q $REPOSITORY /usr/share/kodi/system/addon-manifest.xml; then
echo ${BGreen}$REPOSITORY '\\nto addon-manifest.xml'${NC}
sed -i -e '$i \ <addon optional="true">'$REPOSITORY'</addon>' /usr/share/kodi/system/addon-manifest.xml
fi
if ! grep -q $SKIN /home/pi/.kodi/userdata/guisettings.xml; then
echo ${BGreen}$SKIN '\\nto guisettings.xml'${NC}
sed -i -e 's/lookandfeel.skin" default="true">'$BaseSkin'/lookandfeel.skin">'$SKIN'/' /home/pi/.kodi/userdata/guisettings.xml
fi
echo ${BGreen}'Presettings KODI'${NC}
cat <<'EOF' > /home/pi/.kodi/userdata/sources.xml
<sources>
<programs>
<default pathversion="1"></default>
</programs>
<video>
<default pathversion="1"></default>
<source>
<name>movies</name>
<path pathversion="1">/home/pi/movies/</path>
<allowsharing>true</allowsharing>
</source>
<source>
<name>tvshows</name>
<path pathversion="1">/home/pi/tvshows/</path>
<allowsharing>true</allowsharing>
</source>
<source>
<name>clips</name>
<path pathversion="1">/home/pi/clips/</path>
<allowsharing>true</allowsharing>
</source>
<source>
<name>mults</name>
<path pathversion="1">/home/pi/mults/</path>
<allowsharing>true</allowsharing>
</source>
</video>
<music>
<default pathversion="1"></default>
<source>
<name>music</name>
<path pathversion="1">/home/pi/music/</path>
<allowsharing>true</allowsharing>
</source>
</music>
<pictures>
<default pathversion="1"></default>
</pictures>
<files>
<default pathversion="1"></default>
<source>
<name>192.168.1.3</name>
<path pathversion="1">smb://192.168.1.3/</path>
<allowsharing>true</allowsharing>
</source>
<source>
<name>pi</name>
<path pathversion="1">/home/pi/</path>
<allowsharing>true</allowsharing>
</source>
</files>
<games>
<default pathversion="1"></default>
</games>
</sources>
EOF
if grep -q 'VERSION="12 (bookworm)"' /etc/os-release; then
# Disable Screensaver
sed -i 's/default="true">screensaver.xbmc.builtin.dim<\/setting/\//' /home/pi/.kodi/userdata/guisettings.xml
# Enable auto play next video
#sed -i 's/id="videoplayer.autoplaynextitem" default="true" \/>id="videoplayer.autoplaynextitem">0,1,2,3,4<\/setting>/' /home/pi/.kodi/userdata/guisettings.xml
else
# Disable Screensaver
sed -i 's/id="screensaver.mode" default="true">screensaver.xbmc.builtin.dim/id="screensaver.mode">/' /home/pi/.kodi/userdata/guisettings.xml
sed -i 's/id="screensaver.mode" default="true">default/id="screensaver.mode">/' /home/pi/.kodi/userdata/guisettings.xml
# Enable auto play next video
sed -i 's/id="videoplayer.autoplaynextitem" default="true">/id="videoplayer.autoplaynextitem">0,1,2,3,4/' /home/pi/.kodi/userdata/guisettings.xml
fi
# Amplifi volume up to 30.0dB
sed -i 's/volumeamplification>0.000000/volumeamplification>30.000000/' /home/pi/.kodi/userdata/guisettings.xml
# Enable web-server
sed -i 's/id="services.webserverauthentication" default="true">true/id="services.webserverauthentication">false/' /home/pi/.kodi/userdata/guisettings.xml
sed -i 's/id="services.webserver" default="true">false/id="services.webserver">true/' /home/pi/.kodi/userdata/guisettings.xml
}
folder() {
echo ${BGreen}'Media Folder: '${NC}
if ! [ -d /home/pi/movies ] ; then
echo ${BGreen}"movies"${NC}
mkdir /home/pi/movies && chmod -R 0777 /home/pi/movies
else
echo ${BGreen}"movies"${NC}
fi
if ! [ -d /home/pi/tvshows ] ; then
echo ${BGreen}"tvshows"${NC}
mkdir /home/pi/tvshows && chmod -R 0777 /home/pi/tvshows
else
echo ${BGreen}"tvshows"${NC}
fi
if ! [ -d /home/pi/clips ] ; then
echo ${BGreen}"clips"${NC}
mkdir /home/pi/clips && chmod -R 0777 /home/pi/clips
else
echo ${BGreen}"clips"${NC}
fi
if ! [ -d /home/pi/music ] ; then
echo ${BGreen}"music"${NC}
mkdir /home/pi/music && chmod -R 0777 /home/pi/music
else
echo ${BGreen}"music"${NC}
fi
chown -R pi:pi /home/pi/
}
if [ -e /boot/firmware/config.txt ] ; then
FIRMWARE=/firmware
else
FIRMWARE=
fi
CONFIG=/boot${FIRMWARE}/config.txt
if [ -e /boot/firmware/cmdline.txt ] ; then
FIRMWARE=/firmware
else
FIRMWARE=
fi
CMDLINE=/boot${FIRMWARE}/cmdline.txt
rpi_conf() {
if ! [ -e $CONFIG'_original.txt' ] ; then
cp $CONFIG $CONFIG'_original.txt'
fi
if ! [ -e $CMDLINE'_original.txt' ] ; then
cp $CMDLINE $CMDLINE'_original.txt'
fi
}
rpi_vga() {
echo $(rpi_conf)
if ! grep -q 'VERSION="10 (buster)"' /etc/os-release; then
sed -i -r 's/.+(console=serial0)/\1/' $CMDLINE # Del Analog Video
sed -i -r 's/(.+) vc4.tv_norm.+/\1/' $CMDLINE # Del Analog Video
if grep -q 'Raspberry Pi 4\|Raspberry Pi 5' $ModelPI; then
if ! [ -e /usr/lib/firmware/Rpi480i_EDID.bin ] ; then
echo ${BGreen}'Downloads Rpi480i'${NC}
wget -t 100 -P /tmp https://github.com/maltsevvv/repository-kodi/raw/master/old_install/Rpi480i_EDID.bin && > /dev/null 2>&1
cp /tmp/Rpi480i_EDID.bin /usr/lib/firmware/Rpi480i_EDID.bin
fi
if ! grep -q 'video=HDMI-A-1:NTSC' $CMDLINE; then
sed -i 's/^/video=HDMI-A-1:NTSC,margin_left=29,margin_right=10,margin_top=0,margin_bottom=15 /' $CMDLINE
fi
if ! grep -q 'Rpi480i_EDID.bin' $CMDLINE; then
sed -i 's/$/ drm.edid_firmware=HDMI-A-1:Rpi480i_EDID.bin/' $CMDLINE
fi
if ! grep -q 'hdmi_timings=' $CONFIG; then # Add For HDMI
sed -i '/disable_overscan=1/a\hdmi_timings=640 0 16 88 64 480 0 6 5 13 0 0 0 60 1 12700000 3' $CONFIG # Add load serial For HDMI
fi
fi
if ! grep -q 'hdmi_mode=87' $CONFIG; then # Add For HDMI
sed -i '/disable_overscan=1/a\hdmi_mode=87' $CONFIG # Add load serial For HDMI
fi
if ! grep -q 'hdmi_group=2' $CONFIG; then # Add For HDMI
sed -i '/disable_overscan=1/a\hdmi_group=2' $CONFIG # Add load serial For HDMI
fi
fi
sed -i 's/^#\?#disable_overscan=1/disable_overscan=1/' $CONFIG # Edit For HDMI
sed -i 's/^#\?hdmi_force_hotplug=1/hdmi_force_hotplug=1/' $CONFIG # Edit For HDMI
sed -i 's/^#\?hdmi_group=.*/hdmi_group=2/' $CONFIG # Edit For HDMI
sed -i 's/^#\?hdmi_mode=.*/hdmi_mode=87/' $CONFIG # Edit For HDMI
sed -i 's/^#\?enable_tvout=.*/#enable_tvout=1/' $CONFIG # Del Analog Video
sed -i -r 's/(.+),composite/\1/' $CONFIG # Del Analog Video
if ! grep -q 'hdmi_timings=' $CONFIG; then # Add For HDMI
if grep -q 'Raspberry Pi 4\|Raspberry Pi 5' $ModelPI; then
sed -i '/hdmi_mode=/a\hdmi_timings=640 0 16 88 64 480 0 6 5 13 0 0 0 60 1 12700000 3' $CONFIG
else
sed -i 's/^#\?dtoverlay=vc4-kms-.*/dtoverlay=vc4-fkms-v3d/' $CONFIG
sed -i '/hdmi_mode=/a\hdmi_timings=800 0 51 44 121 460 0 10 9 14 0 0 0 32 1 16000000 3' $CONFIG
fi
fi
}
rpi_composite() {
echo $(rpi_conf)
sed -i 's/^#\?disable_overscan=1/#disable_overscan=1/' $CONFIG # Edit For Analog
sed -i 's/^#\?hdmi_force_hotplug=1/#hdmi_force_hotplug=1/' $CONFIG # Edit For Analog
sed -i 's/^#\?hdmi_group=.*/#hdmi_group=1/' $CONFIG # Edit For Analog
sed -i 's/^#\?hdmi_mode=.*/#hdmi_mode=1/' $CONFIG # Edit For Analog
sed -i "/.*hdmi_timings=.*/d" $CONFIG # Del HDMI
sed -i -r 's/.+(console=serial0)/\1/' $CMDLINE # Del HDMI
sed -i -r 's/(.+) drm.edid.+/\1/' $CMDLINE # Del HDMI
if ! grep -q 'VERSION="10 (buster)"' /etc/os-release; then
if ! grep -q 'Composite-1' $CMDLINE; then
sed -i "s/^/video=Composite-1:720x576@50ie /" $CMDLINE
#video=Composite-1:720x480@60ie
fi
if ! grep -q 'vc4.tv_norm=' $CMDLINE; then
sed -i "s/$/ vc4.tv_norm=PAL/" $CMDLINE
#vc4.tv_norm=NTSC
fi
sed -i 's/^#\?dtoverlay=vc4-kms-v3d.*/dtoverlay=vc4-kms-v3d,composite/' $CONFIG
if ! grep -q 'enable_tvout' $CMDLINE; then
sed -i '/dtoverlay=vc4-kms-v3d/a\enable_tvout=1' $CONFIG
fi
fi
if grep -q 'VERSION="10 (buster)"' /etc/os-release; then
sed -i 's/^#\?sdtv_mode=.*/sdtv_mode=2/' $CONFIG
if ! grep -q 'sdtv_aspect' $CMDLINE; then
sed -i '/sdtv_mode=/a\sdtv_aspect=1' $CONFIG
fi
fi
}
rpi_audio() {
echo $(rpi_conf)
sed -i 's/^#\?dtparam=audio=on/dtparam=audio=on/' $CONFIG
sed -i "/.*hifiberry-dac.*/d" $CONFIG
}
rpi_pcm() {
echo $(rpi_conf)
sed -i 's/^#\?dtparam=audio=on/#dtparam=audio=on/' $CONFIG
if ! grep -q 'hifiberry-dac' $CONFIG; then
sed -i '/dtparam=audio/a\dtoverlay=hifiberry-dac' $CONFIG
fi
}
rpi_can0() {
echo $(rpi_conf)
if ! grep -q 'mcp2515-can0' $CONFIG; then
sed -i 's/^#\?dtparam=spi=on/dtparam=spi=on/' $CONFIG
if grep -q 'Raspberry Pi 4\|Raspberry Pi 5' $ModelPI; then
cat <<'EOF' >> $CONFIG
# MCP2515-Can0 oscillator=8000000 or 16000000 and GPIO=25
dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=25
dtoverlay=spi-bcm2837
EOF
else
cat <<'EOF' >> $CONFIG
# MCP2515-can0 oscillator=8000000 or 16000000 and GPIO=25
dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=25
dtoverlay=spi-bcm2835-overlay
EOF
fi
fi
}
rpi_ir() {
apt purge lirc > /dev/null 2>&1
rm -r /etc/lirc > /dev/null 2>&1
if is_installed "ir-keytable"; then
echo ${BGreen}'\\nSuccessfully'${NC}
else
echo ${BGreen}'Installing ir-keytable'${NC}
apt install -y ir-keytable > /dev/null 2>&1
if [ ! $? -eq 0 ]; then
whiptail --title "IR-Keytable" --msgbox "ERROR Installing \nRestart installer!" 10 60
exit 0
fi
fi
if [ -e /etc/rc_keymaps/nec_rnsjp3.toml ] ; then
cat <<'EOF' > /etc/rc_keymaps/nec_rnsjp3.toml
[[protocols]]
name = "nec_rnsjp3"
protocol = "nec"
[protocols.scancodes]
0x98 = "KEY_STOP"
0x89 = "KEY_ENTER"
0x8a = "KEY_BACK"
0x94 = "KEY_UP"
0x8e = "KEY_DOWN"
0x8d = "KEY_LEFT"
0x8c = "KEY_RIGHT"
0x92 = "KEY_STOP"
0x96 = "KEY_I"
0x97 = "KEY_C"
0x9b = "KEY_PREVIOUSSONG"
0x87 = "KEY_NEXTSONG"
EOF
mv /etc/rc_maps.cfg /etc/rc_maps.cfg.orig
cat <<'EOF' > /etc/rc_maps.cfg
#driver table file
* rc-rc6-mce nec_rnsjp3.toml
EOF
fi
}
echo '---------------------------------------------------------'
echo ${BBlue}'Internet connection'${NC}
echo $(network)
echo '---------------------------------------------------------'
echo '---------------------------------------------------------'
echo ${BBlue}'Update Packets'${NC}
echo $(update)
echo '---------------------------------------------------------'
echo '---------------------------------------------------------'
if (whiptail --title "FULL UPGRADE SYSTEM" --yesno "Installation is Recommended.\nBut it will take a long time" 10 60); then
echo ${BBlue}'Upgrade System'${NC}
echo $(upgrade)
else
echo ${BRed}'YOU CANCELED UPGRADE SYSTEM'${NC}
fi
echo '---------------------------------------------------------'
echo '---------------------------------------------------------'
echo ${BBlue}'SAMBA Installed'${NC}
echo $(samba)
echo '---------------------------------------------------------'
echo '---------------------------------------------------------'
echo ${BBlue}'Installed KODI'${NC}
echo $(kodi)
echo '---------------------------------------------------------'
echo '---------------------------------------------------------'
echo ${BBlue}'Installed CAN-UTILS'${NC}
echo $(canutils)
echo '---------------------------------------------------------'
echo '---------------------------------------------------------'
echo ${BBlue}'Installed PYTHON-CAN'${NC}
echo $(pythoncan)
echo '---------------------------------------------------------'
echo '---------------------------------------------------------'
echo ${BBlue}'Installed Overlay SD card'${NC}
echo $(overlay)
echo '---------------------------------------------------------'
echo '---------------------------------------------------------'
echo ${BBlue}'Installed USBMOUNT'${NC}
echo $(usbmount)
echo '---------------------------------------------------------'
echo '---------------------------------------------------------'
if (whiptail --title "Bluetooth audio receiver installer" --yesno "Install Bluetooth Audio Receive." 10 60) then
echo ${BBlue}'Installing BLUETOOTHE RECIEVER'${NC}
echo $(bluetooth)
else
echo ${BRed}'YOU CANCELED THE INSTALLATION BLUETOOTH RECIEVER'${NC}
fi
echo '---------------------------------------------------------'
echo '---------------------------------------------------------'
echo $(kodi_status) &&
echo $(skin_download)
echo $(skin_install)
echo $(kodi_set)
echo '---------------------------------------------------------'
echo '---------------------------------------------------------'
echo $(folder)
echo '---------------------------------------------------------'
echo '---------------------------------------------------------'
if (whiptail --title "Video Output" --yes-button " HDMI-VGA " --no-button " ANALOG VIDEO " --yesno "Select video output source" 10 60); then
echo ${BGreen}"Use HDMI-VGA Adapter For Video Output"${NC}
echo $(rpi_vga)
if ! grep -q 'VERSION="10 (buster)"' /etc/os-release; then
echo ${BRed}$CMDLINE${NC} '\nvideo=HDMI-A-1:'${BBlue}'NTSC\n'${NC}
echo ${BRed}$CMDLINE${NC} '\ndrm.edid_firmware=HDMI-A-1:Rpi480i_EDID.bin'
fi
else
echo ${BGreen}"Use Analog Video Output Jack 3,5mm"${NC}
$(rpi_composite)
if ! grep -q 'VERSION="10 (buster)"' /etc/os-release; then
echo ${BRed}$CMDLINE${NC} '\nvc4.tv_norm='${BBlue}'PAL'${NC} ${BBlue}'\nNTSC'${NC} '|' ${BBlue}'PAL\n'${NC}
echo ${BRed}$CMDLINE${NC} '\nvideo=Composite-1:'${BBlue}'720x576@50ie'${NC} ${BBlue}'\n720x576@50ie'${NC} 'for' ${BGreen}'PAL'${NC} ${BBlue}'\n720x480@60ie'${NC} 'for' ${BGreen}'NTSC\n'${NC}
elif grep -q 'VERSION="10 (buster)"' /etc/os-release; then
echo ${BRed}$CONFIG${NC} 'sdtv_mode='${BBlue}'2'${NC} ${BBlue}'\n0'${NC} 'NTSC |' ${BBlue}'1'${NC} 'NTSC JAPAN |' ${BBlue}'2'${NC} 'PAL |' ${BBlue}'3'${NC} 'PAL BRAZIL\n'${NC}
echo ${BRed}$CONFIG${NC} 'sdtv_aspect='${BBlue}'1'${NC} ${BBlue}'\n1'${NC} '4:3 |' ${BBlue}'2'${NC} '14:9 |' ${BBlue}'3'${NC} '16:9'
fi
fi
echo '---------------------------------------------------------'
echo '---------------------------------------------------------'
if (whiptail --title "AUDIO Output" --yes-button " PCM5102 " --no-button " ANALOG " --yesno "Select Audio output source" 10 60); then
echo ${BGreen}'Use Digital (PCM5102) Audio Output Jack 3,5mm'${NC}
echo $(rpi_pcm)
else
echo ${BGreen}'Use Analog Audio Output Jack 3,5mm'${NC}
echo $(rpi_audio)
fi
echo '---------------------------------------------------------'
echo '---------------------------------------------------------'
echo ${BGreen}'Enable mcp2515-can0'${NC}
echo $(rpi_can0)
echo '---------------------------------------------------------'
echo '---------------------------------------------------------'
echo ${BGreen}'Installed IR-Keytable'${NC}
if (whiptail --title "IR Remote Control" --yesno "Enable IR-Receiver? \nfor Control Kodi, FOR RNS-JP3 \nWARNING!!!! ONLY FOR RNS-JP3 (Asian)" 10 60); then
echo $(rpi_ir)
sed -i 's/^#\?dtoverlay=gpio-ir,gpio_pin=17/dtoverlay=gpio-ir,gpio_pin=17/' $CONFIG
else
sed -i 's/^#\?dtoverlay=gpio-ir,gpio_pin=17/#dtoverlay=gpio-ir,gpio_pin=17/' $CONFIG
fi
echo '---------------------------------------------------------'
echo '---------------------------------------------------------'
echo '\\\\'$(hostname -I | awk '{print $1}')'\\''rns'
echo '\\\\'$(hostname -I | awk '{print $2}')'\\''rns'
echo '---------------------------------------------------------'
echo '---------------------------------------------------------'
if (whiptail --title "Installation Completed" --yesno "Reboot System Now\nIf everything is fine, then after the reboot \nyou will see a window for entering the activation code" 10 60); then
echo "Reboot System"
reboot
fi
echo '---------------------------------------------------------'