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