-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generate UTF locales selectable in icingaweb2 #140
Changes from all commits
d5f233c
5700e23
aaeeebb
be036fc
4bd1220
d253c0e
15a2113
67bb188
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
if [[ ! -f /etc/locale.gen.dist ]] | ||
then | ||
cp /etc/locale.gen /etc/locale.gen.dist | ||
fi | ||
|
||
echo "BUILD_LOCALES: $BUILD_LOCALES" | ||
typeset -i m=$(echo $BUILD_LOCALES | awk -F ',' '{print NF}') | ||
typeset -i n=1 | ||
while [[ $n -le $m ]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're iterating here over an index. Well, that's possible, but in bash this is discouraged. The language is not made for this. Use things like an enhanced for loop.
Rule of thumb: At the point where you have to use real integers either
|
||
do | ||
b_locale=$(echo $BUILD_LOCALES | awk -F ',' "{print \$$n}") | ||
cat /etc/locale.gen |grep -q "^$b_locale" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if [[ $? -ne 0 ]] | ||
then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The if clause actually executes a command and then tests for its exit code. If the exit code is 0 (==true), it'll execute the codeblock the result else not. So the So, extratesting for |
||
echo "adding locale $b_locale" | ||
cat /etc/locale.gen | sed "s/# $b_locale/$b_locale/" > /tmp/locale.gen | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the locale, I specified is not there in the file, it won't get enabled. On the one hand side, this is great. But KIM, that you could have a typo in the environment variable (e.g.: using
|
||
mv /tmp/locale.gen /etc/locale.gen | ||
fi | ||
|
||
n=$n+1 | ||
done | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not further tested, but this would basically do the same:
|
||
|
||
n=1 | ||
while [[ $n -le $m ]] | ||
do | ||
b_locale=$(echo $BUILD_LOCALES | awk -F ',' "{print \$$n}" |tr ' ', '.' |sed 's/\.UTF-8//' |sed 's/UTF-8/UTF8/') | ||
locale -a |grep -q -i "$b_locale" | ||
if [[ $? -ne 0 ]] | ||
then | ||
echo "$b_locale needs build" | ||
locale-gen | ||
break | ||
fi | ||
n=$n+1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
done |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
. /opt/helpers | ||
|
||
|
||
CNFSUFFIX=icingaweb2 | ||
mysql_cnf_init_section \ | ||
"${CNFSUFFIX}" \ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no guarantee, that your process will spit out a real number. So typesetting it to an integer doesn't give you any guarantee for this. Also quote the commands output, as it could contain special shell chars or just spaces, which get interpreted.