forked from boyska/freepto-lb
-
Notifications
You must be signed in to change notification settings - Fork 13
/
generate_locales_and_zones.sh
executable file
·50 lines (43 loc) · 1.16 KB
/
generate_locales_and_zones.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
getLocales()
{
FILES=/usr/share/i18n/locales/*
for FILE in $FILES
do
CODE=$(basename $FILE)
LANG=$(awk -F\" '/^[ ]*language/ { gsub(/ /, "_", $2); print $2; } ' $FILE)
TERRITORY=$(awk -F\" '/^[ ]*territory/ { gsub(/ /, "_", $2); print $2; } ' $FILE)
OPTION=$(echo $CODE | awk -F@ '{ if($2) { print "(" $2 ")"; } } ')
if [ "$LANG" != "" -a "$TERRITORY" != "" ]
then
echo "$CODE $LANG/$TERRITORY$OPTION off "
fi
done
}
getZones()
{
while read line; do
ZONE=$(echo $line|awk '/^[A-Z]/ {print $3;}')
if [ "$ZONE" != "" ]
then
echo "$ZONE $ZONE off "
fi
done < "/usr/share/zoneinfo/zone.tab"
}
getLocale()
{
echo "Getting locales..."
LOCALES=$(getLocales|sort)
tempfile=/tmp/freepto-locale
rm $tempfile
dialog --title "Select locale" --radiolist "Select the Freepto locale:" 0 0 0 $LOCALES 2> $tempfile
LOCALE=$(cat $tempfile)
echo "$LOCALE"
}
getZone()
{
ZONES=$(getZones|sort)
dialog --title "Select zone" --radiolist "Select the Freepto zone:" 0 0 0 $ZONES
}
getLocales > locales
getZones > zones