summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-04-04 14:22:29 -0400
committerScott Moser <smoser@ubuntu.com>2012-04-04 14:22:29 -0400
commit5a849e4758fb92b66e45b6be80252812a2625b49 (patch)
treeea5443639bd1daf6eb2e68f50fcc45049b862d4c
parentaef06a1aa581ae0adbe53ff874916bd830870e0f (diff)
downloadcloud-init-git-5a849e4758fb92b66e45b6be80252812a2625b49.tar.gz
minor cleanup to messages, combine commands to single line
* remove unused 'line' variable * fix bug where multiple errant locales were not working correctly * only output each bad locale once in the list * you only need to run the apt-get install of the package *or* localegen
-rwxr-xr-xtools/Z99-cloud-locale-test.sh31
1 files changed, 20 insertions, 11 deletions
diff --git a/tools/Z99-cloud-locale-test.sh b/tools/Z99-cloud-locale-test.sh
index ae45c1da..8ad485e8 100755
--- a/tools/Z99-cloud-locale-test.sh
+++ b/tools/Z99-cloud-locale-test.sh
@@ -12,7 +12,7 @@
locale_warn() {
local cr="
"
- local line bad_names="" bad_lcs="" key="" value="" var=""
+ local bad_names="" bad_lcs="" key="" value="" var=""
local w1 w2 w3 w4 remain
# locale is expected to output either:
# VARIABLE=
@@ -31,8 +31,11 @@ locale_warn() {
done
for bad in $bad_names; do
for var in ${vars}; do
- [ "${bad}" = "${var%=*}" ] &&
- bad_lcs="${bad_lcs} ${var#*=}" && break 2
+ [ "${bad}" = "${var%=*}" ] || continue
+ value=${var#*=}
+ [ "${bad_lcs#* ${value}}" = "${bad_lcs}" ] &&
+ bad_lcs="${bad_lcs} ${value}"
+ break
done
done
bad_lcs=${bad_lcs# }
@@ -41,13 +44,10 @@ locale_warn() {
printf "_____________________________________________________________________\n"
printf "WARNING! Your environment specifies an invalid locale.\n"
printf " This can affect your user experience significantly, including the\n"
- printf " ability to manage packages. You may install the locales by running\n"
- printf " the following command(s):\n\n"
+ printf " ability to manage packages. You may install the locales by running:\n\n"
local bad invalid="" to_gen="" sfile="/usr/share/i18n/SUPPORTED"
- if [ ! -e "$sfile" ]; then
- printf " sudo apt-get install locales\n"
- fi
+ local pkgs=""
if [ -e "$sfile" ]; then
for bad in ${bad_lcs}; do
grep -q -i "${bad}" "$sfile" &&
@@ -55,14 +55,23 @@ locale_warn() {
invalid="${invalid} ${bad}"
done
else
+ printf " sudo apt-get install locales\n"
to_gen=$bad_lcs
fi
+ to_gen=${to_gen# }
+ local pkgs=""
for bad in ${to_gen}; do
- printf " sudo apt-get install language-pack-${bad%%_*}\n"
- printf " sudo locale-gen ${bad}\n"
+ pkgs="${pkgs} language-pack-${bad%%_*}"
done
- printf "\n"
+ pkgs=${pkgs# }
+
+ if [ -n "${pkgs}" ]; then
+ printf " sudo apt-get install ${pkgs# }\n"
+ printf " or\n"
+ printf " sudo locale-gen ${to_gen# }\n"
+ printf "\n"
+ fi
for bad in ${invalid}; do
printf "WARNING: '${bad}' is an invalid locale\n"
done