Browse Source

Merge branch 'mpd_check' into pr_2

/\/ \-/ ❭❬ 5 years ago
parent
commit
d5b4caa102
1 changed files with 27 additions and 0 deletions
  1. 27
    0
      check.sh

+ 27
- 0
check.sh View File

@@ -521,3 +521,30 @@ check_ssh_nc() {
521 521
 		fail "Bad replie from $host:$port : '$rep'"
522 522
 	fi
523 523
 }
524
+
525
+
526
+check_mpc() {
527
+    # check_mpc [$host [$port] ]
528
+    # tests if you can contact an MPD server in a client way
529
+    # returns the current state of the server
530
+
531
+	host=$1
532
+	port=$2
533
+
534
+	if [ -z "$host" ]
535
+	then
536
+		host=127.0.0.1
537
+	fi
538
+
539
+	if [ -z "$port" ]
540
+	then
541
+		port=6600
542
+	fi
543
+
544
+    if echo "status" | nc -w 1 "$host" "$port" | head -1 | grep "^OK MPD"
545
+    then
546
+        success "MPD server can be contacted on $host:$port"
547
+        status=$(echo "status" | nc -w 1 "$host" "$port" | grep "^state:"|cut -d: -f2)
548
+        success "It's state is : $status"
549
+    fi
550
+}

Loading…
Cancel
Save