Blame SOURCES/setregdomain

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