-
Notifications
You must be signed in to change notification settings - Fork 0
/
rrk.sh
1131 lines (1033 loc) · 41.7 KB
/
rrk.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
#
# rrk.sh roraspbiankodi
#
ACTIONIS=$1
function firstbootupgrades {
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
}
function performancetweaks {
echo "vm.swappiness=1" | sudo tee -a /etc/sysctl.conf
head -n 19 /etc/rc.local | sudo tee /etc/rc.local
echo "sudo echo \"performance\" | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" | sudo tee -a /etc/rc.local
echo "exit 0" | sudo tee -a /etc/rc.local
sudo systemctl stop triggerhappy #timer or service or socket?
sudo systemctl disable triggerhappy
sudo systemctl stop apt-daily.timer
sudo systemctl disable apt-daily.timer
sudo systemctl stop apt-daily-upgrade.timer
sudo systemctl disable apt-daily-upgrade.timer
#disable ipv6
sudo sed -i "s/wait/wait ipv6.disable=1 usbcore.autosuspend=-1 usbcore.autosuspend_delay_ms=0/g" /boot/cmdline.txt
sudo tee /etc/modprobe.d/ipv6.conf <<_EOF_
alias net-pf-10 off
options ipv6 disable_ipv6=1
blacklist ipv6
_EOF_
#set gpu/cpu memory split
sudo tee -a /boot/config.txt <<_EOF_
#start_x=1
gpu_mem_256=112
gpu_mem_512=160
gpu_mem_1024=256
#1080p50
disable_overscan=1
hdmi_drive=2
hdmi_group=1
hdmi_mode=31
#hdmi_pixel_encoding=0
#uncomment following single line for enabling single IR receiver
#dtoverlay=gpio-ir
#uncomment following 3 lines for PiFi DAC+ v2.0 with builtin IR receiver
#dtparam=i2s=on
#dtoverlay=hifiberry-dacplus
#dtoverlay=gpio-ir,gpio_pin=26
_EOF_
#vcgencmd get_mem arm && vcgencmd get_mem gpu #check memory split
#cron reschedule to midnight
sudo sed -i "s/17 \*/17 3/g" /etc/crontab
sudo sed -i "s/25 6/25 3/g" /etc/crontab
sudo sed -i "s/47 6/47 3/g" /etc/crontab
sudo sed -i "s/52 6/52 3/g" /etc/crontab
}
function setlocaldefaults {
#Can be set later on boot partition with help os pfixtz.sh
sudo sed -i "s/gb/us/g" /etc/default/keyboard
sudo timedatectl set-timezone Europe/Amsterdam
#timedate-ctl list-timezones
}
function extraconfigs {
#/boot partition config files for overiding readonly system and kodi behaviour
sudo mkdir /boot/settings
#persistent keyboard language/layout config
sudo mv /etc/default/keyboard /boot/settings/keyboard
sudo ln -s /boot/settings/keyboard /etc/default/keyboard
sudo tee -a /boot/settings/KODIRDF.txt <<_EOF_
#Uncomment a single regional format for correct clock/date/temperature notation!
#Australia (12h)
#Australia (24h)
#Canada
Central Europe
#India (12h)
#India (24h)
#UK (12h)
#UK (24h)
#USA (12h)
#USA (24h)
_EOF_
sudo tee -a /boot/settings/TIMEZONE.txt <<_EOF_
Uncomment single Timezone/Country/Region notice Europe/Amsterdam is uncommented!
_EOF_
sudo timedatectl list-timezones >> /boot/settings/TIMEZONE.txt
sudo sed -i 's|^|#|' /boot/settings/TIMEZONE.txt
sudo sed -i 's|#Europe/Amsterdam|Europe/Amsterdam|' /boot/settings/TIMEZONE.txt
sudo tee -a /boot/settings/HTSCONF.txt <<_EOF_
#TVHeadend Credentials uncomment&edit HTSNFSF for nfsshare folder on HTSSERV
HTSUSER=exampleuser
HTSPASS=examplepass
HTSSERV=exampleipaddress
HTSWOLM=examplemacaddress
HTSHTTP=9981
HTSHTSP=9982
#HTSNFSF=/mnt/sdb1/tvherecordings
_EOF_
sudo tee -a /boot/settings/PVRTYPE.txt <<_EOF_
#Uncomment only a single kodi PVR frontend: 'none' is default
none
#tvheadend
#hdhomerun
#itsclient
_EOF_
sudo tee -a /boot/settings/ISCCONF.txt <<_EOF_
#Uncomment only a single iptvsimpleclient setting: 'remote' or 'local' is default
local=/boot/settings/playlist.m3u
#remote=http://example.io/atom.m3u
_EOF_
sudo tee -a /boot/settings/playlist.m3u <<_EOF_
#EXTM3U
#EXTINF:-1 channelname01
http://null.example.m3u8
#EXTINF:-1,channelname02
rtmp://null.example
_EOF_
sudo tee -a /boot/settings/AUDIOout.txt <<_EOF_
#Uncomment only a single audio output as in: HDMI, Analogue, Both, DAC, HDMIPASS
#Note that hdmi dolbydigital/dts passthrough won't work with pvr-live tv in 17.x
HDMI
#Analogue
#Both
#DAC
#HDMIPASS
_EOF_
sudo tee -a /boot/settings/WIFI.txt <<_EOF_
#Just complete '/boot/wpa_supplicant.conf' with the following example code below
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=UK
network={
ssid="example"
psk="example"
key_mgmt=WPA-PSK
}
_EOF_
sudo tee -a /boot/wpa_supplicant.conf <<_EOF_
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
_EOF_
#persistent fix wpa_supplicant for readonly behaviour
sudo rm /etc/wpa_supplicant/wpa_supplicant.conf
sudo ln -s /boot/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf
sudo systemctl disable raspberrypi-net-mods.service
#persistent allow static ip setup in /boot/settings
sudo cp /etc/dhcpcd.conf /boot/settings/
sudo rm /etc/dhcpcd.conf
sudo ln -s /boot/settings/dhcpcd.conf /etc/dhcpcd.conf
cat <<'_EOF_' > /home/pi/setpvr.sh
#!/bin/bash
#Overwrite Addons27.db database for enforcing a single active kodi PVR frontend
case $(cat /boot/settings/PVRTYPE.txt | grep -v '#') in
none)
echo "[ OK ] setpvr.sh no pvr addon selected"
cp /home/pi/nonAddons27.db /tmp/kodirw/userdata/Database/Addons27.db
;;
tvheadend)
echo "[ OK ] setpvr.sh sets tvheadend"
cp /home/pi/htsAddons27.db /tmp/kodirw/userdata/Database/Addons27.db
/home/pi/sethts.sh
/home/pi/setnfs.sh
;;
hdhomerun)
echo "[ OK ] setpvr.sh sets hdhomerun"
cp /home/pi/hhrAddons27.db /tmp/kodirw/userdata/Database/Addons27.db
;;
itsclient)
echo "[ OK ] setpvr.sh sets iptvsimpleclient"
cp /home/pi/iscAddons27.db /tmp/kodirw/userdata/Database/Addons27.db
/home/pi/setisc.sh
;;
esac
_EOF_
chmod +x /home/pi/setpvr.sh
sudo apt-get -y install wakeonlan
cat <<'_EOF_' > /home/pi/sethts.sh
#!/bin/bash
#Parce /boot/settings for setting up pvr-hts tvheadend frontend
HTSWOLM=$(cat /boot/settings/HTSCONF.txt | grep -v '#' | grep HTSWOLM | sed -e 's/HTSWOLM=//g' -)
wakeonlan $HTSWOLM
HTSSERV=$(cat /boot/settings/HTSCONF.txt | grep -v '#' | grep HTSSERV | sed -e 's/HTSSERV=//g' -)
sed -i -e "s/192.168.123.123/$HTSSERV/g" /tmp/kodirw/userdata/addon_data/pvr.hts/settings.xml
HTSUSER=$(cat /boot/settings/HTSCONF.txt | grep -v '#' | grep HTSUSER | sed -e 's/HTSUSER=//g' -)
sed -i -e "s/htsu/$HTSUSER/g" /tmp/kodirw/userdata/addon_data/pvr.hts/settings.xml
HTSPASS=$(cat /boot/settings/HTSCONF.txt | grep -v '#' | grep HTSPASS | sed -e 's/HTSPASS=//g' -)
sed -i -e "s/htsw/$HTSPASS/g" /tmp/kodirw/userdata/addon_data/pvr.hts/settings.xml
HTSHTTP=$(cat /boot/settings/HTSCONF.txt | grep -v '#' | grep HTSHTTP | sed -e 's/HTSHTTP=//g' -)
sed -i -e "s/9981/$HTSHTTP/g" /tmp/kodirw/userdata/addon_data/pvr.hts/settings.xml
HTSHTSP=$(cat /boot/settings/HTSCONF.txt | grep -v '#' | grep HTSHTSP | sed -e 's/HTSHTSP=//g' -)
sed -i -e "s/9982/$HTSHTSP/g" /tmp/kodirw/userdata/addon_data/pvr.hts/settings.xml
_EOF_
chmod +x /home/pi/sethts.sh
cat <<'_EOF_' > /home/pi/setisc.sh
#!/bin/bash
#Parce /boot/settings for selecting local/remote url for pvr-iptvsimple frontend
case $(cat /boot/settings/ISCCONF.txt | grep -v '#' | sed -e 's/=.*//' -) in
local)
echo "[ OK ] setisc.sh sets iptvsimpleclient local"
cp /home/pi/kodiro/userdata/addon_data/pvr.iptvsimple/locsettings.xml /tmp/kodirw/userdata/addon_data/pvr.iptvsimple/settings.xml
REPM3U=$(cat /boot/settings/ISCCONF.txt | grep -v '#' | sed -e 's/.*=//' -)
sed -i -e "s|replacem3u|$REPM3U|g" /tmp/kodirw/userdata/addon_data/pvr.iptvsimple/settings.xml
;;
remote)
echo "[ OK ] setisc.sh sets iptvsimpleclient remote"
cp /home/pi/kodiro/userdata/addon_data/pvr.iptvsimple/remsettings.xml /tmp/kodirw/userdata/addon_data/pvr.iptvsimple/settings.xml
REPURL=$(cat /boot/settings/ISCCONF.txt | grep -v '#' | sed -e 's/.*=//' -)
sed -i -e "s|replaceurl|$REPURL|g" /tmp/kodirw/userdata/addon_data/pvr.iptvsimple/settings.xml
;;
esac
_EOF_
chmod +x /home/pi/setisc.sh
cat <<'_EOF_' > /home/pi/setaudio.sh
#!/bin/bash
#Parce /boot/settings for setting up audio output in kodi
case $(cat /boot/settings/AUDIOout.txt | grep -v '#') in
HDMI)
echo "[ OK ] setaudio.sh sets PI:HDMI"
#default needs nothing
;;
Analogue)
echo "[ OK ] setaudio.sh sets PI:Analogue"
#change guisettings.xml?
sed -i 's/ default="true">PI:HDMI/>PI:Analogue/g' /tmp/kodirw/userdata/guisettings.xml
;;
Both)
echo "[ OK ] setaudio.sh sets PI:Both"
#change guisettings.xml?
sed -i 's/ default="true">PI:HDMI/>PI:Both/g' /tmp/kodirw/userdata/guisettings.xml
;;
DAC)
echo "[ OK ] setaudio.sh sets external DAC"
#change guisettings.xml ALSA?
sed -i 's/ default="true">PI:HDMI/>ALSA:@/g' /tmp/kodirw/userdata/guisettings.xml
cp /home/pi/alsa.conf /tmp/alsa.conf
sudo sed -i "s/defaults.ctl.card 0/defaults.ctl.card 1/g" /tmp/alsa.conf
sudo sed -i "s/defaults.pcm.card 0/defaults.pcm.card 1/g" /tmp/alsa.conf
;;
HDMIPASS)
echo "[ OK ] setaudio.sh sets PI:HDMI (E)AC3/DTS PASSTHROUGH"
#change guisettings.xml ALSA?
sed -i 's|<passthrough default="true">false</passthrough>|<passthrough>true</passthrough>|g' /tmp/kodirw/userdata/guisettings.xml
sed -i 's|<eac3passthrough default="true">false</eac3passthrough>|<eac3passthrough>true</eac3passthrough>|g' /tmp/kodirw/userdata/guisettings.xml
sed -i 's|<dtspassthrough default="true">false</dtspassthrough>|<dtspassthrough>true</dtspassthrough>|g' /tmp/kodirw/userdata/guisettings.xml
;;
esac
_EOF_
chmod +x /home/pi/setaudio.sh
#persistent audio changes to allow settings by /boot/settings
cp /usr/share/alsa/alsa.conf /home/pi/alsa.conf
sudo rm /usr/share/alsa/alsa.conf
sudo ln -s /tmp/alsa.conf /usr/share/alsa/alsa.conf
cat <<'_EOF_' > /home/pi/setnfs.sh
#!/bin/bash
#Parce /boot/settings for enabling nfsshare based on TVHeadend HTS variables
case $(cat /boot/settings/HTSCONF.txt | grep -v '#' | grep HTSNFSF | sed -e 's/=.*//' -) in
HTSNFSF)
echo "[ OK ] setnfs.sh sets nfsshare active"
#get nfs server ip
NFSSERV=$(cat /boot/settings/HTSCONF.txt | grep -v '#' | grep HTSSERV | sed -e 's/.*=//' -)
#get nfs server folder
NFSFOLD=$(cat /boot/settings/HTSCONF.txt | grep -v '#' | grep HTSNFSF | sed -e 's/.*=//' -)
sudo mkdir /tmp/nfsshare
sudo mount -t nfs -o proto=tcp $NFSSERV:$NFSFOLD /tmp/nfsshare/
#Create a kodi source for the nfsshare folder
cat <<'_FOE_' > /tmp/kodirw/userdata/sources.xml
<sources>
<programs>
<default pathversion="1"></default>
</programs>
<video>
<default pathversion="1"></default>
<source>
<name>TVHE-Recordings</name>
<path pathversion="1">/tmp/nfsshare/</path>
<allowsharing>false</allowsharing>
</source>
</video>
<music>
<default pathversion="1"></default>
</music>
<pictures>
<default pathversion="1"></default>
</pictures>
<files>
<default pathversion="1"></default>
</files>
</sources>
_FOE_
;;
esac
_EOF_
chmod +x /home/pi/setnfs.sh
cat <<'_EOF_' > /home/pi/setrdf.sh
#!/bin/bash
#set kodi regional default format
DTZ=$(cat /boot/settings/TIMEZONE.txt | grep -v '#')
KRDF=$(cat /boot/settings/KODIRDF.txt | grep -v '#')
#<timezone default="true">Europe/Amsterdam</timezone>
#<country>Central Europe</country>
sed -i -e "s|Europe/Amsterdam|$DTZ|g" /tmp/kodirw/userdata/guisettings.xml
sed -i -e "s/Central Europe/$KRDF/g" /tmp/kodirw/userdata/guisettings.xml
_EOF_
chmod +x /home/pi/setrdf.sh
cat <<'_EOF_' > /home/pi/pfixtz.sh
#!/bin/bash
# login with ssh on pi to permanent fix timezone with rw rootfs access
# manually sudo dpkg-reconfigure tzdata
# sudo timedatectl set-timezone X/Y
# symlink /etc/localtime to /usr/share/zoneinfo/X/Y binary file
# /etc/timezone ascii readable
sudo systemctl stop kodi
sleep 5
sudo mount -o remount,rw /
sleep 5
DTZ=$(cat /boot/settings/TIMEZONE.txt | grep -v '#')
KRDF=$(cat /boot/settings/KODIRDF.txt | grep -v '#')
sudo timedatectl set-timezone $DTZ
sync
sudo timedatectl set-timezone $DTZ
sync
sudo mount -o remount,ro /
sudo reboot;exit
_EOF_
chmod +x /home/pi/pfixtz.sh
}
function installkodi {
sudo apt-get -y install kodi kodi-pvr-hts kodi-pvr-hdhomerun kodi-pvr-iptvsimple kodi-peripheral-joystick kodi-inputstream-adaptive kodi-inputstream-rtmp cec-utils
#Create a kodi service https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=192499
sudo tee -a /lib/systemd/system/kodi.service <<_EOF_
[Unit]
Description = Kodi Media Center
After = remote-fs.target network-online.target
Wants = network-online.target
[Service]
User = pi
Group = pi
Type = simple
ExecStart = /usr/bin/kodi
Restart = on-abort
RestartSec = 5
[Install]
WantedBy = multi-user.target
_EOF_
#Start kodi first time to setup user profile folder structure
sudo systemctl enable kodi.service
sudo systemctl disable kodi.service
#Allow shutdown/reboot from kodi https://yingtongli.me/blog/2016/12/23/kodi-power.html
sudo tee -a /etc/polkit-1/localauthority/50-local.d/all_users_shutdown_reboot.pkla <<_EOF_
[Allow all users to shutdown and reboot]
Identity=unix-user:*
Action=org.freedesktop.login1.*;org.freedesktop.upower.*;org.freedesktop.consolekit.system.*
ResultActive=yes
ResultAny=yes
ResultInactive=yes
_EOF_
#cat /etc/systemd/system/multi-user.target.wants/kodi.service
#ls /etc/polkit-1/localauthority/
#cat /etc/polkit-1/localauthority/50-local.d/all_users
#sudo cat /etc/polkit-1/localauthority/50-local.d/all_users
#sudo cat /etc/polkit-1/localauthority/50-local.d/all_user_shutdown_reboot.pkla
# Start kodi once to allow it to create default .kodi folder and settings don't
# don't use/setup kodi gui yet, wait until this script ends and lookat prepare!
sudo systemctl start kodi.service
echo "Starting kodi to setup defaults, do not configure it yet"
echo "............Kodi will auto close in 60 seconds.........."
sleep 60
sudo systemctl stop kodi.service
#Template with unique variables to be patched by /boot/settings pvr-hts parcing
mkdir /home/pi/.kodi/userdata/addon_data/pvr.hts
tee /home/pi/.kodi/userdata/addon_data/pvr.hts/settings.xml <<_EOF_
<settings>
<setting id="autorec_approxtime" value="0" />
<setting id="autorec_maxdiff" value="15" />
<setting id="connect_timeout" value="10" />
<setting id="dvr_dubdetect" value="0" />
<setting id="dvr_lifetime" value="8" />
<setting id="dvr_priority" value="2" />
<setting id="epg_async" value="false" />
<setting id="host" value="192.168.123.123" />
<setting id="htsp_port" value="9982" />
<setting id="http_port" value="9981" />
<setting id="pass" value="htsw" />
<setting id="pretuner_closedelay" value="10" />
<setting id="pretuner_enabled" value="false" />
<setting id="response_timeout" value="5" />
<setting id="streaming_profile" value="" />
<setting id="total_tuners" value="2" />
<setting id="trace_debug" value="false" />
<setting id="user" value="htsu" />
</settings>
_EOF_
#Template with unique variables to be patched by /boot/settings pvr-isc parcing
mkdir /home/pi/.kodi/userdata/addon_data/pvr.iptvsimple
tee /home/pi/.kodi/userdata/addon_data/pvr.iptvsimple/locsettings.xml <<_EOF_
<settings>
<setting id="epgCache" value="true" />
<setting id="epgPath" value="" />
<setting id="epgPathType" value="1" />
<setting id="epgTSOverride" value="false" />
<setting id="epgTimeShift" value="0" />
<setting id="epgUrl" value="" />
<setting id="logoBaseUrl" value="" />
<setting id="logoFromEpg" value="0" />
<setting id="logoPath" value="" />
<setting id="logoPathType" value="1" />
<setting id="m3uCache" value="true" />
<setting id="m3uPath" value="replacem3u" />
<setting id="m3uPathType" value="0" />
<setting id="m3uUrl" value="" />
<setting id="sep1" value="" />
<setting id="sep2" value="" />
<setting id="sep3" value="" />
<setting id="startNum" value="1" />
</settings>
_EOF_
#Template with unique variables to be patched by /boot/settings pvr-isc parcing
tee /home/pi/.kodi/userdata/addon_data/pvr.iptvsimple/remsettings.xml <<_EOF_
<settings>
<setting id="epgCache" value="true" />
<setting id="epgPath" value="" />
<setting id="epgPathType" value="1" />
<setting id="epgTSOverride" value="false" />
<setting id="epgTimeShift" value="0.000000" />
<setting id="epgUrl" value="" />
<setting id="logoBaseUrl" value="" />
<setting id="logoFromEpg" value="0" />
<setting id="logoPath" value="" />
<setting id="logoPathType" value="1" />
<setting id="m3uCache" value="true" />
<setting id="m3uPath" value="/boot/settings/playlist.m3u" />
<setting id="m3uPathType" value="1" />
<setting id="m3uUrl" value="replaceurl" />
<setting id="sep1" value="" />
<setting id="sep2" value="" />
<setting id="sep3" value="" />
<setting id="startNum" value="1" />
</settings>
_EOF_
#Example keyboard mapping for Numpad navigation usage in kodi
cat <<'_EOF_' > /home/pi/.kodi/userdata/keymaps/keyboard.xml
<keymap>
<global>
<keyboard>
<numpadzero>OSD</numpadzero>
<numpadone>Stop</numpadone>
<numpadtwo>Down</numpadtwo>
<numpadthree>BigStepBack</numpadthree>
<numpadfour>Left</numpadfour>
<numpadfive>Select</numpadfive>
<numpadsix>Right</numpadsix>
<numpadseven>XBMC.ActivateWindow(Home)</numpadseven>
<numpadeight>Up</numpadeight>
<numpadnine>BigStepForward</numpadnine>
<numpaddivide>StepBack</numpaddivide>
<!-- my numpad divide shows up as "forwardslash" -->
<forwardslash>StepBack</forwardslash>
<numpadtimes>StepForward</numpadtimes>
<numpadperiod>Info</numpadperiod>
<numlock>PlayPause</numlock>
<!-- + and - handle the volume by default -->
<!-- BackSpace is "back" by default -->
<!-- Enter is "select" by default -->
<!-- https://kodi.wiki/view/Alternative_keymaps_for_number_pads -->
</keyboard>
</global>
</keymap>
_EOF_
#Create patch file for adjusting defaults in .kodi/userdata/guisettings.xml
cat <<'_EOF_' > gs.patch
--- origuisettings.xml 2018-08-27 20:22:00.774568002 +0200
+++ patchguisettings.xml 2018-08-29 09:52:17.397284881 +0200
@@ -41,7 +41,7 @@
<volumesteps default="true">90</volumesteps>
</audiooutput>
<bluray>
- <playerregion default="true">1</playerregion>
+ <playerregion>2</playerregion>
</bluray>
<cache>
<harddisk default="true">256</harddisk>
@@ -70,23 +70,23 @@
<showloginfo default="true">false</showloginfo>
</debug>
<disc>
- <playback default="true">0</playback>
+ <playback>2</playback>
</disc>
<dvds>
- <automenu default="true">false</automenu>
+ <automenu>true</automenu>
<autorun default="true">false</autorun>
<playerregion default="true">0</playerregion>
</dvds>
<epg>
<daystodisplay default="true">3</daystodisplay>
- <epgupdate default="true">120</epgupdate>
+ <epgupdate>360</epgupdate>
<hidenoinfoavailable default="true">true</hidenoinfoavailable>
<ignoredbforclient default="true">false</ignoredbforclient>
- <preventupdateswhileplayingtv default="true">false</preventupdateswhileplayingtv>
+ <preventupdateswhileplayingtv>true</preventupdateswhileplayingtv>
<selectaction default="true">2</selectaction>
</epg>
<eventlog>
- <enabled default="true">true</enabled>
+ <enabled>false</enabled>
<enablednotifications default="true">false</enablednotifications>
</eventlog>
<filelists>
@@ -102,13 +102,13 @@
<addonbrokenfilter default="true">true</addonbrokenfilter>
<addonforeignfilter default="true">false</addonforeignfilter>
<addonnotifications default="true">false</addonnotifications>
- <addonupdates default="true">0</addonupdates>
- <settinglevel>1</settinglevel>
+ <addonupdates>2</addonupdates>
+ <settinglevel>3</settinglevel>
<eventlog>
<level>0</level>
<showhigherlevels>true</showhigherlevels>
</eventlog>
- <systemtotaluptime>0</systemtotaluptime>
+ <systemtotaluptime>10</systemtotaluptime>
</general>
<input>
<asknewcontrollers default="true">true</asknewcontrollers>
@@ -119,13 +119,13 @@
<locale>
<audiolanguage default="true">original</audiolanguage>
<charset default="true">DEFAULT</charset>
- <country default="true">USA (12h)</country>
+ <country>Central Europe</country>
<keyboardlayouts default="true">English QWERTY</keyboardlayouts>
<language default="true">resource.language.en_gb</language>
<longdateformat default="true">regional</longdateformat>
<shortdateformat default="true">regional</shortdateformat>
<speedunit default="true">regional</speedunit>
- <subtitlelanguage default="true">original</subtitlelanguage>
+ <subtitlelanguage>Dutch</subtitlelanguage>
<temperatureunit default="true">regional</temperatureunit>
<timeformat default="true">regional</timeformat>
<timezone default="true">Europe/Amsterdam</timezone>
@@ -172,7 +172,7 @@
<queuebydefault default="true">false</queuebydefault>
<replaygainnogainpreamp default="true">89</replaygainnogainpreamp>
<replaygainpreamp default="true">89</replaygainpreamp>
- <replaygaintype default="true">1</replaygaintype>
+ <replaygaintype>0</replaygaintype>
<seekdelay default="true">750</seekdelay>
<seeksteps default="true">-60,-30,-10,10,30,60</seeksteps>
<visualisation default="true">visualization.spectrum</visualisation>
@@ -213,7 +213,7 @@
<usehttpproxy default="true">false</usehttpproxy>
</network>
<pictures>
- <displayresolution default="true">14</displayresolution>
+ <displayresolution>16</displayresolution>
<generatethumbs default="true">true</generatethumbs>
<showvideos default="true">true</showvideos>
<usetags default="true">true</usetags>
@@ -225,10 +225,10 @@
<wakeonaccess default="true">false</wakeonaccess>
</powermanagement>
<pvrmanager>
- <backendchannelorder default="true">true</backendchannelorder>
+ <backendchannelorder>false</backendchannelorder>
<hideconnectionlostwarning default="true">false</hideconnectionlostwarning>
<syncchannelgroups default="true">true</syncchannelgroups>
- <usebackendchannelnumbers default="true">false</usebackendchannelnumbers>
+ <usebackendchannelnumbers>true</usebackendchannelnumbers>
</pvrmanager>
<pvrmenu>
<closechannelosdonswitch default="true">true</closechannelosdonswitch>
@@ -248,7 +248,7 @@
<playminimized default="true">true</playminimized>
<scantime default="true">10</scantime>
<signalquality default="true">true</signalquality>
- <startlast default="true">0</startlast>
+ <startlast>2</startlast>
<trafficadvisory default="true">false</trafficadvisory>
<trafficadvisoryvolume default="true">10</trafficadvisoryvolume>
</pvrplayback>
@@ -281,14 +281,14 @@
</scrapers>
<screensaver>
<mode default="true">screensaver.xbmc.builtin.dim</mode>
- <time default="true">3</time>
+ <time>20</time>
<usedimonpause default="true">true</usedimonpause>
<usemusicvisinstead default="true">true</usemusicvisinstead>
</screensaver>
<services>
- <airplay default="true">false</airplay>
+ <airplay>true</airplay>
<airplaypassword default="true"></airplaypassword>
- <airplayvideosupport default="true">true</airplayvideosupport>
+ <airplayvideosupport>false</airplayvideosupport>
<airplayvolumecontrol default="true">true</airplayvolumecontrol>
<devicename default="true">Kodi</devicename>
<esallinterfaces default="true">false</esallinterfaces>
@@ -330,7 +330,7 @@
<downloadfirst default="true">false</downloadfirst>
<font default="true">arial.ttf</font>
<height default="true">28</height>
- <languages default="true">English</languages>
+ <languages>Dutch,English</languages>
<movie default="true"></movie>
<overrideassfonts default="true">false</overrideassfonts>
<parsecaptions default="true">false</parsecaptions>
@@ -357,11 +357,11 @@
<updateonstartup default="true">false</updateonstartup>
</videolibrary>
<videoplayer>
- <adjustrefreshrate default="true">0</adjustrefreshrate>
+ <adjustrefreshrate>2</adjustrefreshrate>
<autoplaynextitem default="true">false</autoplaynextitem>
<errorinaspect default="true">0</errorinaspect>
<hqscalers default="true">20</hqscalers>
- <limitguiupdate default="true">10</limitguiupdate>
+ <limitguiupdate>5</limitguiupdate>
<preferdefaultflag default="true">true</preferdefaultflag>
<prefervaapirender default="true">true</prefervaapirender>
<quitstereomodeonstop default="true">true</quitstereomodeonstop>
@@ -412,11 +412,11 @@
<fakefullscreen default="true">true</fakefullscreen>
<framepacking default="true">false</framepacking>
<limitedrange default="true">false</limitedrange>
- <limitgui default="true">0</limitgui>
+ <limitgui>720</limitgui>
<monitor default="true">Default</monitor>
<noofbuffers default="true">2</noofbuffers>
<preferedstereoscopicmode default="true">100</preferedstereoscopicmode>
- <resolution default="true">16</resolution>
+ <resolution>49</resolution>
<screen default="true">0</screen>
<screenmode default="true">DESKTOP</screenmode>
<stereoscopicmode default="true">0</stereoscopicmode>
_EOF_
cp /home/pi/.kodi/userdata/guisettings.xml /home/pi/origuisettings.xml
patch /home/pi/.kodi/userdata/guisettings.xml gs.patch
#Defaults for Enabling/Disabling Buttons in HomeMenu skin
mkdir /home/pi/.kodi/userdata/addon_data/skin.estuary
cat <<'_EOF_' >/home/pi/.kodi/userdata/addon_data/skin.estuary/settings.xml
<settings>
<setting id="no_slide_animations" type="bool">false</setting>
<setting id="HomeMenuNoPicturesButton" type="bool">false</setting>
<setting id="no_fanart" type="bool">false</setting>
<setting id="HomeMenuNoMovieButton" type="bool">true</setting>
<setting id="HomeMenuNoTVShowButton" type="bool">true</setting>
<setting id="HomeMenuNoMusicButton" type="bool">true</setting>
<setting id="HomeMenuNoMusicVideoButton" type="bool">true</setting>
<setting id="HomeMenuNoTVButton" type="bool">false</setting>
<setting id="HomeMenuNoRadioButton" type="bool">false</setting>
<setting id="HomeMenuNoProgramsButton" type="bool">false</setting>
<setting id="HomeMenuNoVideosButton" type="bool">false</setting>
<setting id="HomeMenuNoFavButton" type="bool">true</setting>
<setting id="HomeMenuNoWeatherButton" type="bool">true</setting>
<setting id="touchmode" type="bool">false</setting>
<setting id="show_weatherinfo" type="bool">false</setting>
<setting id="autoscroll" type="bool">false</setting>
<setting id="hide_mediaflags" type="bool">false</setting>
<setting id="background_overlay" type="string">1</setting>
<setting id="MovieGenreFanart.path" type="string"></setting>
<setting id="MovieGenreFanart.ext" type="string"></setting>
<setting id="WeatherFanart.path" type="string"></setting>
<setting id="WeatherFanart.ext" type="string"></setting>
<setting id="HomeFanart.path" type="string"></setting>
<setting id="HomeFanart.ext" type="string"></setting>
<setting id="HomeFanart.name" type="string"></setting>
<setting id="WeatherFanart.name" type="string"></setting>
<setting id="MovieGenreFanart.Name" type="string"></setting>
</settings>
_EOF_
echo "The automated part is done, now its time to configure kodi GUI to a state"
echo "you want it to be as a template for every single readonly boot for future"
echo "Run './rrk.sh modifykodirw' to see steps to create its definitive state"
}
function modifykodirw {
echo "
The idea is that you will start kodi this time to configure it with hdmi-cec or
mouse/keyboard to its final setup/look/state which will be used as a definitive
template for the readonly environment. You are free to install any Video addon.
Its important to keep a certain order of addon installation since the pvr addons
will be enabled (not configured) at the end. All other addons configured after
the first pvr addon will get lost!
Keep in mind diskspace/ram usage since the whole .kodi folder will stay in ram
when its in read-only mode! Especially avoid addons that build huge thumbcaches!
To check kodi folder size type 'du -hcs ~/.kodi' those are MB of RAM starving!
Final warning do not configure/change settings in the enabled PVR-addons nor
changes in the audio output since otherwise /boot/setting configurations fail
to apply!
################################################################################
sudo systemctl start kodi.service
#setup kodi&addons as usual but before enabling the first pvr addon exit kodi
#
#if kodi has been exited create a backup of the addon database with none pvr!
sudo cp -a /home/pi/.kodi/userdata/Database/Addons27.db /home/pi/nonAddons27.db
sudo systemctl start kodi.service
#setup kodi&addons as usual but after enabling the first pvr-hts addon exit kodi
#
#if kodi has been exited after enabling the pvr-hts addon backup its database!
sudo cp -a /home/pi/.kodi/userdata/Database/Addons27.db /home/pi/htsAddons27.db
sudo systemctl start kodi.service
#start kodi again to disable pvr-hts addon than enable pvr-isc addon and exit
#
#if kodi has been exited after enabling the pvr-isc addon backup its database!
sudo cp -a /home/pi/.kodi/userdata/Database/Addons27.db /home/pi/iscAddons27.db
sudo systemctl start kodi.service
#start kodi again to disable pvr-isc addon than enable pvr-hhr addon and exit
#
#if kodi has been exited after enabling the pvr-hhr addon backup its database!
sudo cp -a /home/pi/.kodi/userdata/Database/Addons27.db /home/pi/hhrAddons27.db
################################################################################
When a definitive kodi state is reached the final step must be run to make it
readonly proof therefor run './rrk.sh finishkodiro' and answer script questions.
"
}
function finishkodiro {
sudo systemctl stop kodi.service
cp -a /home/pi/.kodi /home/pi/kodiro
rm -r /home/pi/.kodi
cp -a /home/pi/kodiro /tmp/kodirw
sudo ln -s /tmp/kodirw /home/pi/.kodi
head -n 20 /etc/rc.local | sudo tee /etc/rc.local
sudo tee -a /etc/rc.local <<_EOF_
echo "[ DO ] copy kodiro to /tmp/kodirw"
cp -a /home/pi/kodiro /tmp/kodirw
sync
echo "[ DO ] running /home/pi/setaudio.sh"
/home/pi/setaudio.sh
echo "[ DO ] running /home/pi/setpvr.sh"
/home/pi/setpvr.sh
echo "[ DO ] running /home/pi/setrdf.sh"
/home/pi/setrdf.sh
echo "[ DO ] running /home/pi/connectwii.sh"
/home/pi/connectwii.sh
sync
sleep 1
sudo systemctl start kodi.service
exit 0
_EOF_
wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/read-only-fs.sh
sudo bash /home/pi/read-only-fs.sh
echo "
You are done just reboot!
"
}
function joystickcontroller {
#buttonmaps for classic- v1/v2/logitech & modern- 360 xbox wired usb controllers
mkdir ~/.kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux
mkdir ~/.kodi/userdata/peripheral_data
cat <<'_EOF_' > ~/.kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux/Logitech_Compact_Controller_for_Xbox_10b_8a.xml
<?xml version="1.0" ?>
<buttonmap>
<device name="Logitech Compact Controller for Xbox" provider="linux" buttoncount="10" axiscount="8">
<configuration>
<axis index="2" center="-1" range="2" />
<axis index="5" center="-1" range="2" />
</configuration>
<controller id="game.controller.default">
<feature name="a" button="0" />
<feature name="b" button="1" />
<feature name="back" button="6" />
<feature name="down" axis="+7" />
<feature name="left" axis="-6" />
<feature name="leftbumper" button="5" />
<feature name="leftstick">
<up axis="-1" />
<down axis="+1" />
<right axis="+0" />
<left axis="-0" />
</feature>
<feature name="leftthumb" button="8" />
<feature name="lefttrigger" axis="+2" />
<feature name="right" axis="+6" />
<feature name="rightbumper" button="2" />
<feature name="rightstick">
<up axis="-4" />
<down axis="+4" />
<right axis="+3" />
<left axis="-3" />
</feature>
<feature name="rightthumb" button="9" />
<feature name="righttrigger" axis="+5" />
<feature name="start" button="7" />
<feature name="up" axis="-7" />
<feature name="x" button="3" />
<feature name="y" button="4" />
</controller>
</device>
</buttonmap>
_EOF_
# set global deadzone for all controller to 0.8 since the slightest stick offset
# will hang/repeat unwanted input and make GUI unresponsive!
#cat <<'_EOF_' > ~/.kodi/userdata/peripheral_data/addon_Logitech_Compact_Controller_for_Xbox.xml
#addon_Microsoft_X-Box_pad_v1_(US)
#addon_Microsoft_X-Box_pad_v2_(US)
#addon_Microsoft_X-Box_360_pad
#<settings>
# <setting id="left_stick_deadzone" value="0.90" />
# <setting id="right_stick_deadzone" value="0.90" />
#</settings>
#_EOF_
cat <<'_EOF_' > ~/.kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux/Microsoft_X-Box_pad_v1_US_10b_8a.xml
<?xml version="1.0" ?>
<buttonmap>
<device name="Microsoft X-Box pad v1 (US)" provider="linux" buttoncount="10" axiscount="8">
<configuration>
<axis index="2" center="-1" range="2" />
<axis index="5" center="-1" range="2" />
</configuration>
<controller id="game.controller.default">
<feature name="a" button="0" />
<feature name="b" button="1" />
<feature name="back" button="6" />
<feature name="down" axis="+7" />
<feature name="left" axis="-6" />
<feature name="leftbumper" button="5" />
<feature name="leftstick">
<up axis="-1" />
<down axis="+1" />
<right axis="+0" />
<left axis="-0" />
</feature>
<feature name="leftthumb" button="8" />
<feature name="lefttrigger" axis="+2" />
<feature name="right" axis="+6" />
<feature name="rightbumper" button="2" />
<feature name="rightstick">
<up axis="-4" />
<down axis="+4" />
<right axis="+3" />
<left axis="-3" />
</feature>
<feature name="rightthumb" button="9" />
<feature name="righttrigger" axis="+5" />
<feature name="start" button="7" />
<feature name="up" axis="-7" />
<feature name="x" button="3" />
<feature name="y" button="4" />
</controller>
</device>
</buttonmap>
_EOF_
cat <<'_EOF_' > ~/.kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux/Microsoft_X-Box_pad_v2_US_10b_8a.xml
<?xml version="1.0" ?>
<buttonmap>
<device name="Microsoft X-Box pad v2 (US)" provider="linux" buttoncount="10" axiscount="8">
<configuration>
<axis index="2" center="-1" range="2" />
<axis index="5" center="-1" range="2" />
</configuration>
<controller id="game.controller.default">
<feature name="a" button="0" />
<feature name="b" button="1" />
<feature name="back" button="6" />
<feature name="down" axis="+7" />
<feature name="left" axis="-6" />
<feature name="leftbumper" button="5" />
<feature name="leftstick">
<up axis="-1" />
<down axis="+1" />
<right axis="+0" />
<left axis="-0" />
</feature>
<feature name="leftthumb" button="8" />
<feature name="lefttrigger" axis="+2" />
<feature name="right" axis="+6" />
<feature name="rightbumper" button="2" />
<feature name="rightstick">
<up axis="-4" />
<down axis="+4" />
<right axis="+3" />
<left axis="-3" />
</feature>
<feature name="rightthumb" button="9" />
<feature name="righttrigger" axis="+5" />
<feature name="start" button="7" />
<feature name="up" axis="-7" />
<feature name="x" button="3" />
<feature name="y" button="4" />
</controller>
</device>
</buttonmap>
_EOF_
cat <<'_EOF_' > ~/.kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux/Microsoft_X-Box_360_pad_11b_8a.xml
<?xml version="1.0" ?>
<buttonmap>
<device name="Microsoft X-Box 360 pad" provider="linux" buttoncount="11" axiscount="8">
<configuration>
<axis index="2" center="-1" range="2" />
<axis index="5" center="-1" range="2" />
</configuration>
<controller id="game.controller.default">
<feature name="a" button="0" />
<feature name="b" button="1" />
<feature name="back" button="6" />
<feature name="down" axis="+7" />
<feature name="guide" button="8" />
<feature name="left" axis="-6" />
<feature name="leftbumper" button="4" />
<feature name="leftstick">
<up axis="-1" />
<down axis="+1" />
<right axis="+0" />
<left axis="-0" />
</feature>
<feature name="leftthumb" button="9" />
<feature name="lefttrigger" axis="+2" />
<feature name="right" axis="+6" />
<feature name="rightbumper" button="5" />
<feature name="rightstick">
<up axis="-4" />
<down axis="+4" />
<right axis="+3" />
<left axis="-3" />