-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathi-xbmcbuntu.sh
executable file
·1492 lines (1235 loc) · 46.4 KB
/
i-xbmcbuntu.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/sh
# Boot XBMCbuntu, CTRL+ALT+F1, login and run:
# wget https://raw.githubusercontent.com/pfzim/xbmc-config/master/i.sh
# chmod a+rx i.sh
# sudo ./i.sh
# --wget http://hencvik.googlecode.com/files/i.sh
# --./i.sh 2>&1 | tee i.log
back_title="XBMC 13.2 post installation configuration script v0.08.22 (c) pfzim"
fg_title="XBMC configuration"
DIALOG=whiptail
idir=$(pwd)
dm=openbox
ask() {
while :
do
read -p "$1" $2
if [ -n "$(eval "echo \$$2")" ] ; then
break
fi
if [ $# -gt 2 -a -n "$3" ] ; then
eval "$2=\$3"
break
fi
done
}
a_msgbox() {
${DIALOG} --backtitle "${back_title}" --clear --title "${fg_title}" --msgbox "$1" 10 75
}
# text result default
a_yesno() {
defval=" --defaultno"
if [ "$3" = "yes" ] ; then
defval=""
fi
${DIALOG} --backtitle "${back_title}" --clear --title "${fg_title}"${defval} --yesno "$1" 22 75
if [ $? -eq 0 ] ; then
eval "$2=Y"
else
eval "$2=N"
fi
}
# text result=default value
a_input() {
temp_result=`mktemp 2>/dev/null` || temp_result=/tmp/test$$
eval "${DIALOG} --backtitle \"${back_title}\" --clear --title \"${fg_title}\"${defval} --inputbox \"$1\" 10 75 \"\${$2}\" 2>$temp_result"
result=`cat $temp_result`
rm -f $temp_result
if [ $? -eq 0 ] ; then
eval "$2=\$result"
fi
}
# text result
a_passwd0() {
temp_result=`mktemp 2>/dev/null` || temp_result=/tmp/test$$
${DIALOG} --backtitle "${back_title}" --clear --title "${fg_title}"${defval} --passwordbox "$1" 10 75 2>$temp_result
result=`cat $temp_result`
rm -f $temp_result
if [ $? -eq 0 ] ; then
eval "$2=\$result"
else
eval "$2=\"$3\""
fi
}
a_passwd() {
while :
do
temp_passwd1=""
temp_passwd2=""
a_passwd0 "$1" temp_passwd1
a_passwd0 "Enter password again:" temp_passwd2
if [ -n "$temp_passwd1" -a "$temp_passwd1" = "$temp_passwd2" ] ; then
eval "$2=\"$temp_passwd1\""
break
fi
done
}
if [ "$(id -u)" != "0" ]; then
echo "Sorry, you must execute me with sudo."
exit 1
fi
[ -d xbmc_install ] || mkdir xbmc_install
cd xbmc_install
# backup
curdate=`date '+%Y-%m-%d-%H-%M%S'`
crontab -u xbmc -l > .crontab
tar -czpf backup-${curdate}-pfzim-xbmc.tar.gz --ignore-failed-read .crontab \
/etc/asound.conf \
/etc/default/rcS \
/etc/fstab \
/etc/iptables.up.rules \
/etc/minidlna.conf \
/etc/modules \
/etc/network/interfaces \
/etc/rc.local \
/etc/fonts/local.conf \
/etc/init.d/rtorrent.sh \
/etc/modprobe.d/alsa-base.conf \
/etc/modprobe.d/v4l2loopback.conf \
/etc/motion/motion.conf \
/etc/transmission-daemon/settings.json \
/etc/NetworkManager/NetworkManager.conf \
/var/www/rutorrent/conf/config.php \
/usr/lib/X11/xorg.conf.d \
/usr/share/alsa/cards/HDA-Intel.conf \
/usr/share/X11/xorg.conf.d \
/home/rtorrent/.rtorrent.rc \
/home/xbmc/.asoundrc \
/home/xbmc/.fdm.conf \
/home/xbmc/.msmtprc \
/home/xbmc/scripts/brasero.sh \
/home/xbmc/scripts/firefox.sh \
/home/xbmc/scripts/chrome.sh \
/home/xbmc/.xbmc/userdata/advancedsettings.xml \
/home/xbmc/.xbmc/userdata/guisettings.xml \
/home/xbmc/.xbmc/userdata/LCD.xml \
/home/xbmc/.xbmc/userdata/profiles.xml \
/home/xbmc/.xbmc/userdata/sources.xml \
/home/xbmc/.xbmc/userdata/RssFeeds.xml
[ -f xbmc-pfz-0.08.tar.bz2 ] || wget "http://hencvik.googlecode.com/files/xbmc-pfz-0.08.tar.bz2"
tar -xjvf xbmc-pfz-0.08.tar.bz2
# set hardware clock to localtime
############################
#read -p "Set timezone to Europe/Moscow [Y/n]?" result
c_tz() {
echo "Europe/Moscow" > /etc/timezone
sed -i -e "s/^\(\\s*UTC\\s*=\\s*\)yes\(\\s*\)\$/\\1no\\2/" /etc/default/rcS
rm -f /etc/localtime
ln -sf /usr/share/zoneinfo/Europe/Moscow /etc/localtime
#hwclock --systohc
}
# configure wireless network
############################
#read -p "Install Atheros firmware (ar9271.fw, htc_9271.fw) [y/N]?" result
i_fmw_pre() {
#[ -f xbmc-firmwares-0.08.tar.bz2 ] || wget "http://pfzim.zh-shop.ru/_xbmc/xbmc-firmwares-0.08.tar.bz2"
#tar -xjvf xbmc-firmwares-0.08.tar.bz2
#http://git.kernel.org/?p=linux/kernel/git/dwmw2/linux-firmware.git;a=tree
[ -f htc_9271.fw ] || wget "http://git.kernel.org/?p=linux/kernel/git/dwmw2/linux-firmware.git;a=blob_plain;f=htc_9271.fw;hb=HEAD"
[ -f htc_7010.fw ] || wget "http://git.kernel.org/?p=linux/kernel/git/dwmw2/linux-firmware.git;a=blob_plain;f=htc_7010.fw;hb=HEAD"
#[ -f /lib/firmware/ar9271.fw ] || cp ar9271.fw /lib/firmware/
[ -f /lib/firmware/htc_9271.fw ] || cp htc_9271.fw /lib/firmware/
[ -f /lib/firmware/htc_7010.fw ] || cp htc_7010.fw /lib/firmware/
}
#read -p "Install compat-wireless-3.2-rc1-1 from source [y/N]?" result
i_cw_pre() {
#[ -f compat-wireless-2.6.tar.bz2 ] || wget "http://pfzim.zh-shop.ru/_xbmc/compat-wireless-2.6.tar.bz2"
#tar -xjvf compat-wireless-2.6.tar.bz2
[ -f compat-wireless-3.2-rc1-1.tar.bz2 ] || wget "http://www.orbit-lab.org/kernel/compat-wireless-3-stable/v3.2/compat-wireless-3.2-rc1-1.tar.bz2"
tar -xjvf compat-wireless-3.2-rc1-1.tar.bz2
cd compat-wireless-*/
make && make install
make unload
cd ..
#rm -rf /lib/modules/updates/compat*
depmod
modprobe ath9k_htc
}
ask_settings_ip() {
while :
do
a_input "Enter IP address [192.168.1.100]:" $1
a_input "Enter network mask [255.255.255.0]:" $2
a_input "Enter gateway [192.168.1.1]:" $3
a_input "Enter DNS1 []:" $4
a_input "Enter DNS2 []:" $5
eval "a_yesno \"Network settings:\\n\\nIP: \$$1\nMask: \$$2\\nGateway: \$$3\\nDNS1: \$$4\\nDNS2: \$$5\\n\\nEntered data correct?\" result"
if [ "$result" = "Y" -o "$result" = "y" ] ; then
break
fi
done
}
ask_settings_pass() {
while :
do
#read -s -p "Enter WPA password: " p1
#read -s -p "Enter again: " p2
#read -p "Enter WPA password: " p1
#read -p "Enter again: " p2
a_passwd "Enter password for wireless network:" p1
if [ "${#p1}" -ge 8 -a "${#p1}" -le 63 ] ; then
eval "$1=$p1"
break
else
a_msgbox "Passphrase must be 8..63 characters"
fi
done
}
#read -p "Configure wireless interface [Y/n]?" result
c_wifi_pre() {
#sudo apt-get install wpasupplicant
fg_title="Wireless network configuration"
while :
do
list_items=$(iwconfig | grep -e "^\\s*[a-zA-Z]\+[0-9]\+" | sed -e "s/^\\s*\([a-zA-Z]\+[0-9]\+\).*\$/\\1/" |
(
n=1
while read line
do
echo "\"${line}\" \"Wireless interface ${n}\""
n=$((n+1))
done
echo "rescan \"Find new WiFi adapters...\""
echo "exit \"Finish configuration\""
)
)
if [ -z "${list_items}" ] ; then
break
fi
tempfile=`mktemp 2>/dev/null` || tempfile=/tmp/test$$
#trap "rm -f $tempfile" 0 1 2 5 15
eval ${DIALOG} --backtitle \"${back_title}\" --clear --title \"Wireless network configuration\" --menu \"Select WiFi inteface\" 20 75 13 ${list_items} 2>$tempfile
if [ $? -ne 0 ] ; then
rm -f $tempfile
break
fi
net_if=$(cat $tempfile)
rm -f $tempfile
if [ "${net_if}" = "rescan" ] ; then
continue
fi
if [ "${net_if}" = "exit" ] ; then
break
fi
ifconfig ${net_if} up
list_items=$(iwlist ${net_if} scan 2>&1 | \
sed -e "s/^\\s*//" \
-e "s/^Cell [0-9]\+ - /#/" \
-e "s/^#Address: \([0-9a-Z:]\+\)\$/#ap_mac=\"\\1\"/" \
-e "s/^Quality=\([0-9]\+\\/[0-9]\+\).*\$/ap_quality=\"\\1\"/" \
-e "s/^.*Channel \([0-9]\+\).*\$/ap_channel=\\1/" \
-e "s/^ESSID:/ap_essid=/" \
-e "s/^Mode: \([a-Z]+\)\$/ap_mode=\\1/" \
-e "s/^Encryption key:\([a-Z]\+\)\$/ap_enc=\\1/" \
-e "s/^IE: WPA Version \([0-9]\+\)\$/ap_etype=WPA\nap_ever=\\1/" | \
grep "^#\?ap_[a-z]\+=.*$" | \
tr "\n#" ";\n" | \
grep -v "^\$" | \
sed -e "s/;\$//" | \
sed -e "s/\"/\\\"/" | \
awk "{ print NR \";\" \$0 }"
)
list_menu=$(echo "${list_items}" | sed -e "s/^\([0-9]\+\).*ap_essid=\([^;]\+\).*\$/\1 \2/")
#echo "*** RESULT ***"
#echo "${list_items}"
#echo "*** RESULT ***"
#echo "*** RESULT ***"
#echo "${list_menu}"
#echo "*** RESULT ***"
if [ -n "${list_items}" ] ; then
eval ${DIALOG} --backtitle \"${back_title}\" --clear --title \"Wireless network configuration\" --menu \"Select WiFi accesspoint\" 20 75 13 ${list_menu} 2>$tempfile
if [ $? -eq 0 ] ; then
sel_item=$(cat $tempfile)
ap_info=$(echo "${list_items}" | grep "^${sel_item};" | sed -e "s/^[0-9]\+;//")
#echo "AP_INFO: ${ap_info}"
eval "${ap_info}"
#echo "MAC: ${ap_mac}"
#echo "ESSID: ${ap_essid}"
#echo "ENC-TYPE: ${ap_etype}"
net_res="# xbmc-config-script-${net_if}\n"
net_res="${net_res}auto ${net_if}\n"
net_dhcp=1
#read -p "Use DHCP [Y/n]?" result
a_yesno "Use DHCP?" result "yes"
if [ "$result" = "Y" -o "$result" = "y" ] ; then
net_res="${net_res}iface ${net_if} inet dhcp\n"
else
net_dhcp=0
net_ip="192.168.1.100"
net_mask="255.255.255.0"
net_gw="192.168.1.1"
net_dns1=""
net_dns2=""
ask_settings_ip net_ip net_mask net_gw net_dns1 net_dns2
net_res="${net_res}iface ${net_if} inet static\n"
net_res="${net_res}address ${net_ip}\n"
net_res="${net_res}netmask ${net_mask}\n"
net_res="${net_res}gateway ${net_gw}\n"
if [ -n "${net_dns1}" -o -n "${net_dns2}" ] ; then
net_res="${net_res}dns-nameservers"
if [ -n "${net_dns1}" ] ; then
net_res="${net_res} ${net_dns1}"
fi
if [ -n "${net_dns2}" ] ; then
net_res="${net_res} ${net_dns2}\n"
fi
net_res="${net_res}\n"
fi
fi
if eval "sed \"/# xbmc-config-script-${net_if}/,/# xbmc-config-script-${net_if}-end/d\" /etc/network/interfaces | grep -v -e \"^\\\\s*#\" | grep -q -e \"${net_if}\"" ; then
a_msgbox "Error: configuration for interface ${net_if} already exist in file /etc/network/interfaces"
else
if [ "${ap_enc}" = "on" ] ; then
ask_settings_pass ap_pass
if [ "${ap_etype}" = "WPA" ] ; then
ap_pass=$(wpa_passphrase "${ap_essid}" "${ap_pass}" | grep "^\s*psk=" | sed -e "s/^\s*psk=\(.*\)$/\1/")
net_res="${net_res}wpa-driver wext\n"
net_res="${net_res}wpa-ssid ${ap_essid}\n"
net_res="${net_res}wpa-ap-scan 2\n"
net_res="${net_res}wpa-proto RSN WPA\n"
net_res="${net_res}wpa-pairwise CCMP TKIP\n"
net_res="${net_res}wpa-group CCMP TKIP\n"
net_res="${net_res}wpa-key-mgmt WPA-PSK\n"
net_res="${net_res}wpa-psk ${ap_pass}\n"
else
# WEP
net_res="${net_res}wireless-mode managed\n"
net_res="${net_res}wireless-essid ${ap_essid}\n"
net_res="${net_res}wireless-enc ${ap_pass}\n"
fi
else
net_res="${net_res}wireless-mode managed\n"
net_res="${net_res}wireless-essid ${ap_essid}\n"
fi
net_res="${net_res}# xbmc-config-script-${net_if}-end\n"
#echo "\n${net_res}"
#read -p "Save this configuration [Y/n]?" result
a_yesno "${net_res}\nSave this configuration?" result "yes"
if [ "$result" = "Y" -o "$result" = "y" ] ; then
sed -i "/# xbmc-config-script-${net_if}/,/# xbmc-config-script-${net_if}-end/d" /etc/network/interfaces
echo "${net_res}" >> /etc/network/interfaces
fi
a_yesno "${net_res}\nConnect NOW using this configuration?" result "yes"
if [ "$result" = "Y" -o "$result" = "y" ] ; then
if [ "${ap_enc}" = "on" ] ; then
if [ "${ap_etype}" = "WPA" ] ; then
tempconf=`mktemp 2>/dev/null` || tempconf=/tmp/test$$
wpa_passphrase "${ap_essid}" "${ap_pass}" > tempconf
wpa_supplicant -Dwext -i${net_if} -c${tempconf}
rm -f ${tempconf}
else
iwconfig ${net_if} essid "${ap_essid}" key "${ap_pass}"
fi
else
iwconfig ${net_if} essid "${ap_essid}"
fi
if [ "$net_dhcp" -eq 1 ] ; then
dhclient ${net_if}
else
ifconfig ${net_if} inet ${net_if} netmask ${net_mask}
route add default gw ${net_gw} ${net_if}
fi
fi
fi
fi
rm -f $tempfile
fi
done
}
# update
############################
#read -p "Update aptitude (apt-get update) [Y/n]?" result
i_aptup() {
# Webmin repository
#deb http://download.webmin.com/download/repository sarge contrib
#deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib
#wget http://www.webmin.com/jcameron-key.asc
#apt-key add jcameron-key.asc
#chromium repository
#add-apt-repository ppa:chromium-daily/ppa
add-apt-repository -y ppa:transmissionbt/ppa
apt-get -y update
}
# install NetworkManager
############################
#read -p "Install Network Manager [Y/n]?" result
i_nm() {
apt-get -y install network-manager
sed -i "s/\(\\s*managed\\s*=\\s*\)false/\\1true/" /etc/NetworkManager/NetworkManager.conf
#echo "\nnm-applet --sm-disable &" >> ~/.fluxbox/startup
}
# configure DDNS
############################
ask_settings_noip() {
while :
do
#echo "DDNS no-ip.com settings:"
a_input "Enter login: " $1
a_passwd "Enter password: " $2
a_input "Enter host: " $3
eval "a_yesno \"no-ip.com DDNS service settings:\\n\\nLogin: \$$1\\nPassword: *hidden*\\nHost: \$$3\\n\\nEntered data correct?\" result \"yes\""
if [ "$result" = "Y" -o "$result" = "y" ] ; then
break
fi
done
}
#read -p "Configure DDNS no-ip.com script [Y/n]?" result
c_ddns_pre() {
noip_user=""
noip_passwd=""
noip_host="youname.no-ip.org"
fg_title="DDNS no-ip.com settings"
ask_settings_noip noip_user noip_passwd noip_host
}
c_ddns() {
crontab -u xbmc -l > .crontab
cat >> .crontab << EOF
*/15 * * * * wget --quiet --delete-after --auth-no-challenge --user="${noip_user}" --password="${noip_passwd}" --user-agent="wget based script/0.01 [email protected]" "http://dynupdate.no-ip.com/nic/update?hostname=${noip_host}"
EOF
crontab -u xbmc .crontab
}
# install Midnight commander
############################
#read -p "Install Midnight commander [Y/n]?" result
i_mc() {
apt-get -y install mc man
}
# configure HDMI audio
############################
#read -p "Configure HDMI audio (run only if HDMI audio does not work) [y/N]?" result
c_hdmi() {
hdmi_device=`aplay -l | grep HDMI | sed -e "s/^card \([0-9]\):.*device \([0-9]\):.*\$/\\1,\\2/"`
if [ -n "${hdmi_device}" ] ; then
# sed -e "s/\$hdmi_device/${hdmi_device}/" asound.conf > /etc/asound.conf
# sed -e "s/\$hdmi_device/${hdmi_device}/" .asoundrc > /home/xbmc/.asoundrc
[ -f /etc/asound.conf ] || cat > /etc/asound.conf << EOF
pcm.!hdmi-remap {
type asym
playback.pcm {
type plug
slave.pcm "remap-surround71"
}
}
pcm.!remap-surround71 {
type route
slave.pcm "hw:${hdmi_device}"
ttable {
0.0= 1
1.1= 1
2.4= 1
3.5= 1
4.2= 1
5.3= 1
6.6= 1
7.7= 1
}
}
EOF
[ -f /home/xbmc/.asoundrc ] || cat > /home/xbmc/.asoundrc << EOF
pcm.dmixer {
type dmix
ipc_key 1024
ipc_key_add_uid false
ipc_perm 0660
slave {
pcm "hw:${hdmi_device}"
#pcm "ladcomp"
rate 48000
channels 2
format S32_LE
period_time 0
period_size 1024
buffer_time 0
buffer_size 4096
}
}
pcm.!default {
type plug
slave.pcm "dmixer"
}
EOF
cat /etc/modprobe.d/alsa-base.conf | grep -q -e "^\\s*options\\s*snd-hda-intel\\s*model=6stack-dig\\s*\$" || cat >> /etc/modprobe.d/alsa-base.conf << EOF
# Audio over HDMI
options snd-hda-intel model=6stack-dig
EOF
[ -f /usr/share/alsa/cards/HDA-Intel.conf.org ] || mv /usr/share/alsa/cards/HDA-Intel.conf /usr/share/alsa/cards/HDA-Intel.conf.org
cp HDA-Intel.conf /usr/share/alsa/cards/
hdmi_card=`echo ${hdmi_device} | awk -F, '{ print $1; }'`
/usr/bin/amixer -q -c ${hdmi_card} sset 'Master',0 unmute && /usr/bin/amixer -q -c ${hdmi_card} sset 'Master',0 100
/usr/bin/amixer -q -c ${hdmi_card} sset 'IEC958 Default PCM',${hdmi_card} unmute
/usr/bin/amixer -q -c ${hdmi_card} sset 'IEC958',0 unmute && /usr/bin/amixer -q -c ${hdmi_card} sset 'IEC958',1 unmute
alsactl store ${hdmi_card}
# speaker-test -D hdmi -c6 -r19200 -FS32_LE
fi
}
#read -p "Install audio Normalization (Dynamic Range Compression) plugin [Y/n]?" result
i_drc() {
apt-get -y install swh-plugins
hdmi_device=`aplay -l | grep HDMI | sed -e "s/^card \([0-9]\):.*device \([0-9]\):.*\$/\\1,\\2/"`
if [ -n "${hdmi_device}" ] ; then
cat /home/xbmc/.asoundrc | grep -q -e "pcm\\.drc" || cat >> /home/xbmc/.asoundrc << EOF
pcm.drc {
type plug
slave.pcm "drc_compressor";
}
pcm.drc_compressor {
type ladspa
slave.pcm "drc_limiter";
path "/usr/lib/ladspa";
plugins [
{
label dysonCompress
input {
#peak limit, release time, fast ratio, ratio
controls [0 1 0.5 0.99]
}
}
]
}
pcm.drc_limiter {
type ladspa
slave.pcm "plughw:${hdmi_device}";
path "/usr/lib/ladspa";
plugins [
{
label fastLookaheadLimiter
input {
#InputGain(Db) -20 -> +20 ; Limit (db) -20 -> 0 ; Release time (s) 0.01 -> 2
controls [ 20 0 0.8 ]
}
}
]
}
EOF
fi
}
# install xbmc plugins
############################
#read -p "Install XBMC plugins (Advanced Launcher) [Y/n]?" result
i_plugins() {
#wget http://mirrors.xbmc.org/addons/dharma/plugin.program.executor/plugin.program.executor-0.2.5.zip
#wget http://mirrors.xbmc.org/addons/dharma/plugin.program.launcher/plugin.program.launcher-1.10.2.zip
#unzip plugin.program.executor-0.2.5.zip -d /home/xbmc/.xbmc/addons/
#unzip plugin.program.launcher-1.10.2.zip -d /home/xbmc/.xbmc/addons/
# Eden
#wget http://mirrors.xbmc.org/addons/eden/plugin.program.advanced.launcher/plugin.program.advanced.launcher-1.7.6.zip
#unzip plugin.program.advanced.launcher-1.7.6.zip -d /home/xbmc/.xbmc/addons/
#wget http://mirrors.xbmc.org/addons/eden/skin.confluence-vertical/skin.confluence-vertical-2.1.1.zip
#unzip skin.confluence-vertical-2.1.1.zip -d /home/xbmc/.xbmc/addons/
#wget http://mirrors.xbmc.org/addons/eden/plugin.program.rtorrent/plugin.program.rtorrent-1.11.7.zip
#unzip plugin.program.rtorrent-1.11.7.zip -d /home/xbmc/.xbmc/addons/
#wget http://mirrors.xbmc.org/addons/eden/script.transmission/script.transmission-0.7.1.zip
#unzip script.transmission-0.7.1.zip -d /home/xbmc/.xbmc/addons/
# Frodo
#wget http://mirrors.xbmc.org/addons/frodo/plugin.program.advanced.launcher/plugin.program.advanced.launcher-1.7.6.zip
#unzip plugin.program.advanced.launcher-1.7.6.zip -d /home/xbmc/.xbmc/addons/
wget http://www.gwenael.org/Repository/repository.angelscry.xbmc-plugins/repository.angelscry.xbmc-plugins-1.2.2.zip
unzip repository.angelscry.xbmc-plugins-1.2.2.zip -d /home/xbmc/.xbmc/addons/
wget http://www.gwenael.org/Repository/plugin.program.advanced.launcher/plugin.program.advanced.launcher-2.0.10.zip
unzip plugin.program.advanced.launcher-2.0.10.zip -d /home/xbmc/.xbmc/addons/
#wget http://mirrors.xbmc.org/addons/eden/skin.confluence-vertical/skin.confluence-vertical-2.1.1.zip
#unzip skin.confluence-vertical-2.1.1.zip -d /home/xbmc/.xbmc/addons/
wget http://mirrors.xbmc.org/addons/frodo/plugin.program.rtorrent/plugin.program.rtorrent-1.11.7.zip
unzip plugin.program.rtorrent-1.11.7.zip -d /home/xbmc/.xbmc/addons/
wget http://mirrors.xbmc.org/addons/frodo/script.transmission/script.transmission-0.7.1.zip
unzip script.transmission-0.7.1.zip -d /home/xbmc/.xbmc/addons/
#wget
#unzip -d /home/xbmc/.xbmc/addons/
#wget
#unzip -d /home/xbmc/.xbmc/addons/
}
# install rtorrent
############################
#read -p "Install rtorrent [Y/n]?" result
rtor_src=0
rtorrent_media="/media/torrents/video"
rtorrent_data="/home/rtorrent"
i_rtor_pre() {
fg_title="rtorrent settings"
while :
do
a_yesno "Build rtorrent from sorce code?" result "no"
#read -p "Build rtorrent from sorce code [y/N]?" result
if [ "$result" = "Y" -o "$result" = "y" ] ; then
rtor_src=1
fi
a_input "Enter path where you want save rtorrent download" rtorrent_media
a_input "Enter path where you want save rtorrent session data" rtorrent_data
rtorrent_media=`echo ${rtorrent_media} | sed -e "s/\\/*\$//"`
rtorrent_data=`echo ${rtorrent_data} | sed -e "s/\\/*\$//"`
a_yesno "rtorrent settings:\n\nDownloads path: ${rtorrent_media}\nSessions path: ${rtorrent_data}\n\nEntered data correct?" result "yes"
if [ "$result" = "Y" -o "$result" = "y" ] ; then
break
fi
done
}
i_rtor() {
if [ $rtor_src -eq 1 ] ; then
apt-get -y install screen build-essential libtool automake libsigc++-2.0-dev libncurses5-dev libcurl4-openssl-dev libxmlrpc-c3-dev
#?apt-get -y install openssl libncursesw5-dev libcppunit-dev
wget http://libtorrent.rakshasa.no/downloads/libtorrent-0.12.9.tar.gz
wget http://libtorrent.rakshasa.no/downloads/rtorrent-0.8.9.tar.gz
tar -xvzf libtorrent-0.12.9.tar.gz
tar -xvzf rtorrent-0.8.9.tar.gz
cd libtorrent-*/
./autogen.sh
./configure --prefix=/usr
make && make install
cd ..
cd rtorrent-*/
./autogen.sh
./configure --with-xmlrpc-c --prefix=/usr
make && make install
cd ..
else
apt-get -y install screen rtorrent
fi
addgroup rtorrent
adduser --gecos "" --ingroup rtorrent --disabled-login rtorrent
[ -d "${rtorrent_data}" ] || mkdir -p "${rtorrent_data}"
[ -d "${rtorrent_media}" ] || mkdir -p "${rtorrent_media}"
chmod a+rwx "${rtorrent_media}"
[ -d "${rtorrent_data}/_control" ] || mkdir "${rtorrent_data}/_control/"
chmod a+rwx "${rtorrent_data}/_control/"
[ -d "${rtorrent_data}/_control/audio" ] || mkdir "${rtorrent_data}/_control/audio/"
chmod a+rwx "${rtorrent_data}/_control/audio/"
[ -d "${rtorrent_data}/_control/video" ] || mkdir "${rtorrent_data}/_control/video/"
chmod a+rwx "${rtorrent_data}/_control/video/"
[ -d "${rtorrent_data}/session" ] || mkdir "${rtorrent_data}/session/"
chmod a+rx "${rtorrent_data}/session/"
chown rtorrent:rtorrent "${rtorrent_data}/session/"
cp rtorrent.sh /etc/init.d/
chmod a+rx /etc/init.d/rtorrent.sh
update-rc.d rtorrent.sh defaults
#[ -f /home/rtorrent/.rtorrent.rc ] || cp rtorrent.rc /home/rtorrent/.rtorrent.rc
rtorrent_media_esc=`echo ${rtorrent_media} | sed -e "s/\([\\/\\+\\.\\\$]\)/\\\\\\\\\\1/g"`
[ -f /home/rtorrent/.rtorrent.rc ] || ( sed -e "s/\\\$rtorrent_download/${rtorrent_media_esc}\\/" rtorrent.rc > /home/rtorrent/.rtorrent.rc )
chmod a+r /home/rtorrent/.rtorrent.rc
#echo "\nrm -f /home/rtorrent/session/rtorrent.lock" >> /etc/rc.local
#sed -i "s/^\\s*exit\\s*0\\s*$/\\[ -f \\/home\\/rtorrent\\/session\\/rtorrent\\.lock \] \\&\\& rm -f \\/home\\/rtorrent\\/session\\/rtorrent\\.lock\\n\\nexit 0\\n/" /etc/rc.local
rtorrent_data_esc=`echo ${rtorrent_data} | sed -e "s/\([\\/\\+\\.\\\$]\)/\\\\\\\\\\1/g"`
sed -i "s/^\\s*exit\\s*0\\s*\$/\\[ -f ${rtorrent_data_esc}\\/session\\/rtorrent\\.lock \] \\&\\& rm -f ${rtorrent_data_esc}\\/session\\/rtorrent\\.lock\\n\\nexit 0\\n/" /etc/rc.local
}
# install transmission-daemon
##############################
i_tbt_pre() {
fg_title="transmission-daemon settings (some as rtorrent)"
while :
do
a_input "Enter path where you want save torrent download" rtorrent_media
a_input "Enter path where you want save torrent session data" rtorrent_data
rtorrent_media=`echo ${rtorrent_media} | sed -e "s/\\/*\$//"`
rtorrent_data=`echo ${rtorrent_data} | sed -e "s/\\/*\$//"`
a_yesno "transmission-daemon settings:\n\nDownloads path: ${rtorrent_media}\nSessions path: ${rtorrent_data}\n\nEntered data correct?" result "yes"
if [ "$result" = "Y" -o "$result" = "y" ] ; then
break
fi
done
}
i_tbt() {
apt-get -y install transmission-daemon
[ -d "${rtorrent_data}" ] || mkdir -p "${rtorrent_data}"
[ -d "${rtorrent_media}" ] || mkdir -p "${rtorrent_media}"
chmod a+rwx "${rtorrent_media}"
[ -d "${rtorrent_data}/_control" ] || mkdir "${rtorrent_data}/_control/"
chmod a+rwx "${rtorrent_data}/_control/"
[ -d "${rtorrent_data}/resume" ] || mkdir "${rtorrent_data}/resume/"
chmod a+rx "${rtorrent_data}/resume/"
chown -R debian-transmission:debian-transmission "${rtorrent_data}/resume/"
[ -d "${rtorrent_data}/torrents" ] || mkdir "${rtorrent_data}/torrents/"
chmod a+rx "${rtorrent_data}/torrents/"
chown -R debian-transmission:debian-transmission "${rtorrent_data}/torrents/"
rm -rf /var/lib/transmission-daemon/info/resume
rm -rf /var/lib/transmission-daemon/info/torrents
ln -s "${rtorrent_data}/resume/" /var/lib/transmission-daemon/info/resume
ln -s "${rtorrent_data}/torrents/" /var/lib/transmission-daemon/info/torrents
rtorrent_media_esc=`echo ${rtorrent_media} | sed -e "s/\([\\/\\+\\.\\\$]\)/\\\\\\\\\\1/g"`
rtorrent_data_esc=`echo ${rtorrent_data} | sed -e "s/\([\\/\\+\\.\\\$]\)/\\\\\\\\\\1/g"`
sed -i "s/^\(\\s*{\)/\\1\\n \"watch-dir\": \"${rtorrent_data_esc}\\/_control\\/\",\\n \"watch-dir-enabled\": true,/" /etc/transmission-daemon/settings.json
sed -i "s/\"download-dir\": [^,]*/\"download-dir\": \"${rtorrent_media_esc}\\/\"/" /etc/transmission-daemon/settings.json
sed -i "s/\"rpc-authentication-required\": [^,]*/\"rpc-authentication-required\": false/" /etc/transmission-daemon/settings.json
invoke-rc.d transmission-daemon reload
}
# install onboard
############################
#read -p "Install on screen keyboard (onboard) [Y/n]?" result
i_onboard() {
apt-get -y onboard
}
# install firefox
############################
#read -p "Install firefox [Y/n]?" result
i_ffox() {
apt-get -y --no-install-recommends install firefox flashplugin-nonfree
[ -d /home/xbmc/scripts ] || mkdir /home/xbmc/scripts/
chmod a+rx /home/xbmc/scripts/
[ -f /home/xbmc/scripts/firefox.sh ] || cat > /home/xbmc/scripts/firefox.sh << EOF
#!/bin/sh
${dm} &
nm-applet --sm-disable &
firefox
killall -9 ${dm}
EOF
chmod a+rx /home/xbmc/scripts/firefox.sh
}
# install chromium
############################
#read -p "Install chromium browser [Y/n]?" result
i_chrome() {
apt-get -y install chromium-browser
[ -d /home/xbmc/scripts ] || mkdir /home/xbmc/scripts/
chmod a+rx /home/xbmc/scripts/
[ -f /home/xbmc/scripts/chrome.sh ] || cat > /home/xbmc/scripts/chrome.sh << EOF
#!/bin/sh
${dm} &
nm-applet --sm-disable &
chromium-browser
killall -9 ${dm}
EOF
chmod a+rx /home/xbmc/scripts/chrome.sh
}
# configure bluetooth
############################
#read -p "Configure bluetooth [Y/n]?" result
c_bluez() {
apt-get -y install bluez bluez-utils bluez-hcidump python-dbus
#modprobe hidp
#cat /etc/modules | grep -q -e "^\\s*hidp\\s*\$" || echo "hidp" >> /etc/modules
#/etc/init.d/bluetooth restart
#hci_device="hci0"
while :
do
list_items=$(hciconfig | grep -e "^\\s*[a-zA-Z]\+[0-9]\+" | sed -e "s/^\\s*\([a-zA-Z]\+[0-9]\+\).*\$/\\1/" |
(
n=1
while read line
do
echo "\"${line}\" \"Bluetooth interface ${n}\""
n=$((n+1))
done
echo "rescan \"Scan again for bluetooth adapters...\""
)
)
if [ -z "${list_items}" ] ; then
break
fi
tempfile=`mktemp 2>/dev/null` || tempfile=/tmp/test$$
#trap "rm -f $tempfile" 0 1 2 5 15
eval ${DIALOG} --backtitle \"${back_title}\" --clear --title \"Bluetooth HID device configuration\" --menu \"Select bluetooth inteface\" 20 75 13 ${list_items} 2>$tempfile
if [ $? -ne 0 ] ; then
rm -f $tempfile
break
fi
hci_device=$(cat $tempfile)
rm -f $tempfile
if [ "${hci_device}" != "rescan" ] ; then
#cat >> /var/lib/bluetooth/xx:xx:xx:xx:xx:xx/config << EOF
#mode connectable
#modeon connectable
#discovto 0
#pairto 0
#EOF
hciconfig ${hci_device} up
#${DIALOG} --backtitle "${back_title}" --clear --title "XBMC configuration" --msgbox "Initialise pairing mode on connected device and press Enter..." 10 75
a_msgbox "Initialise pairing mode on connected device and press Enter..."
#read -p "Initialise pairing mode on connected device and press Enter..." result
echo "\n\nScanning for bluetooth devices...\n"
list_items=$(hcitool scan | grep -v "^Scanning \\.\\.\\.\$" |
(
n=1
while read line
do
#echo "${n} \"${line}\""
echo $line | sed -e "s/^\\s*\([^ ]\+\)\\s\+\(.*\)\$/\"\\1\" \"\\2\"/"
n=$((n+1))
done
)
)
if [ -n "${list_items}" ] ; then
tempfile=`mktemp 2>/dev/null` || tempfile=/tmp/test$$
eval ${DIALOG} --backtitle \"${back_title}\" --clear --title \"Bluetooth HID device configuration\" --menu \"Select HID device\" 20 75 13 ${list_items} 2>$tempfile
if [ $? -eq 0 ] ; then
dev_addr=$(cat $tempfile)
if [ "${dev_addr}" != "rescan" ] ; then
if [ -f /usr/share/doc/bluez/examples/simple-agent ] ; then
/usr/share/doc/bluez/examples/simple-agent ${hci_device} ${dev_addr}
else
bluez-simple-agent ${hci_device} ${dev_addr}
fi
if [ -f /usr/share/doc/bluez/examples/test-device ] ; then
/usr/share/doc/bluez/examples/test-device trusted ${dev_addr} yes
else
bluez-test-device trusted ${dev_addr} yes
fi
if [ -f /usr/share/doc/bluez/examples/test-input ] ; then
/usr/share/doc/bluez/examples/test-input connect ${dev_addr}
else
bluez-test-input connect ${dev_addr}
fi
fi
fi
rm -f $tempfile
fi
fi
done
}
# configure console
############################
#read -p "Install cyrillic for console [Y/n]?" result
i_cyrillic() {
apt-get -y install console-data
apt-get -y install console-cyrillic
}
# install apache
############################
#read -p "Install HTTP server Apache2 [Y/n]?" result
i_httpd() {
apt-get -y install apache2 libapache2-mod-php5
}
# install proftpd
############################
#read -p "Install FTP server ProFTPd [Y/n]?" result
i_ftpd() {
apt-get -y install proftpd
}
# install rutorrent
############################
#read -p "Install web-interface for rtorrent (rutorrent) [Y/n]?" result
i_rutor() {
wget http://rutorrent.googlecode.com/files/rutorrent-3.3.tar.gz
wget http://rutorrent.googlecode.com/files/plugins-3.3.tar.gz
tar -xzvf rutorrent-3.3.tar.gz -C /var/www/
tar -xzvf plugins-3.3.tar.gz -C /var/www/rutorrent/
chown -R root:www-data /var/www/rutorrent
chmod -R g+w /var/www/rutorrent
sed -i -e "s/^\(\\s*\\\$scgi_port\\s*=\\s*\)[0-9]\+\(\\s*;\\s*\)\$/\\15001\\2/" /var/www/rutorrent/conf/config.php
cat > /var/www/rutorrent/plugins/diskspace/action.php << EOF
<?php
require_once( '../../php/util.php' );
require_once( '../../php/xmlrpc.php' );
\$req = new rXMLRPCRequest( new rXMLRPCCommand('get_directory') );
if(\$req->success())
{
\$dir=\$req->val[0];
}
else
{
\$dir=\$topDirectory;
}