LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 03-06-2010, 11:04 AM   #1
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,546
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
How can the locale be set for processes started by boot scripts?


Hello

This thread is a continuation of an earlier thread which had an inappropriate title

How can the locale be set for processes started by boot scripts? For processes which are descendents of login shells, locale is set by /etc/profile.d/lang.*sh in which envar $LANG is set. For virtual terminals, locale is set by kernel parameter vt.default_utf8=1 (thanks Rupa). But how is it set for processes started by boot scripts which are direct descendents of the init process?

Looking around to find how it might be done, I discovered:
  • There are no *locale* files under /etc.
  • /etc/inittab has nothing about locale.
  • man init has nothing about locale.
  • man 7 locale describes locale.h and its usage.
  • man 5 locale describes the format of locale files.
  • /sbin/init (as investigated using the strings command) may call nl_langinfo but man nl_langinfo only describes how to query the locale, not where it is set.
  • The envars set while running a boot script (as displayed by the env command) are:
    CONSOLE=/dev/console
    TERM=linux
    prevlevel=N
    INIT_VERSION=sysvinit-2.86
    PATH=/bin:/usr/bin:/sbin:/usr/sbin
    vga=791
    RUNLEVEL=4
    runlevel=4
    PWD=/
    PREVLEVEL=N
    HOME=/
    SHLVL=2
I want to set the locale for Bacula. According to the Bacula Main Reference*, in the "13.1 Critical Items" section: "Bacula assumes all filenames are in UTF-8 format. This is important when saving the filenames to the catalog. ... you must explicitly ensure that your locale is set properly. Typically this means that the bf LANG environment variable must end in .UTF-8. An full example is en US.UTF-8. The exact syntax may vary a bit from OS to OS, and exactly how you define it will also vary."

It would be nice to set the locale for Bacula only but that would require front-ending a lot of executables and I'm not confident of being able to identify them all.

Presumably both the daemon processes and the processes initiated by a logged-on user should have the same locale. One solution would be to export LANG=<something>.utf8 in the Bacula boot scripts and use /etc/profile.d/lang.*sh for the logged-on users but I'm curious how it can be set for all processes.

EDIT: Bacula is configured to use MySQL so presumably that, too, should have LANG=<something>.utf8.

Best

Charles

* Available as PDF or HTML at http://www.bacula.org/en/?page=documentation)

Last edited by catkin; 03-06-2010 at 11:06 AM.
 
Old 03-08-2010, 03:04 AM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,755

Rep: Reputation: 466Reputation: 466Reputation: 466Reputation: 466Reputation: 466
Two ideas: modify individual boot scripts to pass the desired LOCALE to the process, or create wrappers for the called binaries which set the LOCALE before exec-ing the real program.
 
Old 03-08-2010, 03:12 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,546
Blog Entries: 28

Original Poster
Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by gnashley View Post
Two ideas: modify individual boot scripts to pass the desired LOCALE to the process, or create wrappers for the called binaries which set the LOCALE before exec-ing the real program.
Thanks gnashley

The first suggestion is the one I will go with if I can't find a way to set locale for the whole system by setting it earlier in the process tree.

I considered the second suggestion but rejected it because of the difficulty of identifying all the binaries, and it's a lot of work, and it might break if an upgrade introduced new binaries.
 
  


Reply

Tags
bacula, init, locale, utf8


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
locale: Cannot Set LC_ALL to default locale: No such file or directory. asym Linux - General 10 03-24-2013 08:35 PM
Which set of runlevel scripts does slackware use at boot? okos Slackware 14 05-03-2008 08:20 PM
locale: Cannot set LC_ALL to default locale: Invalid argument GadgetWiz Mandriva 1 03-31-2006 11:38 PM
How do I set up multiple boot scripts in linux? Jbernoski Slackware 4 03-11-2006 08:27 PM
several processes started more than once at boot j-ray Linux - General 2 05-13-2004 12:37 PM


All times are GMT -5. The time now is 05:47 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration