Fixes #20. By implementing checks before reading server files.

This commit is contained in:
Marcus Whybrow 2012-06-25 15:18:08 +01:00
parent 996e67b340
commit 9b8a1dd21d

View File

@ -1564,7 +1564,7 @@ command_server_whitelist_remove() {
# Displays a list of whitelisted players for an individual server # Displays a list of whitelisted players for an individual server
# $1: The server ID # $1: The server ID
command_server_whitelist_list() { command_server_whitelist_list() {
# TODO: Protect against no whitelist file if [ -f "${server_whitelist[$1]}" ]; then
local players="$(cat "${server_whitelist[$1]}")" local players="$(cat "${server_whitelist[$1]}")"
if [ -z "$players" ]; then if [ -z "$players" ]; then
@ -1572,6 +1572,9 @@ command_server_whitelist_list() {
else else
echo "$players" echo "$players"
fi fi
else
echo "No players are whitelisted."
fi
} }
# Adds player names to a server's ban list # Adds player names to a server's ban list
@ -1657,10 +1660,16 @@ command_server_blacklist_ip_remove() {
# Displays a server's banned player names and ip addresses # Displays a server's banned player names and ip addresses
# $1: The server ID # $1: The server ID
command_server_blacklist_list() { command_server_blacklist_list() {
# TODO: Protect against non-existent files local players
local ips
local players="$(cat "${server_banned_players[$1]}")" if [ -f "${server_banned_players[$1]}" ]; then
local ips="$(cat "${server_banned_ips[$1]}")" players="$(cat "${server_banned_players[$1]}")"
fi
if [ -f "${server_banned_ips[$1]}" ]; then
ips="$(cat "${server_banned_ips[$1]}")"
fi
if [[ -z "$players" && -z "$ips" ]]; then if [[ -z "$players" && -z "$ips" ]]; then
echo "The blacklist is empty." echo "The blacklist is empty."