|
@@ -1,6 +1,5 @@
|
1
|
1
|
#!/bin/bash
|
2
|
2
|
|
3
|
|
-
|
4
|
3
|
##### FUNCTIONS #####
|
5
|
4
|
|
6
|
5
|
log() {
|
|
@@ -9,6 +8,21 @@ log() {
|
9
|
8
|
echo "[$date]" $1
|
10
|
9
|
}
|
11
|
10
|
|
|
11
|
+parse_arg() {
|
|
12
|
+ # Echoes the value of a given parameter in a given configuration file
|
|
13
|
+ value=$(cat $1 | grep -E "^$2" | cut -d"=" -f2)
|
|
14
|
+ value=$(echo $value | sed "s,^\s+,,")
|
|
15
|
+ echo $value
|
|
16
|
+}
|
|
17
|
+
|
|
18
|
+check_url() {
|
|
19
|
+ # Check if URL is starting with "http(s)://"
|
|
20
|
+ # Returns the same code as grep, which is 1 if incorrect,
|
|
21
|
+ # 0 if correct
|
|
22
|
+ echo $1 | grep -E "https?\://"
|
|
23
|
+ return $?
|
|
24
|
+}
|
|
25
|
+
|
12
|
26
|
play_stream() {
|
13
|
27
|
# Reset playback state
|
14
|
28
|
curl -s -d '{"jsonrpc": "2.0", "id": 1, "method": "core.playback.stop"}' http://localhost:6680/mopidy/rpc > /dev/null
|
|
@@ -33,22 +47,6 @@ stop_stream() {
|
33
|
47
|
log "Stream stopped"
|
34
|
48
|
}
|
35
|
49
|
|
36
|
|
-parse_arg() {
|
37
|
|
- # Echoes the value of a given parameter in a given configuration file
|
38
|
|
- value=$(cat $1 | grep -E "^$2" | cut -d"=" -f2)
|
39
|
|
- value=$(echo $value | sed "s,^\s+,,")
|
40
|
|
- echo $value
|
41
|
|
-}
|
42
|
|
-
|
43
|
|
-check_url() {
|
44
|
|
- # Check if URL is starting with "http(s)://"
|
45
|
|
- # Returns the same code as grep, which is 1 if incorrect,
|
46
|
|
- # 0 if correct
|
47
|
|
- echo $1 | grep -E "https?\://"
|
48
|
|
- return $?
|
49
|
|
-}
|
50
|
|
-
|
51
|
|
-
|
52
|
50
|
##### PROGRAM #####
|
53
|
51
|
|
54
|
52
|
if [[ $# -eq 0 || ! -f $1 ]]; then
|