1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #Copyright (C) 2016,2023 Weber Yann
- #
- #This program is free software; you can redistribute it and/or modify
- #it under the terms of the GNU General Public License as published by
- #the Free Software Foundation; either version 3 of the License, or
- #any later version.
- #
- #This program is distributed in the hope that it will be useful,
- #but WITHOUT ANY WARRANTY; without even the implied warranty of
- #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- #GNU General Public License for more details.
- #
- #You should have received a copy of the GNU General Public License
- #along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- check_mpc() {
- # check_mpc [$host [$port] ]
- # tests if you can contact an MPD server in a client way
- # returns the current state of the server
-
- host=$1
- port=$2
-
- if [ -z "$host" ]
- then
- host=127.0.0.1
- fi
-
- if [ -z "$port" ]
- then
- port=6600
- fi
-
- if echo "status" | nc -w 1 "$host" "$port" | head -1 | grep "^OK MPD"
- then
- success "MPD server can be contacted on $host:$port"
- status=$(echo "status" | nc -w 1 "$host" "$port" | grep "^state:"|cut -d: -f2)
- success "It's state is : $status"
- fi
- }
|