Blame SOURCES/setregdomain

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