[arch-projects] [PATCH 1/7] config: add /etc/hostname support
If /etc/hostname is non-empty its contents is assumed to be the hostname. This takes precedence over HOSTNAME in rc.conf. Signed-off-by: Tom Gundersen <teg@jklm.no> --- rc.sysinit | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/rc.sysinit b/rc.sysinit index dffea4d..3e5fec9 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -232,6 +232,9 @@ RANDOM_SEED=/var/lib/misc/random-seed # Remove leftover files remove_leftover +if [[ -s /etc/hostname ]]; then + HOSTNAME=$(cat /etc/hostname) +fi if [[ $HOSTNAME ]]; then stat_busy "Setting Hostname: $HOSTNAME" echo "$HOSTNAME" >| /proc/sys/kernel/hostname && stat_done || stat_fail -- 1.7.7.1
Read KEYMAP, CONSOLEFONT and CONSOLEMAP from vconsole.conf. If they are set they take precedence over the values in rc.conf. Signed-off-by: Tom Gundersen <teg@jklm.no> --- rc.sysinit | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/rc.sysinit b/rc.sysinit index 3e5fec9..f82368a 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -240,6 +240,10 @@ if [[ $HOSTNAME ]]; then echo "$HOSTNAME" >| /proc/sys/kernel/hostname && stat_done || stat_fail fi +if [[ -s /etc/locale.conf ]]; then + . /etc/locale.conf + [[ $LANG ]] && LOCALE=$LANG +fi if [[ ${LOCALE,,} =~ utf ]]; then stat_busy "Setting Consoles to UTF-8 mode" # UTF-8 consoles are default since 2.6.24 kernel @@ -261,6 +265,11 @@ else echo 0 >| /sys/module/vt/parameters/default_utf8 stat_done fi + +if [[ -s /etc/vconsole.conf ]]; then + [[ $FONT ]] && CONSOLEFONT=$FONT + [[ $FONT_MAP ]] && CONSOLEMAP=$FONT_MAP +fi [[ $KEYMAP ]] && status "Loading Keyboard Map: $KEYMAP" loadkeys -q $KEYMAP -- 1.7.7.1
On Thu, Oct 27, 2011 at 01:38:28AM +0200, Tom Gundersen wrote:
Read KEYMAP, CONSOLEFONT and CONSOLEMAP from vconsole.conf. If they are set they take precedence over the values in rc.conf.
If these are to be the preferred method going forward, then we should be using the variables from these files as the default, not coercing them back to the "legacy" values of CONSOLEFONT, LOCALE, and the like.
Signed-off-by: Tom Gundersen <teg@jklm.no> --- rc.sysinit | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/rc.sysinit b/rc.sysinit index 3e5fec9..f82368a 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -240,6 +240,10 @@ if [[ $HOSTNAME ]]; then echo "$HOSTNAME" >| /proc/sys/kernel/hostname && stat_done || stat_fail fi
+if [[ -s /etc/locale.conf ]]; then + . /etc/locale.conf + [[ $LANG ]] && LOCALE=$LANG +fi if [[ ${LOCALE,,} =~ utf ]]; then stat_busy "Setting Consoles to UTF-8 mode" # UTF-8 consoles are default since 2.6.24 kernel @@ -261,6 +265,11 @@ else echo 0 >| /sys/module/vt/parameters/default_utf8 stat_done fi + +if [[ -s /etc/vconsole.conf ]]; then + [[ $FONT ]] && CONSOLEFONT=$FONT + [[ $FONT_MAP ]] && CONSOLEMAP=$FONT_MAP +fi [[ $KEYMAP ]] && status "Loading Keyboard Map: $KEYMAP" loadkeys -q $KEYMAP
-- 1.7.7.1
On Wednesday 26 October 2011 19:46:27 Dave Reisner wrote:
On Thu, Oct 27, 2011 at 01:38:28AM +0200, Tom Gundersen wrote:
Read KEYMAP, CONSOLEFONT and CONSOLEMAP from vconsole.conf. If they are set they take precedence over the values in rc.conf.
If these are to be the preferred method going forward, then we should be using the variables from these files as the default, not coercing them back to the "legacy" values of CONSOLEFONT, LOCALE, and the like.
Hmm... I really didn't want to make one preferred over the other. What is used internally in initscrpits does not really matter I guess, except for third- party hooks. In that case I'd like to keep backwards compatibility, so it makes sense to keep the legacy values. I guess an argument could be made about hook authors assuming the vars that can be set in the new config files are available in the hooks even if rc.conf is used. I wouldn't be opposed to making that work too. -t
Signed-off-by: Tom Gundersen <teg@jklm.no> --- rc.shutdown | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/rc.shutdown b/rc.shutdown index 38b22b0..8363737 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -37,6 +37,7 @@ stat_busy "Saving Random Seed" POOL_FILE=/proc/sys/kernel/random/poolsize if [[ -r $POOL_FILE ]]; then read POOL_SIZE < $POOL_FILE + (( POOL_SIZE /= 8 )) else POOL_SIZE=512 fi -- 1.7.7.1
udev was receiving some events (due to e.g. swapoff) on shutdown that caused it to fork new processes. These then receivde TERM before they could finish, and complained on the console. In principle, I'm worried that, with the right ammonut of bad luck, we could fork off some process at exactly the wrong time which escapes the killall logic. This, by the way, highlights the frailty of the killall stuff. Signed-off-by: Tom Gundersen <teg@jklm.no> --- rc.shutdown | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/rc.shutdown b/rc.shutdown index 8363737..5928b2d 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -19,6 +19,8 @@ run_hook shutdown_start stop_all_daemons +status "Shutting down UDev" udevadm control --exit + status "Deactivating Swap" swapoff -a # stop monitoring of lvm2 groups before unmounting filesystems -- 1.7.7.1
On Wed, Oct 26, 2011 at 6:38 PM, Tom Gundersen <teg@jklm.no> wrote: > udev was receiving some events (due to e.g. swapoff) on shutdown > that caused it to fork new processes. These then receivde TERM before s/received/ > they could finish, and complained on the console. > > In principle, I'm worried that, with the right ammonut of bad luck, s/amount/ > we could fork off some process at exactly the wrong time which escapes > the killall logic. > > This, by the way, highlights the frailty of the killall stuff. Two quick thoughts here 1. Is there a need to even call swapoff? I can't believe it is essential for swap partitions. It unfortunately does makes sense for swap files so we can later unmount the file system they live on, but it looks like there is no way to differentiate. Dave, I know you want to submit a patch to util-linux for this... :) 2. Why do we do anything except unmounting filesystems after the kill_all call? It seems like we could move the random seed, and timezone set above it, and then kill udev, and then we'd be safe from any and all spawned processes. The only things following would be (hooks excluded) a umount call, vgchange/cryptsetup calls, a mount call, and either poweroff/reboot. That seems pretty easy to audit, and I feel like you took a potshot at the killall thing when in fact udevd was the only bad boy in the corner causing trouble. > > Signed-off-by: Tom Gundersen <teg@jklm.no> > --- > rc.shutdown | 2 ++ > 1 files changed, 2 insertions(+), 0 deletions(-) > > diff --git a/rc.shutdown b/rc.shutdown > index 8363737..5928b2d 100755 > --- a/rc.shutdown > +++ b/rc.shutdown > @@ -19,6 +19,8 @@ run_hook shutdown_start > > stop_all_daemons > > +status "Shutting down UDev" udevadm control --exit > + > status "Deactivating Swap" swapoff -a > > # stop monitoring of lvm2 groups before unmounting filesystems > -- > 1.7.7.1 > >
On Wed, Oct 26, 2011 at 07:12:13PM -0500, Dan McGee wrote: > On Wed, Oct 26, 2011 at 6:38 PM, Tom Gundersen <teg@jklm.no> wrote: > > udev was receiving some events (due to e.g. swapoff) on shutdown > > that caused it to fork new processes. These then receivde TERM before > s/received/ > > they could finish, and complained on the console. > > > > In principle, I'm worried that, with the right ammonut of bad luck, > s/amount/ > > we could fork off some process at exactly the wrong time which escapes > > the killall logic. > > > > This, by the way, highlights the frailty of the killall stuff. > Two quick thoughts here > 1. Is there a need to even call swapoff? I can't believe it is > essential for swap partitions. It unfortunately does makes sense for > swap files so we can later unmount the file system they live on, but > it looks like there is no way to differentiate. Dave, I know you want > to submit a patch to util-linux for this... :) I'm such a tool. Preliminary patchwork for this now exists: http://code.falconindy.com/cgit/util-linux.git/log/?h=swapon If anyone wants to give it a once over from a user or developer perspective, that'd be awesome. d > 2. Why do we do anything except unmounting filesystems after the > kill_all call? It seems like we could move the random seed, and > timezone set above it, and then kill udev, and then we'd be safe from > any and all spawned processes. > The only things following would be (hooks excluded) a umount call, > vgchange/cryptsetup calls, a mount call, and either poweroff/reboot. > That seems pretty easy to audit, and I feel like you took a potshot at > the killall thing when in fact udevd was the only bad boy in the > corner causing trouble. > > > > > Signed-off-by: Tom Gundersen <teg@jklm.no> > > --- > > rc.shutdown | 2 ++ > > 1 files changed, 2 insertions(+), 0 deletions(-) > > > > diff --git a/rc.shutdown b/rc.shutdown > > index 8363737..5928b2d 100755 > > --- a/rc.shutdown > > +++ b/rc.shutdown > > @@ -19,6 +19,8 @@ run_hook shutdown_start > > > > stop_all_daemons > > > > +status "Shutting down UDev" udevadm control --exit > > + > > status "Deactivating Swap" swapoff -a > > > > # stop monitoring of lvm2 groups before unmounting filesystems > > -- > > 1.7.7.1 > > > >
On Wed, Oct 26, 2011 at 10:51 PM, Dave Reisner <d@falconindy.com> wrote: > On Wed, Oct 26, 2011 at 07:12:13PM -0500, Dan McGee wrote: >> On Wed, Oct 26, 2011 at 6:38 PM, Tom Gundersen <teg@jklm.no> wrote: >> > udev was receiving some events (due to e.g. swapoff) on shutdown >> > that caused it to fork new processes. These then receivde TERM before >> s/received/ >> > they could finish, and complained on the console. >> > >> > In principle, I'm worried that, with the right ammonut of bad luck, >> s/amount/ >> > we could fork off some process at exactly the wrong time which escapes >> > the killall logic. >> > >> > This, by the way, highlights the frailty of the killall stuff. >> Two quick thoughts here >> 1. Is there a need to even call swapoff? I can't believe it is >> essential for swap partitions. It unfortunately does makes sense for >> swap files so we can later unmount the file system they live on, but >> it looks like there is no way to differentiate. Dave, I know you want >> to submit a patch to util-linux for this... :) > > I'm such a tool. Preliminary patchwork for this now exists: > > http://code.falconindy.com/cgit/util-linux.git/log/?h=swapon > > If anyone wants to give it a once over from a user or developer > perspective, that'd be awesome. Wow, you're awesome. I guess my first question would be- does it actually work? :) Just hotpatch the old initscripts to only swapoff file partitions and try shutting down and make sure it actually goes off without a hitch. This could definitely save some shutdown time on machines that have paged a non-trivial amount to swap. -Dan
On Wed, Oct 26, 2011 at 11:03:52PM -0500, Dan McGee wrote: > On Wed, Oct 26, 2011 at 10:51 PM, Dave Reisner <d@falconindy.com> wrote: > > On Wed, Oct 26, 2011 at 07:12:13PM -0500, Dan McGee wrote: > >> On Wed, Oct 26, 2011 at 6:38 PM, Tom Gundersen <teg@jklm.no> wrote: > >> > udev was receiving some events (due to e.g. swapoff) on shutdown > >> > that caused it to fork new processes. These then receivde TERM before > >> s/received/ > >> > they could finish, and complained on the console. > >> > > >> > In principle, I'm worried that, with the right ammonut of bad luck, > >> s/amount/ > >> > we could fork off some process at exactly the wrong time which escapes > >> > the killall logic. > >> > > >> > This, by the way, highlights the frailty of the killall stuff. > >> Two quick thoughts here > >> 1. Is there a need to even call swapoff? I can't believe it is > >> essential for swap partitions. It unfortunately does makes sense for > >> swap files so we can later unmount the file system they live on, but > >> it looks like there is no way to differentiate. Dave, I know you want > >> to submit a patch to util-linux for this... :) > > > > I'm such a tool. Preliminary patchwork for this now exists: > > > > http://code.falconindy.com/cgit/util-linux.git/log/?h=swapon > > > > If anyone wants to give it a once over from a user or developer > > perspective, that'd be awesome. > > Wow, you're awesome. I guess my first question would be- does it > actually work? :) Just hotpatch the old initscripts to only swapoff > file partitions and try shutting down and make sure it actually goes > off without a hitch. This could definitely save some shutdown time on > machines that have paged a non-trivial amount to swap. > > -Dan Of course it works! It's far from useable, though. The swapon code is a mess and hasn't really been touched in years. I'm going to track down Karel Zak at some point and ask him if this is even something that's wanted and maybe get some guidance as to what else should be cleaned up in the process. d
On Thu, Oct 27, 2011 at 09:12:19AM -0400, Dave Reisner wrote: > On Wed, Oct 26, 2011 at 11:03:52PM -0500, Dan McGee wrote: > > On Wed, Oct 26, 2011 at 10:51 PM, Dave Reisner <d@falconindy.com> wrote: > > > On Wed, Oct 26, 2011 at 07:12:13PM -0500, Dan McGee wrote: > > >> On Wed, Oct 26, 2011 at 6:38 PM, Tom Gundersen <teg@jklm.no> wrote: > > >> > udev was receiving some events (due to e.g. swapoff) on shutdown > > >> > that caused it to fork new processes. These then receivde TERM before > > >> s/received/ > > >> > they could finish, and complained on the console. > > >> > > > >> > In principle, I'm worried that, with the right ammonut of bad luck, > > >> s/amount/ > > >> > we could fork off some process at exactly the wrong time which escapes > > >> > the killall logic. > > >> > > > >> > This, by the way, highlights the frailty of the killall stuff. > > >> Two quick thoughts here > > >> 1. Is there a need to even call swapoff? I can't believe it is > > >> essential for swap partitions. It unfortunately does makes sense for > > >> swap files so we can later unmount the file system they live on, but > > >> it looks like there is no way to differentiate. Dave, I know you want > > >> to submit a patch to util-linux for this... :) > > > > > > I'm such a tool. Preliminary patchwork for this now exists: > > > > > > http://code.falconindy.com/cgit/util-linux.git/log/?h=swapon > > > > > > If anyone wants to give it a once over from a user or developer > > > perspective, that'd be awesome. > > > > Wow, you're awesome. I guess my first question would be- does it > > actually work? :) Just hotpatch the old initscripts to only swapoff > > file partitions and try shutting down and make sure it actually goes > > off without a hitch. This could definitely save some shutdown time on > > machines that have paged a non-trivial amount to swap. > > > > -Dan > > Of course it works! > > It's far from useable, though. The swapon code is a mess and hasn't > really been touched in years. I'm going to track down Karel Zak at some > point and ask him if this is even something that's wanted and maybe get > some guidance as to what else should be cleaned up in the process. > > d So, I sort of agree with Tom that perhaps this isn't the right thing to do because of situations such as LVM. Additionally, the swapon code is a real farking mess and I'm not sure upstream wants the addition (waiting to hear back as I want to do a bit of refactoring along with it). In the meantime, just for grins, we can already do this in shell: if [[ -r /proc/swaps ]]; then { read _ while read -r swap type _; do [[ $type = 'file' ]] && swaps+=("$(printf '%b\n' "$swap")") done (( ${#swaps[*]} )) && swapoff "${swaps[@]}" } </proc/swaps fi d
On Thu, Oct 27, 2011 at 2:12 AM, Dan McGee <dpmcgee@gmail.com> wrote:
1. Is there a need to even call swapoff? I can't believe it is essential for swap partitions. It unfortunately does makes sense for swap files so we can later unmount the file system they live on, but it looks like there is no way to differentiate. Dave, I know you want to submit a patch to util-linux for this... :)
You are right in this, if we can only swapoff swap files that would be more efficient (unless I'm missing something). Dave: thanks for the work on this already!
2. Why do we do anything except unmounting filesystems after the kill_all call? It seems like we could move the random seed, and timezone set above it, and then kill udev, and then we'd be safe from any and all spawned processes. The only things following would be (hooks excluded) a umount call, vgchange/cryptsetup calls, a mount call, and either poweroff/reboot.
The reordering you propose makes sense to me, I'll do this with the next round of patches (unless someone beats me to it).
That seems pretty easy to audit, and I feel like you took a potshot at the killall thing when in fact udevd was the only bad boy in the corner causing trouble.
Our killall works if everyone behaves as they should (and to the best of my knowledge, now they do). However, I guess it would not be difficult to create a program that forks at the right times in such a way that it would escape being killed. I think things are "good enough" as they are now though, unless someone finds a real-life problem, or someone proposes a fool-proof replacement. -t
On Thu, Oct 27, 2011 at 2:12 AM, Dan McGee <dpmcgee@gmail.com> wrote:
1. Is there a need to even call swapoff? I can't believe it is essential for swap partitions.
On second thought: I guess there is the case where the swap partition is on top of something else (lvm, md, crypt, ...). We are currently trying to tear down all these things gracefully, so I guess we'd need to swapoff if we want that. -t
--- PKGBUILD | 2 +- functions | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 18b53b7..0c5b71d 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -10,7 +10,7 @@ conflicts=('initscripts') provides=('initscripts=9999') backup=(etc/inittab etc/rc.conf etc/rc.local etc/rc.local.shutdown) makedepends=('asciidoc') -depends=('glibc' 'bash' 'grep' 'coreutils' 'udev>=173' 'iproute2' +depends=('glibc' 'bash' 'grep' 'coreutils' 'udev>=174' 'iproute2' 'ncurses' 'kbd' 'findutils' 'sysvinit') optdepends=('net-tools: legacy networking support' 'bridge-utils: Network bridging support' diff --git a/functions b/functions index 938e5f9..05d8f56 100644 --- a/functions +++ b/functions @@ -332,7 +332,7 @@ kill_all() { udevd_modprobe() { # $1 = where we are being called from. # This is used to determine which hooks to run. - status "Starting UDev Daemon" udevd --daemon + status "Starting UDev Daemon" /lib/udev/udevd --daemon run_hook "$1_udevlaunched" -- 1.7.7.1
Uglier script, but should now work with zsh as well as bash. Signed-off-by: Tom Gundersen <teg@jklm.no> --- locale.sh | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 73 insertions(+), 4 deletions(-) diff --git a/locale.sh b/locale.sh index e774659..4b4ef4e 100644 --- a/locale.sh +++ b/locale.sh @@ -1,10 +1,79 @@ if [ -s /etc/rc.conf ]; then - LANG=$(. /etc/rc.conf 2> /dev/null ; echo "${LOCALE:=en_US.UTF-8}") + LANG=$(. /etc/rc.conf 2> /dev/null ; echo "$LOCALE") fi + if [ -s /etc/locale.conf ]; then . /etc/locale.conf fi -export LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE -export LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS -export LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION +if [ -n "$LANG" ]; then + export LANG +else + export LANG="C" +fi + +if [ -n "$LC_CTYPE" ]; then + export LC_CTYPE +else + unset LC_CTYPE +fi + +if [ -n "$LC_NUMERIC" ]; then + export LC_NUMERIC +else + unset LC_NUMERIC +fi + +if [ -n "$LC_TIME" ]; then + export LC_TIME +else + unset LC_TIME +fi + +if [ -n "$LC_COLLATE" ]; then + export LC_COLLATE +else + unset LC_COLLATE +fi + +if [ -n "$LC_MONETARY" ]; then + export LC_MONETARY +else + unset LC_MONETARY +fi + +if [ -n "$LC_MESSAGES" ]; then + export LC_MESSAGES +else + unset LC_MESSAGES +fi + +if [ -n "$LC_PAPER" ]; then + export LC_PAPER +else + unset LC_PAPER +fi + +if [ -n "$LC_NAME" ]; then + export LC_NAME +else + unset LC_NAME +fi + +if [ -n "$LC_ADDRESS" ]; then + export LC_ADDRESS +else + unset LC_ADDRESS +fi + +if [ -n "$LC_TELEPHONE" ]; then + export LC_MEASUREMENT +else + unset LC_MEASUREMENT +fi + +if [ -n "$LC_IDENTIFICATION" ]; then + export LC_IDENTIFICATION +else + unset LC_IDENTIFICATION +fi -- 1.7.7.1
On Thu, Oct 27, 2011 at 01:38:32AM +0200, Tom Gundersen wrote:
Uglier script, but should now work with zsh as well as bash.
Signed-off-by: Tom Gundersen <teg@jklm.no> --- locale.sh | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 73 insertions(+), 4 deletions(-)
diff --git a/locale.sh b/locale.sh index e774659..4b4ef4e 100644 --- a/locale.sh +++ b/locale.sh @@ -1,10 +1,79 @@ if [ -s /etc/rc.conf ]; then - LANG=$(. /etc/rc.conf 2> /dev/null ; echo "${LOCALE:=en_US.UTF-8}") + LANG=$(. /etc/rc.conf 2> /dev/null ; echo "$LOCALE") fi + if [ -s /etc/locale.conf ]; then . /etc/locale.conf fi
Minor optimization -- check for locale.conf first. If it exists, don't even read rc.conf. The legacy setting is only ever going to supply LANG, whereas locale.conf can supply LANG and a lot more.
-export LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE -export LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS -export LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION +if [ -n "$LANG" ]; then + export LANG +else + export LANG="C" +fi + +if [ -n "$LC_CTYPE" ]; then + export LC_CTYPE +else + unset LC_CTYPE +fi + +if [ -n "$LC_NUMERIC" ]; then + export LC_NUMERIC +else + unset LC_NUMERIC +fi + +if [ -n "$LC_TIME" ]; then + export LC_TIME +else + unset LC_TIME +fi + +if [ -n "$LC_COLLATE" ]; then + export LC_COLLATE +else + unset LC_COLLATE +fi + +if [ -n "$LC_MONETARY" ]; then + export LC_MONETARY +else + unset LC_MONETARY +fi + +if [ -n "$LC_MESSAGES" ]; then + export LC_MESSAGES +else + unset LC_MESSAGES +fi + +if [ -n "$LC_PAPER" ]; then + export LC_PAPER +else + unset LC_PAPER +fi + +if [ -n "$LC_NAME" ]; then + export LC_NAME +else + unset LC_NAME +fi + +if [ -n "$LC_ADDRESS" ]; then + export LC_ADDRESS +else + unset LC_ADDRESS +fi + +if [ -n "$LC_TELEPHONE" ]; then + export LC_MEASUREMENT +else + unset LC_MEASUREMENT +fi + +if [ -n "$LC_IDENTIFICATION" ]; then + export LC_IDENTIFICATION +else + unset LC_IDENTIFICATION +fi -- 1.7.7.1
On Wednesday 26 October 2011 19:49:29 Dave Reisner wrote:
On Thu, Oct 27, 2011 at 01:38:32AM +0200, Tom Gundersen wrote:
Uglier script, but should now work with zsh as well as bash.
Signed-off-by: Tom Gundersen <teg@jklm.no> ---
locale.sh | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 73 insertions(+), 4 deletions(-)
diff --git a/locale.sh b/locale.sh index e774659..4b4ef4e 100644 --- a/locale.sh +++ b/locale.sh @@ -1,10 +1,79 @@
if [ -s /etc/rc.conf ]; then
- LANG=$(. /etc/rc.conf 2> /dev/null ; echo "${LOCALE:=en_US.UTF-8}") + LANG=$(. /etc/rc.conf 2> /dev/null ; echo "$LOCALE")
fi
+
if [ -s /etc/locale.conf ]; then
. /etc/locale.conf
fi
Minor optimization -- check for locale.conf first. If it exists, don't even read rc.conf. The legacy setting is only ever going to supply LANG, whereas locale.conf can supply LANG and a lot more.
I did this, but only in the case that LANG is not set in locale.conf, I want LOCALE to still work in the case where someone just set some LC_ var in locale.conf. -t
On Thu, Oct 27, 2011 at 1:38 AM, Tom Gundersen <teg@jklm.no> wrote:
Uglier script, but should now work with zsh as well as bash.
Signed-off-by: Tom Gundersen <teg@jklm.no> --- locale.sh | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 73 insertions(+), 4 deletions(-)
diff --git a/locale.sh b/locale.sh index e774659..4b4ef4e 100644 --- a/locale.sh +++ b/locale.sh @@ -1,10 +1,79 @@ if [ -s /etc/rc.conf ]; then - LANG=$(. /etc/rc.conf 2> /dev/null ; echo "${LOCALE:=en_US.UTF-8}") + LANG=$(. /etc/rc.conf 2> /dev/null ; echo "$LOCALE") fi + if [ -s /etc/locale.conf ]; then . /etc/locale.conf fi
-export LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE -export LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS -export LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION +if [ -n "$LANG" ]; then + export LANG +else + export LANG="C" +fi + +if [ -n "$LC_CTYPE" ]; then + export LC_CTYPE +else + unset LC_CTYPE +fi + +if [ -n "$LC_NUMERIC" ]; then + export LC_NUMERIC +else + unset LC_NUMERIC +fi + +if [ -n "$LC_TIME" ]; then + export LC_TIME +else + unset LC_TIME +fi + +if [ -n "$LC_COLLATE" ]; then + export LC_COLLATE +else + unset LC_COLLATE +fi + +if [ -n "$LC_MONETARY" ]; then + export LC_MONETARY +else + unset LC_MONETARY +fi + +if [ -n "$LC_MESSAGES" ]; then + export LC_MESSAGES +else + unset LC_MESSAGES +fi + +if [ -n "$LC_PAPER" ]; then + export LC_PAPER +else + unset LC_PAPER +fi + +if [ -n "$LC_NAME" ]; then + export LC_NAME +else + unset LC_NAME +fi + +if [ -n "$LC_ADDRESS" ]; then + export LC_ADDRESS +else + unset LC_ADDRESS +fi + +if [ -n "$LC_TELEPHONE" ]; then + export LC_MEASUREMENT +else + unset LC_MEASUREMENT +fi + +if [ -n "$LC_IDENTIFICATION" ]; then + export LC_IDENTIFICATION +else + unset LC_IDENTIFICATION +fi -- 1.7.7.1
i think we should take an another approach about this issue of locale. We should use pam (with pam_env module) to set this env vars. -- Sébastien Luttringer www.seblu.net
On Friday 28 October 2011 20:48:44 Seblu wrote:
On Thu, Oct 27, 2011 at 1:38 AM, Tom Gundersen <teg@jklm.no> wrote:
Uglier script, but should now work with zsh as well as bash.
Signed-off-by: Tom Gundersen <teg@jklm.no> --- locale.sh | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 73 insertions(+), 4 deletions(-)
diff --git a/locale.sh b/locale.sh index e774659..4b4ef4e 100644 --- a/locale.sh +++ b/locale.sh @@ -1,10 +1,79 @@ if [ -s /etc/rc.conf ]; then - LANG=$(. /etc/rc.conf 2> /dev/null ; echo "${LOCALE:=en_US.UTF-8}") + LANG=$(. /etc/rc.conf 2> /dev/null ; echo "$LOCALE") fi + if [ -s /etc/locale.conf ]; then . /etc/locale.conf fi
-export LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE -export LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS -export LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION +if [ -n "$LANG" ]; then + export LANG +else + export LANG="C" +fi + +if [ -n "$LC_CTYPE" ]; then + export LC_CTYPE +else + unset LC_CTYPE +fi + +if [ -n "$LC_NUMERIC" ]; then + export LC_NUMERIC +else + unset LC_NUMERIC +fi + +if [ -n "$LC_TIME" ]; then + export LC_TIME +else + unset LC_TIME +fi + +if [ -n "$LC_COLLATE" ]; then + export LC_COLLATE +else + unset LC_COLLATE +fi + +if [ -n "$LC_MONETARY" ]; then + export LC_MONETARY +else + unset LC_MONETARY +fi + +if [ -n "$LC_MESSAGES" ]; then + export LC_MESSAGES +else + unset LC_MESSAGES +fi + +if [ -n "$LC_PAPER" ]; then + export LC_PAPER +else + unset LC_PAPER +fi + +if [ -n "$LC_NAME" ]; then + export LC_NAME +else + unset LC_NAME +fi + +if [ -n "$LC_ADDRESS" ]; then + export LC_ADDRESS +else + unset LC_ADDRESS +fi + +if [ -n "$LC_TELEPHONE" ]; then + export LC_MEASUREMENT +else + unset LC_MEASUREMENT +fi + +if [ -n "$LC_IDENTIFICATION" ]; then + export LC_IDENTIFICATION +else + unset LC_IDENTIFICATION +fi -- 1.7.7.1
i think we should take an another approach about this issue of locale. We should use pam (with pam_env module) to set this env vars.
I agree that setting the vars from within the shell is not ideal (but it solves the problem in most cases). I'd be very happy to accept a better implementation (as long as the configuration format is unchanged). -t
This is not very useful, is not maintained, has open serious bugs. Better to admit that it does not work and just remove it. Someone could easily make an AUR package with a hook, if they want it and can make it work as expected. The only case where this would be useful is in case lvm monitoring is in use and dmeventd sends out a message to syslog before syslog-ng is started (there is a very small window). However, not even this works atm (as far as I know) due to bugs in minilogd. Signed-off-by: Tom Gundersen <teg@jklm.no> --- Makefile | 10 +-- PKGBUILD | 2 +- minilogd.c | 202 ------------------------------------------------------------ rc.sysinit | 3 +- 4 files changed, 6 insertions(+), 211 deletions(-) delete mode 100644 minilogd.c diff --git a/Makefile b/Makefile index c7eaa5f..7da89e3 100644 --- a/Makefile +++ b/Makefile @@ -15,21 +15,19 @@ DIRS := \ /usr/share/zsh/site-functions \ /usr/share/man/man8 -all: minilogd doc - -minilogd: minilogd.o +all: doc installdirs: install -dm755 $(foreach DIR, $(DIRS), $(DESTDIR)$(DIR)) -install: minilogd installdirs doc +install: installdirs doc install -m644 -t $(DESTDIR)/etc inittab rc.conf install -m755 -t $(DESTDIR)/etc rc.local rc.local.shutdown rc.multi rc.shutdown rc.single rc.sysinit install -m644 -t $(DESTDIR)/etc/logrotate.d bootlog install -m644 -t $(DESTDIR)/etc/rc.d functions install -m755 -t $(DESTDIR)/etc/rc.d hwclock network netfs install -m755 -t $(DESTDIR)/etc/profile.d locale.sh - install -m755 -t $(DESTDIR)/usr/sbin minilogd rc.d + install -m755 -t $(DESTDIR)/usr/sbin rc.d install -m644 -t ${DESTDIR}/usr/share/man/man8 rc.d.8 install -m755 -t $(DESTDIR)/usr/lib/initscripts arch-tmpfiles arch-sysctl install -m644 tmpfiles.conf $(DESTDIR)/usr/lib/tmpfiles.d/arch.conf @@ -42,7 +40,7 @@ rc.d.8: rc.d.8.txt doc: rc.d.8 clean: - rm -f minilogd minilogd.o rc.d.8 + rm -f rc.d.8 release: git archive HEAD --prefix=initscripts-$(VER)/ | xz > initscripts-$(VER).tar.xz diff --git a/PKGBUILD b/PKGBUILD index 0c5b71d..deddbd5 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -2,7 +2,7 @@ pkgname=initscripts-git pkgver=$(date +%s) pkgrel=$(git log -1 --pretty=format:%h) pkgdesc="System initialization/bootup scripts" -arch=('i686' 'x86_64') +arch=('any') url="http://www.archlinux.org" license=('GPL') groups=('base') diff --git a/minilogd.c b/minilogd.c deleted file mode 100644 index c86ab23..0000000 --- a/minilogd.c +++ /dev/null @@ -1,202 +0,0 @@ -/* minilogd.c - * - * A pale imitation of syslogd. Most notably, doesn't write anything - * anywhere except possibly back to syslogd. - * - */ - -#include <errno.h> -#include <fcntl.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <strings.h> -#include <stdarg.h> -#include <syslog.h> -#ifndef __USE_BSD -# define __USE_BSD -#endif -#include <unistd.h> - -#include <sys/poll.h> -#include <sys/socket.h> -#include <sys/stat.h> -#include <sys/un.h> - -#define MAX_BUF_LINES 10000 -#define BUF_LINE_SIZE 8192 - -static int we_own_log=0; -static char **buffer=NULL; -static int buflines=0; - -int debug; - -int recvsock; - -void alarm_handler(int x) { - alarm(0); - close(recvsock); - recvsock = -1; -} - -void freeBuffer() { - struct sockaddr_un addr; - int sock; - int x=0,conn; - - memset(&addr, 0, sizeof(addr)); - addr.sun_family = AF_LOCAL; - strncpy(addr.sun_path,_PATH_LOG,sizeof(addr.sun_path)-1); - /* wait for klogd to hit syslog */ - sleep(2); - sock = socket(AF_LOCAL, SOCK_STREAM,0); - conn=connect(sock,(struct sockaddr *) &addr,(socklen_t)sizeof(addr)); - while (x<buflines) { - if (!conn) { - /*printf("to syslog: %s\n", buffer[x]);*/ - write(sock,buffer[x],strlen(buffer[x])+1); - } - free(buffer[x]); - x++; - } - free(buffer); -} - -void cleanup(int exitcode) { - /* If we own the log, unlink it before trying to free our buffer. - * Otherwise, sending the buffer to /dev/log doesn't make much sense.... */ - if (we_own_log) { - perror("wol"); - unlink(_PATH_LOG); - } - /* Don't try to free buffer if we were called from a signal handler */ - if (exitcode<=0) { - if (buffer) - freeBuffer(); - exit(exitcode); - } else - exit(exitcode+128); -} - -void runDaemon(int sock) { - struct sockaddr_un addr; - int x,done=0; - ssize_t len; - socklen_t addrlen = (socklen_t)sizeof(struct sockaddr_un); - char *message = NULL; - struct stat s1,s2; - struct pollfd pfds; - - daemon(0,-1); - /* try not to leave stale sockets lying around */ - /* Hopefully, we won't actually get any of these */ - signal(SIGHUP,cleanup); - signal(SIGINT,cleanup); - signal(SIGQUIT,cleanup); - signal(SIGILL,cleanup); - signal(SIGABRT,cleanup); - signal(SIGFPE,cleanup); - signal(SIGSEGV,cleanup); - signal(SIGPIPE,cleanup); - signal(SIGBUS,cleanup); - signal(SIGTERM,cleanup); - done = 0; - /* Get stat info on /dev/log so we can later check to make sure we - * still own it... */ - if (stat(_PATH_LOG,&s1) != 0) - memset(&s1, 0, sizeof(struct stat)); - while (!done) { - pfds.fd = sock; - pfds.events = POLLIN|POLLPRI; - pfds.revents = 0; - if ( ( (x=poll(&pfds,1,500))==-1) && errno !=EINTR) { - perror("poll"); - cleanup(-1); - } - if ( (x>0) && (pfds.revents & (POLLIN | POLLPRI))) { - if (message == NULL) { - message = calloc(BUF_LINE_SIZE,sizeof(char)); - } - recvsock = accept(sock,(struct sockaddr *) &addr, &addrlen); - alarm(2); - signal(SIGALRM, alarm_handler); - len = read(recvsock,message,BUF_LINE_SIZE); - alarm(0); - close(recvsock); - if (len>0) { - /*printf("line recv'd: %s\n", message);*/ - if (buflines < MAX_BUF_LINES) { - if (buffer) - buffer = realloc(buffer,(buflines+1)*sizeof(char *)); - else - buffer = malloc(sizeof(char *)); - message[strlen(message)]='\n'; - buffer[buflines]=message; - message = NULL; - buflines++; - } - } - else { - recvsock=-1; - } - } - if ( (x>0) && ( pfds.revents & (POLLHUP | POLLNVAL)) ) - done = 1; - /* Check to see if syslogd's yanked our socket out from under us */ - if ( (stat(_PATH_LOG,&s2)!=0) || - (s1.st_ino != s2.st_ino ) || (s1.st_ctime != s2.st_ctime) || - (s1.st_mtime != s2.st_mtime) ) { /*|| (s1.st_atime != s2.st_atime) ) {*/ - done = 1; - we_own_log = 0; - /*printf("someone stole our %s\n", _PATH_LOG); - printf("st_ino: %d %d\n", s1.st_ino, s2.st_ino); - printf("st_ctime: %d %d\n", s1.st_ctime, s2.st_ctime); - printf("st_atime: %d %d\n", s1.st_atime, s2.st_atime); - printf("st_mtime: %d %d\n", s1.st_mtime, s2.st_mtime);*/ - } - } - free(message); - cleanup(0); -} - -int main(int argc, char **argv) { - struct sockaddr_un addr; - int sock; - int pid; - - /* option processing made simple... */ - if (argc>1) debug=1; - /* just in case */ - sock = open("/dev/null",O_RDWR); - dup2(sock,0); - dup2(sock,1); - dup2(sock,2); - - memset(&addr, 0, sizeof(addr)); - addr.sun_family = AF_LOCAL; - strncpy(addr.sun_path,_PATH_LOG,sizeof(addr.sun_path)-1); - sock = socket(AF_LOCAL, SOCK_STREAM,0); - unlink(_PATH_LOG); - /* Bind socket before forking, so we know if the server started */ - if (!bind(sock,(struct sockaddr *) &addr, (socklen_t)sizeof(addr))) { - we_own_log = 1; - listen(sock,5); - if ((pid=fork())==-1) { - perror("fork"); - exit(3); - } - if (pid) { - exit(0); - } else { - /*printf("starting daemon...\n");*/ - runDaemon(sock); - /* shouldn't get back here... */ - exit(4); - } - } else { - exit(5); - } -} -/* vim: set ts=2 noet: */ diff --git a/rc.sysinit b/rc.sysinit index f82368a..d802f3f 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -31,8 +31,7 @@ findmnt / --options ro &>/dev/null || run_hook sysinit_start -# start up our mini logger until syslog takes over -minilogd +# log all console messages bootlogd -p /run/bootlogd.pid if [[ ! -a /usr/lib ]] ; then -- 1.7.7.1
On Wed, Oct 26, 2011 at 6:38 PM, Tom Gundersen <teg@jklm.no> wrote:
This is not very useful, is not maintained, has open serious bugs. Better to admit that it does not work and just remove it. Someone could easily make an AUR package with a hook, if they want it and can make it work as expected.
The only case where this would be useful is in case lvm monitoring is in use and dmeventd sends out a message to syslog before syslog-ng is started (there is a very small window). However, not even this works atm (as far as I know) due to bugs in minilogd.
Signed-off-by: Tom Gundersen <teg@jklm.no> If you also update .gitignore and remove the two relevant entries, Signed-off-by: Dan McGee <dan@archlinux.org>
--- Makefile | 10 +-- PKGBUILD | 2 +- minilogd.c | 202 ------------------------------------------------------------ rc.sysinit | 3 +- 4 files changed, 6 insertions(+), 211 deletions(-) delete mode 100644 minilogd.c
diff --git a/Makefile b/Makefile index c7eaa5f..7da89e3 100644 --- a/Makefile +++ b/Makefile @@ -15,21 +15,19 @@ DIRS := \ /usr/share/zsh/site-functions \ /usr/share/man/man8
-all: minilogd doc - -minilogd: minilogd.o +all: doc
installdirs: install -dm755 $(foreach DIR, $(DIRS), $(DESTDIR)$(DIR))
-install: minilogd installdirs doc +install: installdirs doc install -m644 -t $(DESTDIR)/etc inittab rc.conf install -m755 -t $(DESTDIR)/etc rc.local rc.local.shutdown rc.multi rc.shutdown rc.single rc.sysinit install -m644 -t $(DESTDIR)/etc/logrotate.d bootlog install -m644 -t $(DESTDIR)/etc/rc.d functions install -m755 -t $(DESTDIR)/etc/rc.d hwclock network netfs install -m755 -t $(DESTDIR)/etc/profile.d locale.sh - install -m755 -t $(DESTDIR)/usr/sbin minilogd rc.d + install -m755 -t $(DESTDIR)/usr/sbin rc.d install -m644 -t ${DESTDIR}/usr/share/man/man8 rc.d.8 install -m755 -t $(DESTDIR)/usr/lib/initscripts arch-tmpfiles arch-sysctl install -m644 tmpfiles.conf $(DESTDIR)/usr/lib/tmpfiles.d/arch.conf @@ -42,7 +40,7 @@ rc.d.8: rc.d.8.txt doc: rc.d.8
clean: - rm -f minilogd minilogd.o rc.d.8 + rm -f rc.d.8
release: git archive HEAD --prefix=initscripts-$(VER)/ | xz > initscripts-$(VER).tar.xz diff --git a/PKGBUILD b/PKGBUILD index 0c5b71d..deddbd5 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -2,7 +2,7 @@ pkgname=initscripts-git pkgver=$(date +%s) pkgrel=$(git log -1 --pretty=format:%h) pkgdesc="System initialization/bootup scripts" -arch=('i686' 'x86_64') +arch=('any') url="http://www.archlinux.org" license=('GPL') groups=('base') diff --git a/minilogd.c b/minilogd.c deleted file mode 100644 index c86ab23..0000000 --- a/minilogd.c +++ /dev/null @@ -1,202 +0,0 @@ -/* minilogd.c - * - * A pale imitation of syslogd. Most notably, doesn't write anything - * anywhere except possibly back to syslogd. - * - */ - -#include <errno.h> -#include <fcntl.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <strings.h> -#include <stdarg.h> -#include <syslog.h> -#ifndef __USE_BSD -# define __USE_BSD -#endif -#include <unistd.h> - -#include <sys/poll.h> -#include <sys/socket.h> -#include <sys/stat.h> -#include <sys/un.h> - -#define MAX_BUF_LINES 10000 -#define BUF_LINE_SIZE 8192 - -static int we_own_log=0; -static char **buffer=NULL; -static int buflines=0; - -int debug; - -int recvsock; - -void alarm_handler(int x) { - alarm(0); - close(recvsock); - recvsock = -1; -} - -void freeBuffer() { - struct sockaddr_un addr; - int sock; - int x=0,conn; - - memset(&addr, 0, sizeof(addr)); - addr.sun_family = AF_LOCAL; - strncpy(addr.sun_path,_PATH_LOG,sizeof(addr.sun_path)-1); - /* wait for klogd to hit syslog */ - sleep(2); - sock = socket(AF_LOCAL, SOCK_STREAM,0); - conn=connect(sock,(struct sockaddr *) &addr,(socklen_t)sizeof(addr)); - while (x<buflines) { - if (!conn) { - /*printf("to syslog: %s\n", buffer[x]);*/ - write(sock,buffer[x],strlen(buffer[x])+1); - } - free(buffer[x]); - x++; - } - free(buffer); -} - -void cleanup(int exitcode) { - /* If we own the log, unlink it before trying to free our buffer. - * Otherwise, sending the buffer to /dev/log doesn't make much sense.... */ - if (we_own_log) { - perror("wol"); - unlink(_PATH_LOG); - } - /* Don't try to free buffer if we were called from a signal handler */ - if (exitcode<=0) { - if (buffer) - freeBuffer(); - exit(exitcode); - } else - exit(exitcode+128); -} - -void runDaemon(int sock) { - struct sockaddr_un addr; - int x,done=0; - ssize_t len; - socklen_t addrlen = (socklen_t)sizeof(struct sockaddr_un); - char *message = NULL; - struct stat s1,s2; - struct pollfd pfds; - - daemon(0,-1); - /* try not to leave stale sockets lying around */ - /* Hopefully, we won't actually get any of these */ - signal(SIGHUP,cleanup); - signal(SIGINT,cleanup); - signal(SIGQUIT,cleanup); - signal(SIGILL,cleanup); - signal(SIGABRT,cleanup); - signal(SIGFPE,cleanup); - signal(SIGSEGV,cleanup); - signal(SIGPIPE,cleanup); - signal(SIGBUS,cleanup); - signal(SIGTERM,cleanup); - done = 0; - /* Get stat info on /dev/log so we can later check to make sure we - * still own it... */ - if (stat(_PATH_LOG,&s1) != 0) - memset(&s1, 0, sizeof(struct stat)); - while (!done) { - pfds.fd = sock; - pfds.events = POLLIN|POLLPRI; - pfds.revents = 0; - if ( ( (x=poll(&pfds,1,500))==-1) && errno !=EINTR) { - perror("poll"); - cleanup(-1); - } - if ( (x>0) && (pfds.revents & (POLLIN | POLLPRI))) { - if (message == NULL) { - message = calloc(BUF_LINE_SIZE,sizeof(char)); - } - recvsock = accept(sock,(struct sockaddr *) &addr, &addrlen); - alarm(2); - signal(SIGALRM, alarm_handler); - len = read(recvsock,message,BUF_LINE_SIZE); - alarm(0); - close(recvsock); - if (len>0) { - /*printf("line recv'd: %s\n", message);*/ - if (buflines < MAX_BUF_LINES) { - if (buffer) - buffer = realloc(buffer,(buflines+1)*sizeof(char *)); - else - buffer = malloc(sizeof(char *)); - message[strlen(message)]='\n'; - buffer[buflines]=message; - message = NULL; - buflines++; - } - } - else { - recvsock=-1; - } - } - if ( (x>0) && ( pfds.revents & (POLLHUP | POLLNVAL)) ) - done = 1; - /* Check to see if syslogd's yanked our socket out from under us */ - if ( (stat(_PATH_LOG,&s2)!=0) || - (s1.st_ino != s2.st_ino ) || (s1.st_ctime != s2.st_ctime) || - (s1.st_mtime != s2.st_mtime) ) { /*|| (s1.st_atime != s2.st_atime) ) {*/ - done = 1; - we_own_log = 0; - /*printf("someone stole our %s\n", _PATH_LOG); - printf("st_ino: %d %d\n", s1.st_ino, s2.st_ino); - printf("st_ctime: %d %d\n", s1.st_ctime, s2.st_ctime); - printf("st_atime: %d %d\n", s1.st_atime, s2.st_atime); - printf("st_mtime: %d %d\n", s1.st_mtime, s2.st_mtime);*/ - } - } - free(message); - cleanup(0); -} - -int main(int argc, char **argv) { - struct sockaddr_un addr; - int sock; - int pid; - - /* option processing made simple... */ - if (argc>1) debug=1; - /* just in case */ - sock = open("/dev/null",O_RDWR); - dup2(sock,0); - dup2(sock,1); - dup2(sock,2); - - memset(&addr, 0, sizeof(addr)); - addr.sun_family = AF_LOCAL; - strncpy(addr.sun_path,_PATH_LOG,sizeof(addr.sun_path)-1); - sock = socket(AF_LOCAL, SOCK_STREAM,0); - unlink(_PATH_LOG); - /* Bind socket before forking, so we know if the server started */ - if (!bind(sock,(struct sockaddr *) &addr, (socklen_t)sizeof(addr))) { - we_own_log = 1; - listen(sock,5); - if ((pid=fork())==-1) { - perror("fork"); - exit(3); - } - if (pid) { - exit(0); - } else { - /*printf("starting daemon...\n");*/ - runDaemon(sock); - /* shouldn't get back here... */ - exit(4); - } - } else { - exit(5); - } -} -/* vim: set ts=2 noet: */ diff --git a/rc.sysinit b/rc.sysinit index f82368a..d802f3f 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -31,8 +31,7 @@ findmnt / --options ro &>/dev/null ||
run_hook sysinit_start
-# start up our mini logger until syslog takes over -minilogd +# log all console messages bootlogd -p /run/bootlogd.pid
if [[ ! -a /usr/lib ]] ; then -- 1.7.7.1
On Thu, Oct 27, 2011 at 01:38:27AM +0200, Tom Gundersen wrote:
If /etc/hostname is non-empty its contents is assumed to be the hostname. This takes precedence over HOSTNAME in rc.conf.
Signed-off-by: Tom Gundersen <teg@jklm.no> --- rc.sysinit | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/rc.sysinit b/rc.sysinit index dffea4d..3e5fec9 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -232,6 +232,9 @@ RANDOM_SEED=/var/lib/misc/random-seed # Remove leftover files remove_leftover
+if [[ -s /etc/hostname ]]; then + HOSTNAME=$(cat /etc/hostname)
No need to fork. This should be a one line file. read -r HOSTNAME < /etc/hostname
+fi if [[ $HOSTNAME ]]; then stat_busy "Setting Hostname: $HOSTNAME" echo "$HOSTNAME" >| /proc/sys/kernel/hostname && stat_done || stat_fail -- 1.7.7.1
On Wed, Oct 26, 2011 at 6:44 PM, Dave Reisner <d@falconindy.com> wrote:
On Thu, Oct 27, 2011 at 01:38:27AM +0200, Tom Gundersen wrote:
If /etc/hostname is non-empty its contents is assumed to be the hostname. This takes precedence over HOSTNAME in rc.conf.
So this is going to really start to irk the old time crowd, and frankly one of the things I (and many others, for that matter) [1] have always loved about Arch- we don't have configuration scattered all over the place. We're beginning to move away from that- sure, rc.conf settings still work, but my gut is telling me those are becoming second-class now, and if you don't follow the systemd route, you are a big loser and stuck in 2002 or something. And I'll add this- I'm sorry I always seem to be cranky regarding initscripts changes. I love the fact that they have a caretaker now, so please don't think I don't appreciate all the work you pour into this. Does anyone else still hold onto the old days where configuration was primarily a single file rather than scattered buckshot in /etc/? If it is just me I'll shut up, but I've always loved that fact. If we insist on playing nice with systemd, have we considered flipping this on it's head here and having rc.d or some tool have an `rc.d reconfigure` which would do the scattering of the centralized settings for you? -Dan [1] http://www.google.com/search?q=arch+linux+rc.conf+simplicity
On 27/10/11 10:28, Dan McGee wrote:
Does anyone else still hold onto the old days where configuration was primarily a single file rather than scattered buckshot in /etc/? If it is just me I'll shut up, but I've always loved that fact.
I have to agree here. I was fine with the locale stuff moving out as I saw the advantage (control over individual locale components) and that putting those in rc.conf would be messy. But I do not see what advantage moving hostname out of rc.conf brings. Allan
On Thu, Oct 27, 2011 at 2:11 PM, Allan McRae <allan@archlinux.org> wrote:
On 27/10/11 10:28, Dan McGee wrote:
Does anyone else still hold onto the old days where configuration was primarily a single file rather than scattered buckshot in /etc/? If it is just me I'll shut up, but I've always loved that fact.
I have to agree here. I was fine with the locale stuff moving out as I saw the advantage (control over individual locale components) and that putting those in rc.conf would be messy. But I do not see what advantage moving hostname out of rc.conf brings.
I'm happy to drop this patch if it rubs people the wrong way. I'll give you my rationale first though, just to try and convince you I'm not proposing things just for the sake of it :-) 1) no downsides: This is an optional feature, so if you don't do anything you are not affected. If you prefer rc.conf and its simplicity to whatever benefits you get from the new format, then you are free to stick with it. Indeed, even if you were to move to systemd, setting the hostname++ in rc.conf would still work (this was one of my first patches to systemd). 2) interoptability: I have seen patches appearing in the gnome repository adding support for the systemd-style config files, and we can only hope that other third-party projects will follow. In my opinion it would be nice to be able to tell users that, if they want, they can move to the new format and get these features for free. The alternative would be to also add support for rc.conf to the relevant third-party project, but due to rc.conf being a bash script, this is not so simple (if we want to do it properly). To parse rc.conf, your app needs to use a bash interpreter (as rc.conf could contain any bash code), and writing to rc.conf can only be done correctly and without creating a mess if you make assumptions about it's structure (e.g. that it only contains assignments, and no conditionals / loops / sourcing...). 3) cross-distro compatibility: imho it is a real benefit to everyone doing the trivial things in the same way (or at least it being possible to do them in the same way). I guess this would be appreciated by admins who have to deal with different distros on different machines. Eventually it would also make non-distro-specific guides, books, tutorials, etc simpler. What do you think? Still NACK? -t
On 28/10/11 09:35, Tom Gundersen wrote:
On Thu, Oct 27, 2011 at 2:11 PM, Allan McRae<allan@archlinux.org> wrote:
On 27/10/11 10:28, Dan McGee wrote:
Does anyone else still hold onto the old days where configuration was primarily a single file rather than scattered buckshot in /etc/? If it is just me I'll shut up, but I've always loved that fact.
I have to agree here. I was fine with the locale stuff moving out as I saw the advantage (control over individual locale components) and that putting those in rc.conf would be messy. But I do not see what advantage moving hostname out of rc.conf brings.
I'm happy to drop this patch if it rubs people the wrong way. I'll give you my rationale first though, just to try and convince you I'm not proposing things just for the sake of it :-)
1) no downsides: This is an optional feature, so if you don't do anything you are not affected. If you prefer rc.conf and its simplicity to whatever benefits you get from the new format, then you are free to stick with it. Indeed, even if you were to move to systemd, setting the hostname++ in rc.conf would still work (this was one of my first patches to systemd).
2) interoptability: I have seen patches appearing in the gnome repository adding support for the systemd-style config files, and we can only hope that other third-party projects will follow. In my opinion it would be nice to be able to tell users that, if they want, they can move to the new format and get these features for free. The alternative would be to also add support for rc.conf to the relevant third-party project, but due to rc.conf being a bash script, this is not so simple (if we want to do it properly). To parse rc.conf, your app needs to use a bash interpreter (as rc.conf could contain any bash code), and writing to rc.conf can only be done correctly and without creating a mess if you make assumptions about it's structure (e.g. that it only contains assignments, and no conditionals / loops / sourcing...).
3) cross-distro compatibility: imho it is a real benefit to everyone doing the trivial things in the same way (or at least it being possible to do them in the same way). I guess this would be appreciated by admins who have to deal with different distros on different machines. Eventually it would also make non-distro-specific guides, books, tutorials, etc simpler.
What do you think? Still NACK?
You had me at #1... My main concerns is a slippery slope where this extra file gets introduced as optional now, but after a while it becomes accepted as the default way to configure stuff and then more changes are made so that rc.conf stops working. Cross-distro compatibility etc is all good, but remember there are reasons for different distros and we should not lose what makes Arch unique. Anyway, my voice of descent is rather weak given I have little understanding of the whole start-up process (push button, magic occurs, login prompt...). And it is good to see this whole area being given the attention it deserves. So in the end, I defer to whatever the people doing the work think is best. Cheers, Allan
On Fri, Oct 28, 2011 at 2:57 AM, Allan McRae <allan@archlinux.org> wrote:
On 28/10/11 09:35, Tom Gundersen wrote:
On Thu, Oct 27, 2011 at 2:11 PM, Allan McRae<allan@archlinux.org> wrote:
On 27/10/11 10:28, Dan McGee wrote:
Does anyone else still hold onto the old days where configuration was primarily a single file rather than scattered buckshot in /etc/? If it is just me I'll shut up, but I've always loved that fact.
I have to agree here. I was fine with the locale stuff moving out as I saw the advantage (control over individual locale components) and that putting those in rc.conf would be messy. But I do not see what advantage moving hostname out of rc.conf brings.
I'm happy to drop this patch if it rubs people the wrong way. I'll give you my rationale first though, just to try and convince you I'm not proposing things just for the sake of it :-)
1) no downsides: This is an optional feature, so if you don't do anything you are not affected. If you prefer rc.conf and its simplicity to whatever benefits you get from the new format, then you are free to stick with it. Indeed, even if you were to move to systemd, setting the hostname++ in rc.conf would still work (this was one of my first patches to systemd).
2) interoptability: I have seen patches appearing in the gnome repository adding support for the systemd-style config files, and we can only hope that other third-party projects will follow. In my opinion it would be nice to be able to tell users that, if they want, they can move to the new format and get these features for free. The alternative would be to also add support for rc.conf to the relevant third-party project, but due to rc.conf being a bash script, this is not so simple (if we want to do it properly). To parse rc.conf, your app needs to use a bash interpreter (as rc.conf could contain any bash code), and writing to rc.conf can only be done correctly and without creating a mess if you make assumptions about it's structure (e.g. that it only contains assignments, and no conditionals / loops / sourcing...).
3) cross-distro compatibility: imho it is a real benefit to everyone doing the trivial things in the same way (or at least it being possible to do them in the same way). I guess this would be appreciated by admins who have to deal with different distros on different machines. Eventually it would also make non-distro-specific guides, books, tutorials, etc simpler.
What do you think? Still NACK?
You had me at #1... My main concerns is a slippery slope where this extra file gets introduced as optional now, but after a while it becomes accepted as the default way to configure stuff and then more changes are made so that rc.conf stops working. Cross-distro compatibility etc is all good, but remember there are reasons for different distros and we should not lose what makes Arch unique.
Anyway, my voice of descent is rather weak given I have little understanding of the whole start-up process (push button, magic occurs, login prompt...). And it is good to see this whole area being given the attention it deserves. So in the end, I defer to whatever the people doing the work think is best.
I agree with Dan and Allan about the feeling that rc.conf become less and less the central point of configuration. But to have a complete hostname configuration, we have to take in consideration, in our current archlinux setups, we needs to edit /etc/rc.conf et /etc/hosts to have a right "hostname", "hostname -f" and "domainname". So i'm hesistant about hostname setting because it already need an external file to be correctly setup. About locale.conf, imho the bug report was closed too quickly, the current solution doesn't correctly adress the issue. Inheritance of locales should not be done by a login shell but by process granting access (by example pam). This would fix issues with *dm started by inittab. -- Sébastien Luttringer www.seblu.net
On Fri, Oct 28, 2011 at 8:44 PM, Seblu <seblu@seblu.net> wrote:
But to have a complete hostname configuration, we have to take in consideration, in our current archlinux setups, we needs to edit /etc/rc.conf et /etc/hosts to have a right "hostname", "hostname -f" and "domainname".
Having to edit /etc/hosts is indeed a pain, we should just ship <http://0pointer.de/lennart/projects/nss-myhostname/>, which does the correct thing for us automatically without requiring /etc/hosts to contain the hostname.
About locale.conf, imho the bug report was closed too quickly, the current solution doesn't correctly adress the issue. Inheritance of locales should not be done by a login shell but by process granting access (by example pam). This would fix issues with *dm started by inittab.
As far as I understood the report, the problem was fixed (the locale.sh is not re-sourced if you start a non-login shell). However, what you describe sounds like a possibly nicer way to implement it, so I'd be interested in seeing some patches ;-) Cheers, Tom
On Thu, Oct 27, 2011 at 7:44 AM, Dave Reisner <d@falconindy.com> wrote:
On Thu, Oct 27, 2011 at 01:38:27AM +0200, Tom Gundersen wrote:
If /etc/hostname is non-empty its contents is assumed to be the hostname. This takes precedence over HOSTNAME in rc.conf.
Signed-off-by: Tom Gundersen <teg@jklm.no> --- rc.sysinit | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/rc.sysinit b/rc.sysinit index dffea4d..3e5fec9 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -232,6 +232,9 @@ RANDOM_SEED=/var/lib/misc/random-seed # Remove leftover files remove_leftover
+if [[ -s /etc/hostname ]]; then + HOSTNAME=$(cat /etc/hostname)
No need to fork. This should be a one line file.
read -r HOSTNAME < /etc/hostname
If /etc/hostname does not end with a newline, `read' will return 1. Not sure if it matters here, but worth mentioning. How about, HOSTNAME=$(< /etc/hostname)
+fi if [[ $HOSTNAME ]]; then stat_busy "Setting Hostname: $HOSTNAME" echo "$HOSTNAME" >| /proc/sys/kernel/hostname && stat_done || stat_fail -- 1.7.7.1
On Thu, Oct 27, 2011 at 11:36:01AM +0800, lolilolicon wrote:
On Thu, Oct 27, 2011 at 7:44 AM, Dave Reisner <d@falconindy.com> wrote:
On Thu, Oct 27, 2011 at 01:38:27AM +0200, Tom Gundersen wrote:
If /etc/hostname is non-empty its contents is assumed to be the hostname. This takes precedence over HOSTNAME in rc.conf.
Signed-off-by: Tom Gundersen <teg@jklm.no> --- rc.sysinit | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/rc.sysinit b/rc.sysinit index dffea4d..3e5fec9 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -232,6 +232,9 @@ RANDOM_SEED=/var/lib/misc/random-seed # Remove leftover files remove_leftover
+if [[ -s /etc/hostname ]]; then + HOSTNAME=$(cat /etc/hostname)
No need to fork. This should be a one line file.
read -r HOSTNAME < /etc/hostname
If /etc/hostname does not end with a newline, `read' will return 1. Not sure if it matters here, but worth mentioning.
How about, HOSTNAME=$(< /etc/hostname)
read returns 1 on EOF, too. Yes, we probably should cater to special people who want to bloat their /etc/hostname. IFS=$'\n' read -rd '' HOSTNAME </etc/hostname d
On Thu, Oct 27, 2011 at 11:48 AM, Dave Reisner <d@falconindy.com> wrote:
On Thu, Oct 27, 2011 at 11:36:01AM +0800, lolilolicon wrote:
On Thu, Oct 27, 2011 at 7:44 AM, Dave Reisner <d@falconindy.com> wrote:
On Thu, Oct 27, 2011 at 01:38:27AM +0200, Tom Gundersen wrote:
If /etc/hostname is non-empty its contents is assumed to be the hostname. This takes precedence over HOSTNAME in rc.conf.
Signed-off-by: Tom Gundersen <teg@jklm.no> --- rc.sysinit | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/rc.sysinit b/rc.sysinit index dffea4d..3e5fec9 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -232,6 +232,9 @@ RANDOM_SEED=/var/lib/misc/random-seed # Remove leftover files remove_leftover
+if [[ -s /etc/hostname ]]; then + HOSTNAME=$(cat /etc/hostname)
No need to fork. This should be a one line file.
read -r HOSTNAME < /etc/hostname
If /etc/hostname does not end with a newline, `read' will return 1. Not sure if it matters here, but worth mentioning.
How about, HOSTNAME=$(< /etc/hostname)
read returns 1 on EOF, too. Yes, we probably should cater to special people who want to bloat their /etc/hostname.
IFS=$'\n' read -rd '' HOSTNAME </etc/hostname
Presumably there won't be any liternal NUL in /etc/hostname, so the above: - strips the leading and traling newlines, and assign everything in between to HOSTNAME. - always returns 1 My question is, technically, what characters are allowed in HOSTNAME? Is newline allowed? How about NUL?
d
participants (6)
-
Allan McRae
-
Dan McGee
-
Dave Reisner
-
lolilolicon
-
Seblu
-
Tom Gundersen