Blame SOURCES/setregdomain

470826
#!/bin/sh
470826
#
470826
# Copyright 2009-2014 Red Hat, Inc.  All rights reserved.
470826
#
470826
# Permission to use, copy, modify, and/or distribute this software for any
470826
# purpose with or without fee is hereby granted, provided that the above
470826
# copyright notice and this permission notice appear in all copies.
470826
# 
470826
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
470826
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
470826
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
470826
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
470826
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
470826
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
470826
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
470826
#
470826
470826
REGDOMAIN=/etc/sysconfig/regdomain
470826
LOCALTIME=/etc/localtime
470826
470826
LOGGER="/usr/bin/logger -t wireless"
470826
470826
getcountry() {
470826
	while read c a z r
470826
	do
470826
		if [ "$z" = "$ZONE" ]
470826
		then
470826
			echo $c
470826
			break
470826
		fi
470826
	done < /usr/share/zoneinfo/zone.tab
470826
}
470826
470826
if [ -f $REGDOMAIN ]
470826
then
470826
	# This should set COUNTRY
470826
	. $REGDOMAIN
470826
	if [ -n "$COUNTRY" ]
470826
	then
470826
		/usr/sbin/iw reg set $COUNTRY
470826
		exit
470826
	fi
470826
fi
470826
470826
if [ -f "$LOCALTIME" ]
470826
then
470826
	ZONE=$(readlink -f $LOCALTIME)
470826
	ZONE=${ZONE#/usr/share/zoneinfo/}
470826
else
470826
	$LOGGER -s "Timezone information not found!  Unable to set regulatory domain."
470826
	exit 1
470826
fi
470826
470826
if [ -z "$ZONE" -o "$ZONE" = "$LOCALTIME" ]
470826
then
470826
	$LOGGER -s "Could not determine timezone!  Unable to set regulatory domain."
470826
	exit 1
470826
fi
470826
470826
COUNTRY=$(getcountry)
470826
470826
if [ -z "$COUNTRY" ]
470826
then
470826
	$LOGGER -s "Could not determine country!  Unable to set regulatory domain."
470826
	exit 1
470826
fi
470826
470826
$LOGGER "setting regulatory domain to $COUNTRY based on timezone ($ZONE)"
470826
/usr/sbin/iw reg set $COUNTRY