i2prouter: set locale environment variables if LANG not set

Check for /etc/environment and /etc/default/locale and retrieve/set locale
variables from them--but only if LANG is unset. This should help in those
cases in which someone is starting I2P as a daemon using an initscript and I2P is
starting /before/ the environment is configured, leading to the wrong file
encoding being detected.
This commit is contained in:
kytv
2011-12-19 18:14:21 +00:00
parent cefe20f11d
commit bd14dc3112

View File

@@ -107,6 +107,22 @@ WAIT_FOR_STARTED_TIMEOUT=120
# flag for using upstart when installing (rather than init.d rc.d)
USE_UPSTART=
# Source the environment variables for the locale if $LANG isn't set
# If you want to set custom locale variables for I2P,
# you may comment out this block and set them yourself here.
if [ ! -n $LANG ]; then
for ENV_FILE in /etc/environment /etc/default/locale; do
[ -r "$ENV_FILE" ] || continue
[ -s "$ENV_FILE" ] || continue
for var in LANG LANGUAGE LC_ALL LC_CTYPE; do
value=`egrep "^${var}=" "$ENV_FILE" | tail -n1 | cut -d= -f2`
[ -n "$value" ] && eval export $var=$value
done
done
fi
# When installing on On Mac OSX platforms, the following domain will be used to
# prefix the plist file name.
PLIST_DOMAIN=org.tanukisoftware.wrapper