-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstallVinylstation.sh
798 lines (710 loc) · 33.3 KB
/
installVinylstation.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
#!/bin/bash
#================ Function to check the status of the last executed command
check_status() {
if [ $? -ne 0 ]; then
echo -e "\e[1;41mError: $1\e[0m"
exit 1
fi
}
#=============Preliminaries & Initialise OPAM and build bare switch (=compiler)=======
# Get the username of the current user
echo -e "Hello,\e[1;32m $USER\e[0m! Let's get started with \e[1;42m VinylStation Installation \e[0m"
#========FFMpeg and fdkaac compilation works with 64bit Bullseye distrib============
echo -e "\e[1;42mUpdate system and install prerequisites\e[0m"
sudo apt-get update && sudo apt-get -y upgrade
check_status "System update and upgrade failed."
sudo apt-get -y install icecast2 nginx libnginx-mod-rtmp pulseaudio mercurial git darcs bubblewrap screen build-essential libvorbis-dev libmp3lame-dev libasound2-dev libgtk-3-dev libssl-dev libasound2-plugins
check_status "Install prerequisites failed."
echo -e "\e[1;42mUpdate system and install prerequisites\e[0m :\e[1;32m Success \e[0m"
#========Get rid of every audio device except the USB interface=========
sudo sed -i '/^dtparam=audio=on$/c\dtparam=audio=off' /boot/firmware/config.txt
check_status "Disable internal audio devices failed."
sudo sed -i '/^dtoverlay=vc4-kms-v3d$/c\#dtoverlay=vc4-kms-v3d' /boot/firmware/config.txt
check_status "Disable internal audio devices failed."
sudo sed -i '/^max_framebuffers=2$/c\#max_framebuffers=2' /boot/firmware/config.txt
echo -e "\e[1;41mGet rid of every audio device except the USB interface\e[0m :\e[1;32m Success \e[0m"
#===============Daemonise Pulseaudio and have it spawn automatically upon system start
sudo sed -i '/^; daemonize = no$/c\daemonize = yes' /etc/pulse/daemon.conf
sudo sed -i '/^; autospawn = yes$/c\autospawn = yes' /etc/pulse/client.conf
echo -e "\e[1;42mDaemonise Pulseaudio and have it spawn automatically upon system start \e[0m :\e[1;32m Success \e[0m"
#===============Get OPAM and prepare switch
echo -e "\e[1;42mGet OPAM and prepare switch\e[0m"
bash -c "sh <(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)"
check_status "Install OPAM failed."
opam init -y --bare --shell-setup --disable-sandboxing
opam switch create liquidsoap ocaml-base-compiler.4.14.2 -y
check_status "Create OPAM switch failed."
eval "$(opam env --switch=liquidsoap)"
#export IS_SNAPSHOT=false;
echo -e "\e[1;42mGet OPAM and prepare switch \e[0m : \e[1;32mSuccess\e[0m"
#===============Create and prepare relevant directories and permissions
sudo mkdir /etc/liquidsoap;
sudo mkdir /etc/liquidsoap/hls;
sudo mkdir /etc/liquidsoap/hls/persist
sudo touch /etc/liquidsoap/vinylfromWax.liq;
sudo chmod 666 /etc/liquidsoap/vinylfromWax.liq;
sudo mkdir /var/log/liquidsoap;
sudo touch /var/log/liquidsoap/VinylfromWax.log;
sudo chmod 777 /var/log/liquidsoap/VinylfromWax.log;
sudo touch /lib/systemd/system/liquidsoap.service;
sudo touch /var/www/html/song.json
sudo chown $USER:$USER /var/www/html/song.json
sudo chmod 777 /var/www/html/song.json
sudo mkdir /var/www/html/hls
sudo mkdir /var/www/html/hls/persist
sudo chown $USER:$USER -R /var/www/html/hls
echo -e "\e[1;42mCreate and prepare relevant directories and permissions \e[0m : \e[1;32mSuccess\e[0m"
#================Configure icecast.xml and enable Iceacast service===============
sudo tee /etc/icecast2/icecast.xml <<EOF
<icecast>
<!-- location and admin are two arbitrary strings that are e.g. visible
on the server info page of the icecast web interface
(server_version.xsl). -->
<location>Earth</location>
<admin>icemaster@localhost</admin>
<!-- IMPORTANT!
Especially for inexperienced users:
Start out by ONLY changing all passwords and restarting Icecast.
For detailed setup instructions please refer to the documentation.
It's also available here: http://icecast.org/docs/
-->
<limits>
<clients>100</clients>
<sources>4</sources>
<queue-size>524288</queue-size>
<client-timeout>30</client-timeout>
<header-timeout>15</header-timeout>
<source-timeout>10</source-timeout>
<!-- If enabled, this will provide a burst of data when a client
first connects, thereby significantly reducing the startup
time for listeners that do substantial buffering. However,
it also significantly increases latency between the source
client and listening client. For low-latency setups, you
might want to disable this. -->
<burst-on-connect>0</burst-on-connect>
<!-- same as burst-on-connect, but this allows for being more
specific on how much to burst. Most people won't need to
change from the default 65535. Applies to all mountpoints -->
<burst-size>0</burst-size>
</limits>
<authentication>
<!-- Sources log in with username 'source' -->
<source-password>vinylstation</source-password>
<!-- Relays log in with username 'relay' -->
<relay-password>VinylStation</relay-password>
<!-- Admin logs in with the username given below -->
<admin-user>admin</admin-user>
<admin-password>VinylStation</admin-password>
</authentication>
<!-- set the mountpoint for a shoutcast source to use, the default if not
specified is /stream but you can change it here if an alternative is
wanted or an extension is required
<shoutcast-mount>/live.nsv</shoutcast-mount>
-->
<!-- Uncomment this if you want directory listings -->
<!--
<directory>
<yp-url-timeout>15</yp-url-timeout>
<yp-url>http://dir.xiph.org/cgi-bin/yp-cgi</yp-url>
</directory>
-->
<!-- This is the hostname other people will use to connect to your server.
It affects mainly the urls generated by Icecast for playlists and yp
listings. You MUST configure it properly for YP listings to work!
-->
<hostname>localhost</hostname>
<!-- You may have multiple <listen-socket> elements -->
<listen-socket>
<port>8000</port>
<!-- <bind-address>127.0.0.1</bind-address> -->
<!-- <shoutcast-mount>/stream</shoutcast-mount> -->
</listen-socket>
<!--
<listen-socket>
<port>8080</port>
</listen-socket>
-->
<!--
<listen-socket>
<port>8443</port>
<ssl>1</ssl>
</listen-socket>
-->
<!-- Global header settings
Headers defined here will be returned for every HTTP request to Icecast.
The ACAO header makes Icecast public content/API by default
This will make streams easier embeddable (some HTML5 functionality needs it).
Also it allows direct access to e.g. /status-json.xsl from other sites.
If you don't want this, comment out the following line or read up on CORS.
-->
<http-headers>
<header name="Access-Control-Allow-Origin" value="*" />
</http-headers>
<!-- Relaying
You don't need this if you only have one server.
Please refer to the documentation for a detailed explanation.
-->
<!--<master-server>127.0.0.1</master-server>-->
<!--<master-server-port>8001</master-server-port>-->
<!--<master-update-interval>120</master-update-interval>-->
<!--<master-password>hackme</master-password>-->
<!-- setting this makes all relays on-demand unless overridden, this is
useful for master relays which do not have <relay> definitions here.
The default is 0 -->
<!--<relays-on-demand>1</relays-on-demand>-->
<!--
<relay>
<server>127.0.0.1</server>
<port>8080</port>
<mount>/example.ogg</mount>
<local-mount>/different.ogg</local-mount>
<on-demand>0</on-demand>
<relay-shoutcast-metadata>0</relay-shoutcast-metadata>
</relay>
-->
<!-- Mountpoints
Only define <mount> sections if you want to use advanced options,
like alternative usernames or passwords
-->
<!-- Default settings for all mounts that don't have a specific <mount type="normal">.
-->
<!--
<mount type="default">
<public>0</public>
<intro>/server-wide-intro.ogg</intro>
<max-listener-duration>3600</max-listener-duration>
<authentication type="url">
<option name="mount_add" value="http://auth.example.org/stream_start.php"/>
</authentication>
<http-headers>
<header name="foo" value="bar" />
</http-headers>
</mount>
-->
<!-- Normal mounts -->
<!--
<mount type="normal">
<mount-name>/example-complex.ogg</mount-name>
<username>othersource</username>
<password>hackmemore</password>
<max-listeners>1</max-listeners>
<dump-file>/tmp/dump-example1.ogg</dump-file>
<burst-size>65536</burst-size>
<fallback-mount>/example2.ogg</fallback-mount>
<fallback-override>1</fallback-override>
<fallback-when-full>1</fallback-when-full>
<intro>/example_intro.ogg</intro>
<hidden>1</hidden>
<public>1</public>
<authentication type="htpasswd">
<option name="filename" value="myauth"/>
<option name="allow_duplicate_users" value="0"/>
</authentication>
<http-headers>
<header name="Access-Control-Allow-Origin" value="http://webplayer.example.org" />
<header name="baz" value="quux" />
</http-headers>
<on-connect>/home/icecast/bin/stream-start</on-connect>
<on-disconnect>/home/icecast/bin/stream-stop</on-disconnect>
</mount>
-->
<!--
<mount type="normal">
<mount-name>/auth_example.ogg</mount-name>
<authentication type="url">
<option name="mount_add" value="http://myauthserver.net/notify_mount.php"/>
<option name="mount_remove" value="http://myauthserver.net/notify_mount.php"/>
<option name="listener_add" value="http://myauthserver.net/notify_listener.php"/>
<option name="listener_remove" value="http://myauthserver.net/notify_listener.php"/>
<option name="headers" value="x-pragma,x-token"/>
<option name="header_prefix" value="ClientHeader."/>
</authentication>
</mount>
-->
<fileserve>1</fileserve>
<paths>
<!-- basedir is only used if chroot is enabled -->
<basedir>/usr/share/icecast2</basedir>
<!-- Note that if <chroot> is turned on below, these paths must both
be relative to the new root, not the original root -->
<logdir>/var/log/icecast2</logdir>
<webroot>/usr/share/icecast2/web</webroot>
<adminroot>/usr/share/icecast2/admin</adminroot>
<!-- <pidfile>/usr/share/icecast2/icecast.pid</pidfile> -->
<!-- Aliases: treat requests for 'source' path as being for 'dest' path
May be made specific to a port or bound address using the "port"
and "bind-address" attributes.
-->
<!--
<alias source="/foo" destination="/bar"/>
-->
<!-- Aliases: can also be used for simple redirections as well,
this example will redirect all requests for http://server:port/ to
the status page
-->
<alias source="/" destination="/status.xsl"/>
<!-- The certificate file needs to contain both public and private part.
Both should be PEM encoded.
<ssl-certificate>/usr/share/icecast2/icecast.pem</ssl-certificate>
-->
</paths>
<logging>
<accesslog>access.log</accesslog>
<errorlog>error.log</errorlog>
<!-- <playlistlog>playlist.log</playlistlog> -->
<loglevel>3</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error -->
<logsize>10000</logsize> <!-- Max size of a logfile -->
<!-- If logarchive is enabled (1), then when logsize is reached
the logfile will be moved to [error|access|playlist].log.DATESTAMP,
otherwise it will be moved to [error|access|playlist].log.old.
Default is non-archive mode (i.e. overwrite)
-->
<!-- <logarchive>1</logarchive> -->
</logging>
<security>
<chroot>0</chroot>
<!--
<changeowner>
<user>nobody</user>
<group>nogroup</group>
</changeowner>
-->
</security>
</icecast>
EOF
sudo systemctl enable icecast2
echo -e "\e[1;42mConfigure Icecast and enable service \e[0m : \e[1;32mSuccess\e[0m"
#================ Create LIQUIDSOAP Streaming Engine configuration with HLS output ===========
sudo tee /etc/liquidsoap/vinylfromWax.liq <<EOF
#!/home/$USER/.opam/default/bin/liquidsoap
# set the path and permissions for the logfile
settings.log.file.path := "/var/log/liquidsoap/VinylfromWax.log"
settings.log.file.perms := 777
settings.log.unix_timestamps := false
settings.encoder.metadata.cover := ["pic", "apic", "metadata_block_picture"]
settings.encoder.metadata.export := ["artist", "title", "album", "genre", "year", "url", "apic", "pic", "coverart"]
#settings.charset.encodings := ["ISO-8859-1"] #url encoding worked with this setting
#==============ALSA Settings==========
#settings.alsa.alsa_buffer := 0
#settings.alsa.periods := 0
#==============Input from soundcard
#s = (input.alsa(device = "pcm.default", self_sync=true):source(audio=pcm(stereo)))
s = input.pulseaudio(fallible=false)
s = amplify(2.2 ,s)
s = bass_boost(frequency=140.0 ,gain=1.2 ,s)
#======================FORMATS======================================================
#-----------------MP3 Stream with floating point encoder
#f = %mp3.cbr(samplerate=44100,bitrate=320)
f = %ffmpeg(format="mp3", %audio(codec="libmp3lame", samplerate=44100, sample_format="s16", channels=2, b="320k"))
#-----------------FLAC stream with OGG encapsulation
#fflac = %ogg(%flac(samplerate=44100,channels=2,compression=5,bits_per_sample=16))
#fflac = %ffmpeg(format="ogg", %audio(codec="flac", samplerate=44100, sample_format="s16", channels=2))
#-----------------MP3 Stream with fixed point encoder SHINE
#f = %shine(channels=2,samplerate=44100,bitrate=320)
#-----------------OGG VORBIS stream
#fvorbis = %ogg(%vorbis.cbr(samplerate=44100, channels=2, bitrate=128))
fvorbis = %ffmpeg(format="ogg", %audio(codec="libvorbis", samplerate=44100, sample_format="s16", channels=2, b="250k"))
#-----------------ACC stream for SONOS
#faac = %fdkaac(channels=2, samplerate=44100, bandwidth="auto", bitrate=96, afterburner=false, transmux="adts", sbr_mode=false)
#faac = %ffmpeg(format="adts", %audio(codec="libfdk-aac", samplerate=44100, sample_format="s16", channels=2, b="250k"))
#faac = %ffmpeg(format="adts", %audio(codec="aac", samplerate=44100, sample_format="s16", channels=2, b="192k"))
#===================================================================================
#=============Define a reference to hold coverart URL information============
current_coverart = ref ("")
#======Prepare source to accept metadata injection=========
s = insert_metadata(s)
#================ Metadata grab and update section =========================================
#======== Launch songrec to detect one song, output as JSON, insert metadata into source stream========
def metadataupdater()
json = process.read("/usr/sbin/songrec recognize --json")
file.write(data=json, "/var/www/html/song.json")
let json.parse (parsed_data : {
track : {
subtitle : string,
title : string,
genres : {
primary : string
},
images : {
coverart : string,
},
sections : [
{
metadata : [{text : string, title : string}]?,
metapages : [{caption : string, image : string}]?,
tabname : string,
type : string,
url : string?
}
],
type : string,
url : string?,
}
}) = json
let title = parsed_data.track.title
let subtitle = parsed_data.track.subtitle
let coverart = parsed_data.track.images.coverart
let genre = parsed_data.track.genres.primary
let sections = parsed_data.track.sections
#code provided by @vitoyucepi to get the deeply nested metadata under sections
metadata_list =
try
metadata_section = list.find(fun(section) -> section.metadata != null(), sections)
list.map(
fun(metadata_item) -> (metadata_item.title, metadata_item.text),
null.get(metadata_section.metadata)
)
catch err do
log.important("Metadata processing failed: #{err}")
[]
end
let album = metadata_list["Album"]
#let label = metadata_list["Label"]
let year = metadata_list["Released"]
print ("Genre: #{genre}")
print("Album: #{album}")
#print("Label: #{label}")
print("Year: #{year}")
# print("Found track #{title}, artist is #{subtitle}, cover art url is #{coverart}")
pict = process.read("curl #{coverart} | base64 -i")
#Here are different options to prepare the URL coverart string for SONOS coverart injection. SONOS requires two string parts separated by a NUL character.
#See https://docs.sonos.com/docs/supported-audio-formats#tag/playback/operation/Playback-LoadContent-GroupId for information. Beware the typos in their WXXX tag example: neither include <> nor "" within the string!
current_coverart := 'artworkURL_400x\x00'^coverart #This Hex format NUL character formatting works!
#current_coverart := '<artworkURL_400x␀'^coverart^'>' #NUL CHaracter
#current_coverart := 'artworkURL_400x\u{0000}'^coverart #UNICODE NUL CHaracter
s.insert_metadata([("title", title),("artist", subtitle),("pic", pict),("coverart", coverart),("album", album),("year", year),("genre", genre),("url",current_coverart())])
#print("HLS Current_Coverart tag reads #{current_coverart()}")
end
#This is an intermediate function to be called from blank.detect and output.icecast on_start.
#This intermediate function runs the actual mediadata updater in a thread, so that the
#metadata update does *not* interrupt the stream.
def handleblank()
thread.run(metadataupdater)
end
silent = ref(false)
s = blank.detect(
threshold=-21.,
max_blank=1.,
on_noise=handleblank,
{silent := true},
s)
#==============CREATE HTTP SERVER FOR METADATA OUTPUT================
meta = ref([])
# s = some source
s.on_metadata(fun (m) -> meta := m)
# Return the json content of meta
def get_meta(_, response) =
response.json(meta())
end
# Register get_meta at port 700
harbor.http.register(port=7000,method="GET","/getmeta",get_meta)
#===========PREPARE HLS SETTINGS=================
aac_lofi = %ffmpeg(
format="adts",
%audio(
codec="aac",
samplerate=44100,
channels=2,
b="96k")).{
# Adds an extra tag to this stream.
id3_version=4,
replay_id3=true,
}
aac_midfi = %ffmpeg(
format="adts",
%audio(
codec="aac",
samplerate=44100,
channels=2,
b="128k",
)
).{
# Adds an extra tag to this stream.
id3_version=4,
replay_id3=true,
}
aac_hifi = %ffmpeg(
format="adts", #metadata successfully sent with adts
%audio(
codec="aac",
samplerate=44100,
channels=2,
b="256k",
)
).{
# Adds an extra tag to this stream.
id3_version=4,
replay_id3=true,
#extra_tags = ["WXXX", "album", "genre", "year"]
#extra_tags = ["WXXX"]
#extra_tags = ['#EXTINF:-1 tvg-logo="http://192.168.39.19/template.jpg", #EXTIMG: http://192.168.39.19/template.jpg']
}
# Put them all together
hls_streams = [
("aac_lofi", aac_lofi),
("aac_midfi", aac_midfi),
("aac_hifi", aac_hifi)]
def hls_segment_name(metadata) =
timestamp = int_of_float(time())
let {stream_name, duration, position, extname} = metadata
"#{stream_name}_#{duration}_#{timestamp}_#{position}.#{extname}"
end
#=================OUTPUT==================
#-------------HLS Output via harbor - not recommended by savonet, but works here without issues-------------
output.harbor.hls(playlist="vinylstation.m3u8",
segment_duration=0.5,
segments=6,
segments_overhead=3,
segment_name=hls_segment_name,
port=8080,
persist_at="/etc/liquidsoap/hls/persist",
#"/etc/liquidsoap/hls",
hls_streams,
s)
#<
#-------------HLS Output via file-------------
output.file.hls(playlist="vinylstation.m3u8",
segment_duration=2.0,
segments=10,
segments_overhead=5,
segment_name=hls_segment_name,
#port=8080,
persist_at="/var/www/html/hls/persist",
"/var/www/html/hls",
hls_streams,
s)
>#
#---------------Icecast Output-------------------
#---------------------MP3------------------------
output.icecast(f,
host = "127.0.0.1",
port = 8000,
password = "vinylstation",
mount = "vinyl",
name = "Vinyl from Wax",
id="Vinyl Station",
on_start=handleblank,
send_icy_metadata=true,
description="VinylStation - powered by Technics turntables",
#url="http://IP-ADDRESS”,
s)
#-----------------OGG/Vorbis--------------------
output.icecast(fvorbis,
host = "127.0.0.1",
port = 8000,
password = "vinylstation",
mount = "vinylogg",
name = "Vinyl from Wax",
id="Vinyl Station",
#send_icy_metadata=true,
description="VinylStation - powered by Technics turntables",
s)
#<========== Disabled Outputs ============
output.icecast(fvorbis,
host = "127.0.0.1",
port = 8000,
password = "vinylstation",
mount = "vinylogg.ogg",
name = "Vinyl from Wax",
id="Vinyl Station",
#send_icy_metadata=true,
description="VinylStation - powered by Technics turntables",
s)
output.icecast(fflac,
host = "127.0.0.1",
port = 8000,
password = "vinylstation",
mount = "vinylflac",
name = "Vinyl from Wax",
id="Vinyl Station",
description="VinylStation - powered by Technics turntables",
s)
output.icecast(faac,
host = "127.0.0.1",
port = 8000,
password = "vinylstation",
mount = "vinylaac",
name = "Vinyl from Wax",
id="Vinyl Station",
#send_icy_metadata=true,
description="VinylStation - powered by Technics turntables",
s)
================================>#
EOF
sudo sed -i "s/\$USER/$USER/g" /etc/liquidsoap/vinylfromWax.liq
echo -e "\e[1;42mCreate LIQUIDSOAP Streaming Engine configuration with HLS output\e[0m : \e[1;32mSuccess\e[0m"
#================Congifure sound interface for liquidsoap=================
sudo tee /etc/asound.conf <<EOF
#goes into /etc/
#This config is for use with PulseAudio
pcm.!default {
type hw
card 0
device 0
format S16_LE
channels 2
rate 44100
period_size 1024
buffer_size 4096
}
#What you see here below are configs that worked well with ALSA
#pcm.!default {
# type plug
# slave.pcm "liquidsoap"
#}
#pcm.liquidsoap {
# type dsnoop
# ipc_key 5978293 # Unique IPC key
# ipc_key_add_uid yes
# slave {
# pcm "hw:0,0"
# channels 2
# rate 44100 # Set sample rate to 44.1 kHz
# period_size: 661
# buffer_size: 2644
# #period_size 1024 # Frames per period (low latency: 23.2 ms)
# #buffer_size 4096 # Total buffer size (92.9 ms total latency)
# }
# bindings {
# 0 0
# 1 1
# }
#}
EOF
echo -e "\e[1;42mCreate ALSA configuration file, PulseAudio version - see notes inside /etc/asound.conf \e[0m : \e[1;32mSuccess\e[0m"
#========================= Configure liquidsoap.service
sudo tee /lib/systemd/system/liquidsoap.service <<EOF
#goes into /lib/systemd/system/
[Unit]
Description=Liquidsoap Stream Engine
After=multi-user.target
[Service]
ExecStart=/home/$USER/.opam/liquidsoap/bin/liquidsoap /etc/liquidsoap/vinylfromWax.liq
Restart=always
User=$USER
[Install]
WantedBy=multi-user.target
EOF
sudo sed -i "s/\$USER/$USER/g" /lib/systemd/system/liquidsoap.service
echo -e "\e[1;42mConfigure liquidsoap.service\e[0m : \e[1;32mSuccess\e[0m"
#=================================Configure NGINX with HLS streamer
sudo tee /etc/nginx/sites-available/HLS-vinylstation.conf <<EOF
#based on https://github.com/radiofrance/rf-liquidsoap/blob/master/example/nginx/hls.conf
server {
listen 8080;
server_name _;
root /var/www/html/hls;
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
location ~ \.(ts|m3u8)$ {
add_header Allow "GET, HEAD" always;
if ( $request_method !~ ^(GET|HEAD)$ ) {
return 405;
}
root /var/www/html/hls;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET';
add_header 'Access-Control-Allow-Headers' '*';
location ~ \.(ts)$ {
add_header 'Cache-Control' 'public, max-age=660';
}
location ~ (lofi|midfi|hifi)\.(m3u8)$ {
add_header 'Cache-Control' 'max-age=1';
}
location ~ \.(m3u8)$ {
add_header 'Cache-Control' 'max-age=600';
}
}
location / {
autoindex on;
autoindex_format html;
}
}
EOF
#sudo ln -s /etc/nginx/sites-enabled/ /etc/sites-available/HLS-vinylstation.conf
echo -e "\e[1;42mConfigure NGINX with HLS streamer\e[0m : \e[1;31mNOT ACTIVATED\e[0m \n\e[1;43mThe configuration file is ready, but is not enabled, as liquidsoap harbor serves the files.\e[0m\nIf you want to activate the NGINX HLS server configuration:\n1. In the liquidsoap configuration file: \e[1;31m disable liquidsoap output.harbor.hls,\e[1;32m activate output.file.hls\e[0m \n2. run this command: \e[1;33mln -s /etc/nginx/sites-enabled/ /etc/sites-available/HLS-vinylstation.conf\e[0m"
#=======================Get FFMPEG Source & Compile====================
echo -e "\e[1;42mPrepare the long and winding road to compiling FFmpeg with aac support\e[0m"
sudo apt-get -y install autoconf automake build-essential cmake doxygen libtool pkg-config python3-dev python3-pip git
cd ~
mkdir ~/ffmpeg-libraries
#----------Compile AAC Support
echo -e "\e[1;42mGet FFmpeg fdk-aac libraries\e[0m"
git clone --depth 1 https://github.com/mstorsjo/fdk-aac.git ~/ffmpeg-libraries/fdk-aac \
&& cd ~/ffmpeg-libraries/fdk-aac \
&& autoreconf -fiv \
&& ./configure \
&& make -j$(nproc) \
&& sudo make install ;
cd ~ ;
echo -e "\e[1;42mGet FFmpeg source (v.7.1)\e[0m"
wget https://ffmpeg.org/releases/ffmpeg-7.1.tar.xz;
tar -xf ffmpeg-7.1.tar.xz ;
cd ffmpeg-7.1 ;
echo -e "\e[1;42mCompile FFmpeg with fdk-aac libvorbis libmp3lame flac\e[0m"
./configure --enable-shared --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-pic \
&& make && sudo make install && sudo ldconfig
echo -e "\e[1;42mCompile FFmpeg with fdk-aac libvorbis libmp3lame flac\e[0m : \e[1;32mSuccess\e[0m"
#=======================Get SONGREC Source & compile===================
echo -e "\e[1;42mGet songrec opensource Shazam client and compile\e[0m"
sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get -y install mercurial git darcs bubblewrap
curl https://sh.rustup.rs -sSf | sh
echo "export PATH="$HOME/.cargo/bin:$PATH"" | tee -a ~/.profile ~/.bashrc
export PATH="$HOME/.cargo/bin:$PATH"
source ~/.bashrc
sudo apt install build-essential libasound2-dev libgtk-3-dev libssl-dev -y
cd ~
git clone https://github.com/marin-m/songrec
cd songrec
cargo build --release --no-default-features -F ffmpeg,mpris
sudo mv ~/songrec/target/release/songrec /usr/sbin/
echo -e "\e[1;42mGet songrec opensource Shazam client and compile\e[0m : \e[1;32mSuccess\e[0m"
#=======================Get liquidsoap rolling release source & compile===================
echo -e "\e[1;42mGet liquidsoap rolling release source & compile\e[0m"
cd ~
opam pin -ny git+https://github.com/savonet/liquidsoap
check_status "Pin Liquidsoap repository failed."
o
#Line below generates some package conflicts in recent versions
#opam install -y ocurl taglib mad lame vorbis cry alsa pulseaudio shine flac ffmpeg liquidsoap
#Following line prefers FFmpeg for lame, vorbis
opam install -y ocurl taglib mad lame cry alsa pulseaudio shine ffmpeg liquidsoap
check_status "Install Liquidsoap and dependencies failed."
sudo systemctl enable liquidsoap.service
echo -e "\e[1;42mGet liquidsoap rolling release source & compile : \e[1;32mSuccess\e[0m"
echo -e "\e[1;42mVinylstation successfully installed\e[0m\n
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▓▒░░░░░░░░░░░░░░░
░░░░░░░░▒▒▓▒▒▒▒▓▒▒▒▒▒▒▓▓▒▒▒▒▒▒░░░░░░▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒░░░░░░▓▓▓▓▓▓▓▒░░░░░░░░
░░░░░░░▒██░░░░░▓███▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓██████████▓░▒░░░░░▒██████▒░░░░░░░
░░░░░░░███▓▓▒▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓███▓▓█▓▒░░░░▒▒░░▓▒▓██▓░░░░░░░
░░░░░░▒█████▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓█░░▒▒░▒█░░░▒▓▒▓██░░░░░░░
░░░░░░▓███▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓██▓▒▒▒▒░░▒▒█▓████▓░░░░░░
░░░░░░██▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▒▓▒▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█████▓▓░█████████░░░░░░
░░░░░▓█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▒▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓█████▒░▓███████▒░░░░░
░░░░░█▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██████░░████████░░░░░
░░░░▒█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓░▒▒▒█████▓░▓█▓▓▓▓███▒░░░░
░░░░██▒▒▓▒▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▒▒▒▒▒███▒░░▓███▓▓█▓███░░░░
░░░▒███▒▒▒▒▒▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▒▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▒▒▒▒▒██▓▓▓▒▓████▓▒▒▒███▒░░░
░░░▓▓▓▓▓▒▒▒▒░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▒░▒▒▒▒▓▓▒▓▓███████▓▒░░▓██▓░░░
░░░█▒▒▒▒▒▒░▒▒▒░▒▒▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▒▒░▒▒▒▒▒███▓▓▓█████████▓█▓▓███░░░
░░▓█▓▒░▒▒██▓▒▒▒▒▒▒▒▒▒▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▒▒░░░▒▒▒▒▒▓█████████████████▓█▓████▓░░
░░█▓▒▒▒▒▒▒▓███▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░▒▒▒░░░▒▓▓████████████████████████████░░
░▒█▒░░░░░░▒█▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░▒▓█████████████████████████████▒░
░██▓▓▓▓▓▓▓██▓▓▓▓▓▓▓▓█████▓▓▓▓▓▓▓▓▓▓▓▓▓▓██████▓▓▓▓██████████████████████████████░
░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░
░▒▓▓▓▓█████████████████████████████████████████████████████████████████████████░
░░▓▓████████████████▓█▓▓▓▓███████████████████████████████████████████████████▓▒░
░░░░▒▓▓██▓▓█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▓▓▓███▓▒░░░
░░░░▓██████▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓██████▒░░░
"
# 10-second countdown before reboot
for i in {10..1}; do
echo -e "\e[1;31m System reboot in $i \e[0m seconds."
sleep 1
done
# Reboot the system to apply all configurations
sudo reboot