From a74f312263b4154414dea1bc494818b1bcbb6b9b Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Wed, 27 Jul 2011 23:07:15 +0200 Subject: Let background daemons show errors on stderr Daemon running in background should let error output to be printed. Standart output is still hided to have a correct printing in default cases. This will help to detect error in daemon runned in background. This will also remove have_daemon call which is already called in start_daemon. Signed-off-by: Sebastien Luttringer --- functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions b/functions index f68c088..eaa1374 100644 --- a/functions +++ b/functions @@ -218,7 +218,7 @@ ck_depends() { start_daemon_bkgd() { stat_bkgd "Starting $1" - have_daemon "$1" && (start_daemon "$1") &>/dev/null & + (start_daemon "$1") >/dev/null & } stop_daemon() { -- cgit v1.2.3 From 1ce1675dd7c2edf89c58be70908df289c2b2665b Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Mon, 8 Aug 2011 20:13:20 +0200 Subject: Remove double case in hwclock daemon Signed-off-by: Sebastien Luttringer --- hwclock | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/hwclock b/hwclock index 5996b95..9c05843 100755 --- a/hwclock +++ b/hwclock @@ -13,11 +13,7 @@ case "$1" in start) add_daemon hwclock;; stop) - case $HARDWARECLOCK in - UTC) hwclock --adjust --utc;; - localtime) hwclock --adjust --localtime;; - "") hwclock --adjust;; - esac + hwclock --adjust $HWCLOCK_PARAMS rm_daemon hwclock ;; restart) -- cgit v1.2.3 From 4e573b6b35d4468b4b3856a7784728f75ab2e73a Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Mon, 8 Aug 2011 20:50:51 +0200 Subject: New smarter display of bad daemon names in rc.d Signed-off-by: Sebastien Luttringer --- rc.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rc.d b/rc.d index 5cb03f8..9b0f092 100755 --- a/rc.d +++ b/rc.d @@ -69,8 +69,8 @@ case $1 in if [[ -x "/etc/rc.d/$i" ]]; then env -i "${ENV[@]}" "/etc/rc.d/$i" "$action" else - printf "${C_OTHER}:: ${C_FAIL}Error: ${C_DONE}Daemon script \`%s' does not exist or is not executable.${C_CLEAR}\n" \ - "$i" + printf "${C_FAIL}:: ${C_DONE}Daemon ${C_FAIL}$i${C_DONE} does not exist \ +or is not executable${C_CLEAR}\n" fi (( ret += !! $? )) # clamp exit value to 0/1 done -- cgit v1.2.3 From 227b71e67d19f73128862d20aac714537c8517df Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Mon, 8 Aug 2011 21:38:56 +0200 Subject: rc.d: handle a set of options rc.d can now take --started, --stopped, --auto, --noauto as option which help user to filter list of daemon for all actions As a corollary list command can now take a list of dameon to display All kind of arguments can be mixed to obtain the proper output. zsh and bash completion are updated Note: Output of help command exit 0 and is no more printed on stderr Signed-off-by: Sebastien Luttringer --- bash-completion | 20 ++++----- rc.d | 124 ++++++++++++++++++++++++++++++++++++++++---------------- zsh-completion | 8 +--- 3 files changed, 101 insertions(+), 51 deletions(-) diff --git a/bash-completion b/bash-completion index d78484e..4b4593b 100644 --- a/bash-completion +++ b/bash-completion @@ -3,20 +3,20 @@ _rc_d() { local action cur prev - action="help list start stop reload restart" + actions='help list start stop reload restart' + options='-s --started -S --stopped -a --auto -A --noauto' _get_comp_words_by_ref cur prev - if ((COMP_CWORD == 1)); then - COMPREPLY=($(compgen -W "${action}" -- "$cur")) - elif [[ "$prev" == help ]]; then + _get_first_arg + if [[ -z "$arg" ]]; then + COMPREPLY=($(compgen -W "${actions} ${options}" -- "$cur")) + elif [[ "$arg" == help ]]; then COMPREPLY=() - elif [[ "$prev" == list ]]; then - ((COMP_CWORD == 2)) && COMPREPLY=($(compgen -W "started stopped" -- "$cur")) || COMPREPLY=() - elif [[ "$prev" == start ]]; then + elif [[ "$arg" == start ]]; then COMPREPLY=($(comm -23 <(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort) <(cd /run/daemons/ && compgen -f "$cur"|sort))) - elif [[ "$prev" =~ stop|restart|reload ]]; then + elif [[ "$arg" =~ stop|restart|reload ]]; then COMPREPLY=($(cd /run/daemons/ && compgen -f "$cur"|sort)) - elif ((COMP_CWORD > 1)); then - COMPREPLY=($(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort)) + else + COMPREPLY=($(compgen -W "${options} $(cd /etc/rc.d && compgen -f -X 'functions*')" -- "$cur")) fi } complete -F _rc_d rc.d diff --git a/rc.d b/rc.d index 9b0f092..3f2835e 100755 --- a/rc.d +++ b/rc.d @@ -4,74 +4,128 @@ NEED_ROOT=0 # this script can be run without be root . /etc/rc.conf . /etc/rc.d/functions +# print usage and exit usage() { local name=${0##*/} cat >&2 << EOF -usage: $name [daemon] ... - $name list [started|stopped] - $name help +usage: $name [options] [daemons] - is the name of a script in /etc/rc.d +options: + -s, --started Filter started daemons + -S, --stopped Filter stopped daemons + -a, --auto Filter auto started daemons + -A, --noauto Filter manually started daemons + + is a space separated list of script in /etc/rc.d can be a start, stop, restart, reload, status, ... WARNING: initscripts are free to implement or not the above actions. e.g: $name list - $name list started - $name help + $name list sshd gpm + $name list --started gpm $name start sshd gpm + $name stop --noauto + $name help EOF - exit 1 + exit ${1:-1} +} + +# filter list of daemons +filter_daemons() { + local -a new_daemons=() + for daemon in "${daemons[@]}"; do + # check if daemons is valid + if ! have_daemon "$daemon"; then + printf "${C_FAIL}:: ${C_DONE}Dameon script ${C_FAIL}${daemon}${C_DONE} does \ +not exist or is not executable.${C_CLEAR}\n" >&2 + exit 2 + fi + # check filter + ((${filter[started]} == 1)) && ck_daemon "$daemon" && continue + ((${filter[stopped]} == 1)) && ! ck_daemon "$daemon" && continue + ((${filter[auto]} == 1)) && ck_autostart "$daemon" && continue + ((${filter[noauto]} == 1)) && ! ck_autostart "$daemon" && continue + new_daemons+=("$daemon") + done + daemons=("${new_daemons[@]}") } (( $# < 1 )) && usage +# ret store the return code of rc.d declare -i ret=0 -case $1 in +# daemons store daemons on which action will be executed +declare -a daemons=() +# filter store current filter mode +declare -A filter=([started]=0 [stopped]=0 [auto]=0 [noauto]=0) + +# parse options +argv=$(getopt -l 'started,stopped,auto,noauto' -- 'sSaA' "$@") || usage +eval set -- "$argv" + +# create an initial daemon list +while [[ "$1" != -- ]]; do + case "$1" in + -s|--started) filter[started]=1 ;; + -S|--stopped) filter[stopped]=1 ;; + -a|--auto) filter[auto]=1 ;; + -A|--noauto) filter[noauto]=1 ;; + esac + shift +done + +# remove -- +shift +# get action +action=$1 +shift + +# get initial daemons list +for daemon; do + daemons+=("$daemon") +done + +# going into script directory +cd /etc/rc.d + +case $action in help) - usage - ;; + usage 0 2>&1 + ;; list) - shift - cd /etc/rc.d/ - for d in *; do - have_daemon "$d" || continue + # list take all daemons by default + [[ -z $daemons ]] && for d in *; do have_daemon "$d" && daemons+=("$d"); done + filter_daemons + for daemon in "${daemons[@]}"; do # print running / stopped satus - if ! ck_daemon "$d"; then - [[ "$1" == stopped ]] && continue - printf "${C_OTHER}[${C_DONE}STARTED${C_OTHER}]" + if ! ck_daemon "$daemon"; then + s_status="${C_OTHER}[${C_DONE}STARTED${C_OTHER}]" else - [[ "$1" == started ]] && continue - printf "${C_OTHER}[${C_FAIL}STOPPED${C_OTHER}]" + s_status="${C_OTHER}[${C_FAIL}STOPPED${C_OTHER}]" fi # print auto / manual status - if ! ck_autostart "$d"; then - printf "${C_OTHER}[${C_DONE}AUTO${C_OTHER}]" + if ! ck_autostart "$daemon"; then + s_auto="${C_OTHER}[${C_DONE}AUTO${C_OTHER}]" else - printf "${C_OTHER}[${C_FAIL} ${C_OTHER}]" + s_auto="${C_OTHER}[${C_FAIL} ${C_OTHER}]" fi - printf " ${C_CLEAR}$d\n" + printf "$s_status$s_auto${C_CLEAR} $daemon\n" done ;; *) - # check min args count - (( $# < 2 )) && usage - action=$1 - shift + # other actions need an explicit daemons list + [[ -z $daemons ]] && usage + filter_daemons # set same environment variables as init runlevel=$(/sbin/runlevel) - ENV=("PATH=/bin:/usr/bin:/sbin:/usr/sbin" + ENV=('PATH=/bin:/usr/bin:/sbin:/usr/sbin' "PREVLEVEL=${runlevel%% *}" "RUNLEVEL=${runlevel##* }" "CONSOLE=${CONSOLE:-/dev/console}" "TERM=$TERM") cd / - for i; do - if [[ -x "/etc/rc.d/$i" ]]; then - env -i "${ENV[@]}" "/etc/rc.d/$i" "$action" - else - printf "${C_FAIL}:: ${C_DONE}Daemon ${C_FAIL}$i${C_DONE} does not exist \ -or is not executable${C_CLEAR}\n" - fi + for daemon in "${daemons[@]}"; do + env -i "${ENV[@]}" "/etc/rc.d/$daemon" "$action" (( ret += !! $? )) # clamp exit value to 0/1 done ;; diff --git a/zsh-completion b/zsh-completion index e5c2850..58fdfab 100644 --- a/zsh-completion +++ b/zsh-completion @@ -4,11 +4,10 @@ _rc.d () { local curcontext="$curcontext" state line typeset -A opt_args - _arguments "1: :->action" "*: :->service" - + _arguments "1: :->action" "*: :->service" {-s,--started} {-S,--stopped} {-a,--auto} {-A,--noauto} case $state in action) - _arguments "1:action:(list help start stop restart)" + _arguments "*:action:(list help start stop restart)" ;; service) local action="$words[2]" @@ -18,9 +17,6 @@ _rc.d () { help) _arguments "*: :" ;; - list) - _arguments "2: :(started stopped)" - ;; start) _arguments "*: :($(comm -23 <(echo /etc/rc.d/*(N-*:t)|tr ' ' '\n') <(echo /run/daemons/*(N:t)|tr ' ' '\n')))" ;; -- cgit v1.2.3 From 5948612fe7191734ccc89570e808659ee2e6b3e3 Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Wed, 31 Aug 2011 11:32:51 +0200 Subject: Load sysctl config files from sysctl.d This patch implement loading of sysctl config files as described in http://0pointer.de/public/systemd-man/sysctl.d.html This is a very conveniant way of configuring sysctl option for sysadmin which can drop sysctl config files inside this directory to enable some feature. Dropping a file like disableipv6.conf inside this directory will disable ipv6 $ cat disableipv6.conf net.ipv6.conf.all.disable_ipv6 = 1 There is atm no package which use this functionnality Signed-off-by: Sebastien Luttringer --- Makefile | 4 +++- arch-sysctl | 29 +++++++++++++++++++++++++++++ rc.multi | 4 ++-- 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100755 arch-sysctl diff --git a/Makefile b/Makefile index 4916387..a6262e2 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,8 @@ DIRS := \ /usr/sbin \ /etc/tmpfiles.d \ /usr/lib/tmpfiles.d \ + /etc/sysctl.d \ + /usr/lib/sysctl.d \ /usr/lib/initscripts \ /etc/bash_completion.d \ /usr/share/zsh/site-functions @@ -25,7 +27,7 @@ install: minilogd installdirs 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/lib/initscripts arch-tmpfiles + install -m755 -t $(DESTDIR)/usr/lib/initscripts arch-tmpfiles arch-sysctl install -m644 tmpfiles.conf $(DESTDIR)/usr/lib/tmpfiles.d/arch.conf install -m644 -T bash-completion $(DESTDIR)/etc/bash_completion.d/rc.d install -m644 -T zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_rc.d diff --git a/arch-sysctl b/arch-sysctl new file mode 100755 index 0000000..4856df6 --- /dev/null +++ b/arch-sysctl @@ -0,0 +1,29 @@ +#!/bin/bash +# +# /usr/lib/initscripts/arch-sysctl +# +# Load sysctl configuration files following +# http://0pointer.de/public/systemd-man/sysctl.d.html +# + +shopt -s nullglob + +declare -a sysctl_d=( + /usr/lib/sysctl.d/*.conf + /etc/sysctl.d/*.conf + /run/sysctl.d/*.conf + /etc/sysctl.conf +) +declare -A fragments + +# files declared later in the sysctl_d array will override earlier +# Example: `/etc/sysctl.d/foo.conf' supersedes `/usr/lib/sysctl.d/foo.conf'. +for path in "${sysctl_d[@]}"; do + [[ -f $path ]] && fragments[${path##*/}]=$path +done + +for path in "${fragments[@]}"; do + sysctl -q -p "$path" +done + +# vim: set ts=2 sw=2 noet: diff --git a/rc.multi b/rc.multi index 16fa83a..19623d8 100755 --- a/rc.multi +++ b/rc.multi @@ -8,8 +8,8 @@ run_hook multi_start -# Load sysctl variables if sysctl.conf is present -[[ -r /etc/sysctl.conf ]] && sysctl -q -p &>/dev/null +# Load sysctl config files +[[ -x /usr/lib/initscripts/arch-sysctl ]] && /usr/lib/initscripts/arch-sysctl # Start daemons for daemon in "${DAEMONS[@]}"; do -- cgit v1.2.3 From 872444291d3ab4cbeecd4a24216531564986a01c Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 4 Sep 2011 10:12:18 -0400 Subject: functions: clarify source of module loading This isn't _all_ your modules. Just the extras specified from rc.conf. Signed-off-by: Dave Reisner --- functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions b/functions index eaa1374..f550642 100644 --- a/functions +++ b/functions @@ -323,7 +323,7 @@ udevd_modprobe() { # Load modules from the MODULES array defined in rc.conf [[ -f /proc/modules ]] && (( ${#MODULES[*]} )) && - status "Loading Modules" modprobe -ab "${MODULES[@]}" + status "Loading User-specified Modules" modprobe -ab "${MODULES[@]}" status "Waiting for UDev uevents to be processed" \ udevadm settle --timeout=${UDEV_TIMEOUT:-30} -- cgit v1.2.3 From ae92346c03bc60578bfb5bddef9dbbf1b4d71460 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 4 Sep 2011 15:41:53 -0400 Subject: timezone: create /etc/localtime as a symlink Abstract out timezone setting into its own function, passing Country/Area as a parameter. Do some menial checking to make sure: - the zonefile actually exists, erroring when it doesn't - /etc/localtime is a symlink to the correct zoneinfo file, relinking when it isn't. Signed-off-by: Dave Reisner --- functions | 17 +++++++++++++++++ rc.sysinit | 4 +--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/functions b/functions index f550642..b85de46 100644 --- a/functions +++ b/functions @@ -369,6 +369,23 @@ read_crypttab() { return $failed } +set_timezone() { + local tz=$1 zonefile=/usr/share/zoneinfo/$tz + + [[ $tz ]] || return 1 + + if [[ ! -e $zonefile ]]; then + printf "error: \`%s' is not a valid timezone\n" "$tz" + return 1 + fi + + if [[ -L /etc/localtime && /etc/localtime -ef $zonefile ]]; then + return 0 + fi + + ln -sf "/usr/share/zoneinfo/$tz" /etc/localtime +} + # Filesystem functions # These can be overridden/reused for customizations like shutdown/loop-fsck. NETFS="nfs,nfs4,smbfs,cifs,codafs,ncpfs,shfs,fuse,fuseblk,glusterfs,davfs,fuse.glusterfs" diff --git a/rc.sysinit b/rc.sysinit index 9f215c4..2a7db8b 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -221,9 +221,7 @@ run_hook sysinit_postmount status "Activating Swap" swapon -a -[[ $TIMEZONE ]] && - status "Configuring Time Zone" \ - cp --remove-destination "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime +[[ $TIMEZONE ]] && status "Configuring Time Zone" set_timezone "$TIMEZONE" RANDOM_SEED=/var/lib/misc/random-seed [[ -f $RANDOM_SEED ]] && -- cgit v1.2.3 From e0cd30462e62bad1420bd83d4408cc83ae202fda Mon Sep 17 00:00:00 2001 From: Gerardo Exequiel Pozzi Date: Fri, 19 Aug 2011 11:29:30 -0300 Subject: [initscript] Make locale.sh consistent with default rc.conf rc.conf defaults LOCALE to en_US.UTF-8 Signed-off-by: Gerardo Exequiel Pozzi --- locale.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locale.sh b/locale.sh index 611a797..6723f95 100644 --- a/locale.sh +++ b/locale.sh @@ -1,3 +1,3 @@ . /etc/rc.conf -export LANG=${LOCALE:=en_US} +export LANG=${LOCALE:=en_US.UTF-8} -- cgit v1.2.3 From 34c8a9f600d17010ed6b77ad685ed83a76322d3d Mon Sep 17 00:00:00 2001 From: Gerardo Exequiel Pozzi Date: Mon, 12 Sep 2011 12:32:23 -0300 Subject: [initscripts] Remove too early /dev/null redirection Since recent change in udev package [#1] (install: remove post-install) In case of booting without initramfs and there is no /dev/null: * if / is ro, devtmpfs mount will fail, in consecuence /dev will be mounted as tmpfs. * if / is rw, devtmpfs mount will success, but a regular file /dev/null in / will be created. [#1] http://projects.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/udev&id=8728747c2b3d5d0506f7e6f1ac74edc0319591d6 Signed-off-by: Gerardo Exequiel Pozzi --- rc.sysinit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc.sysinit b/rc.sysinit index 2a7db8b..d6e7bbd 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -15,7 +15,7 @@ printsep mountpoint -q /proc || mount -n -t proc proc /proc -o nosuid,noexec,nodev mountpoint -q /sys || mount -n -t sysfs sys /sys -o nosuid,noexec,nodev mountpoint -q /run || mount -n -t tmpfs run /run -o mode=0755,size=10M,nosuid,nodev -mountpoint -q /dev || mount -n -t devtmpfs udev /dev -o mode=0755,size=10M,nosuid &>/dev/null \ +mountpoint -q /dev || mount -n -t devtmpfs udev /dev -o mode=0755,size=10M,nosuid \ || mount -n -t tmpfs udev /dev -o mode=0755,size=10M,nosuid mkdir -p -m 1777 /run/lock mkdir -p /dev/{pts,shm} -- cgit v1.2.3 From 5f7f87fa3259310454793521ac181028c31c1014 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sat, 24 Sep 2011 22:19:29 +0200 Subject: timezone: use function in shutdown like in sysinit This uses the function introduced in 9b77b7d7b535c3c52c99a95374e1f800466c6414. Signed-off-by: Tom Gundersen --- rc.shutdown | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rc.shutdown b/rc.shutdown index db8f50b..ad91f76 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -37,9 +37,7 @@ stat_busy "Saving Random Seed" dd if=/dev/urandom of=$RANDOM_SEED count=1 bs=$POOL_SIZE &>/dev/null stat_done -[[ $TIMEZONE ]] && - status "Saving Time Zone" \ - cp --remove-destination "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime +[[ $TIMEZONE ]] && status "Configuring Time Zone" set_timezone "$TIMEZONE" # Write to wtmp file before unmounting halt -w -- cgit v1.2.3 From 0093b7447019a9ca73c619c007fdd287329f9f52 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sat, 24 Sep 2011 22:21:32 +0200 Subject: shutdown: move disabling of monitoring/swap We do this before killing all processes. There is no reason to do it later, and this might give some processes a bit more time to terminate properly. Signed-off-by: Tom Gundersen --- rc.shutdown | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/rc.shutdown b/rc.shutdown index ad91f76..ea86f8f 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -19,6 +19,12 @@ run_hook shutdown_start stop_all_daemons +status "Deactivating Swap" swapoff -a + +# stop monitoring of lvm2 groups before unmounting filesystems +[[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) ]] && + status "Deactivating monitoring of LVM2 groups" vgchange --monitor n + run_hook shutdown_prekillall kill_all @@ -42,13 +48,6 @@ stat_done # Write to wtmp file before unmounting halt -w -status "Deactivating Swap" swapoff -a - -# stop monitoring of lvm2 groups before unmounting filesystems -[[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) && -d /sys/block ]] && - status "Deactivating monitoring of LVM2 groups" \ - vgchange --monitor n &>/dev/null - # if we don't have devtmpfs support, /dev is mounted as tmpfs, so don't unmount it status "Unmounting Filesystems" \ umount -a -r -t nodevtmpfs,notmpfs,nosysfs,noproc,nodevpts -O no_netdev -- cgit v1.2.3 From f90526071644423b67a9ba4b0421f94b890dee89 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sat, 24 Sep 2011 22:23:35 +0200 Subject: kill: give proper error messages and increase timeout With the new logic we will only wait for the timeout in case of problems, we therefore increase the timeout as this will make problems more obvious. There has been reports of problems with processes not being terminated, but hopefully this should help us reproduce them. Signed-off-by: Tom Gundersen --- functions | 52 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/functions b/functions index b85de46..0eb905f 100644 --- a/functions +++ b/functions @@ -284,28 +284,42 @@ stop_all_daemons() { done } -kill_all() { - # Terminate all processes - # and wait until killall5 reports all done or timeout +# $1 - signal +# $2 - iterations +kill_all_wait() { + # Send SIGTERM/SIGKILL all processes and wait until killall5 + # reports all done or timeout. # Unfortunately killall5 does not support the 0 signal, so just # use SIGCONT for checking (which should be ignored). - stat_busy "Sending SIGTERM To Processes" - local i - killall5 -15 ${omit_pids[@]/#/-o } &>/dev/null - for (( i=0; i<20 && $?!=2; i++ )); do - sleep .25 # 1/4 second - killall5 -18 ${omit_pids[@]/#/-o } &>/dev/null - done - stat_done - stat_busy "Sending SIGKILL To Processes" - local i - killall5 -9 ${omit_pids[@]/#/-o } &>/dev/null - for (( i=0; i<4 && $?!=2; i++ )); do - sleep .25 # 1/4 second - killall5 -18 ${omit_pids[@]/#/-o } &>/dev/null - done - stat_done + local i + + killall5 -${1} ${omit_pids[@]/#/-o } &>/dev/null + + for (( i=0; i<${2}; i++ )); do + + sleep .25 # 1/4 second + + # sending SIGCONT to processes to check if they are there + killall5 -18 ${omit_pids[@]/#/-o } &>/dev/null + + if (( $? == 2 )); then + return 0 + fi + done + + return 1 +} + +kill_all() { + stat_busy "Sending SIGTERM To Processes" + kill_all_wait 15 40 + if (( $? == 0 )); then + stat_done + else + stat_fail + status "Sending SIGKILL To Processes" kill_all_wait 9 60 + fi } # Start/trigger UDev, load MODULES and settle UDev -- cgit v1.2.3 From 71fe1590598381588502e58b60622b0b72d79454 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sat, 24 Sep 2011 22:50:46 +0200 Subject: bootlog: clean some more ANSI codes I was getting "^[71G", this fixed it. Signed-off-by: Tom Gundersen --- functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions b/functions index 0eb905f..ab6d9ae 100644 --- a/functions +++ b/functions @@ -466,7 +466,7 @@ bootlogd_stop() { kill $(< /run/bootlogd.pid) rm -f /run/bootlogd.pid sed -i -r -e 's/\^\[\[[0-9]?;?[0-9]?[0-9]?;?[0-9]?[0-9]?[ms]//g' \ - -e 's/\^\[(\[1[0-9]1|%)G//g' -e 's/\^\[\[0;1//g' /var/log/boot + -e 's/\^\[(\[1?[0-9]1|%)G//g' -e 's/\^\[\[0;1//g' /var/log/boot } ############################### -- cgit v1.2.3 From 21f1a7c7eb961c5049fa6d05f95361bdad245dc9 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 24 Sep 2011 19:43:39 -0400 Subject: respect the user's choice for /etc/localtime This can be a symlink or a regular file, and rc.sysinit will preserve it as such. Signed-off-by: Dave Reisner --- functions | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/functions b/functions index ab6d9ae..2ea81f9 100644 --- a/functions +++ b/functions @@ -397,7 +397,12 @@ set_timezone() { return 0 fi - ln -sf "/usr/share/zoneinfo/$tz" /etc/localtime + # respect the user's decision to symlink or copy + if [[ -L /etc/localtime ]]; then + ln -sf "/usr/share/zoneinfo/$tz" /etc/localtime + else + cp --remove-destination "/usr/share/zoneinfo/$tz" /etc/localtime + fi } # Filesystem functions -- cgit v1.2.3 From 6358d9e6b1abd4514f7d342334d3a3e0d8b276a0 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Mon, 26 Sep 2011 12:16:39 +0200 Subject: rc.conf: disable hwclock and netfs by default These are only useful to a minority of users. Signed-off-by: Tom Gundersen --- rc.conf | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/rc.conf b/rc.conf index 9700480..303a035 100644 --- a/rc.conf +++ b/rc.conf @@ -113,7 +113,10 @@ NETWORK_PERSIST="no" # - prefix a daemon with a ! to disable it # - prefix a daemon with a @ to start it up in the background # -# If something other takes care of your hardware clock (ntpd, dual-boot...) -# you should disable 'hwclock' here. +# If you are sure nothing else touches your hardware clock (such as ntpd or +# a dual-boot), you might want to enable 'hwclock'. Note that this will only +# make a difference if the hwclock program has been calibrated correctly. # -DAEMONS=(hwclock syslog-ng network netfs crond) +# If you use a network filesystem you should enable 'netfs'. +# +DAEMONS=(syslog-ng network crond) -- cgit v1.2.3 From 4f4681a94923e69b9e078db6f2cae585ecbbb612 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Mon, 26 Sep 2011 16:01:45 +0200 Subject: hooks: move shutdown_poweroff before remounting / ro This will make sure the same hook is run regardless of whether you pivot to the shutdown ramfs or not. This is in order to run apcupsd --killpower as pointed out by Gerardo. Signed-off-by: Tom Gundersen --- rc.shutdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rc.shutdown b/rc.shutdown index ea86f8f..38b22b0 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -75,6 +75,8 @@ fi [[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) && -d /sys/block ]] && status "Deactivating LVM2 groups" vgchange --sysinit -a n &>/dev/null +run_hook shutdown_poweroff + if [[ -x /run/initramfs/shutdown ]]; then # decide what we want to do @@ -113,8 +115,6 @@ else status "Remounting Root Filesystem Read-only" \ mount -n -o remount,ro / - run_hook shutdown_poweroff - # Power off or reboot printsep if [[ $RUNLEVEL = 0 ]]; then -- cgit v1.2.3 From 137a7347ff975e4988d7fd999a0a6c32fee0464b Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Mon, 17 Oct 2011 20:55:38 +0200 Subject: locale.sh: support /etc/locale.conf This is mainly to support non-bash shells that cannot source rc.conf. The format of /etc/locale.conf is described here: . If LANG is not set in locale.conf, then we fall back to LOCALE from rc.conf, as before. Signed-off-by: Tom Gundersen --- functions | 8 ++++++-- locale.sh | 11 +++++++++-- rc.conf | 1 + 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/functions b/functions index 2ea81f9..68f4229 100644 --- a/functions +++ b/functions @@ -67,8 +67,12 @@ unset TZ unset LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \ LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE \ LC_MEASUREMENT LC_IDENTIFICATION LC_ALL -if [[ $DAEMON_LOCALE = [yY][eE][sS] && $LOCALE ]]; then - export LANG="${LOCALE}" +if [[ $DAEMON_LOCALE = [yY][eE][sS] ]]; then + if [ -r /etc/locale.conf ]; then + . /etc/locale.conf + else + export LANG="${LOCALE}" + fi else export LANG=C fi diff --git a/locale.sh b/locale.sh index 6723f95..e774659 100644 --- a/locale.sh +++ b/locale.sh @@ -1,3 +1,10 @@ -. /etc/rc.conf +if [ -s /etc/rc.conf ]; then + LANG=$(. /etc/rc.conf 2> /dev/null ; echo "${LOCALE:=en_US.UTF-8}") +fi +if [ -s /etc/locale.conf ]; then + . /etc/locale.conf +fi -export LANG=${LOCALE:=en_US.UTF-8} +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 diff --git a/rc.conf b/rc.conf index 303a035..d91dff7 100644 --- a/rc.conf +++ b/rc.conf @@ -7,6 +7,7 @@ # ----------------------------------------------------------------------- # # LOCALE: available languages can be listed with the 'locale -a' command +# LANG in /etc/locale.conf takes precedence # DAEMON_LOCALE: If set to 'yes', use $LOCALE as the locale during daemon # startup and during the boot process. If set to 'no', the C locale is used. # HARDWARECLOCK: set to "", "UTC" or "localtime", any other value will result -- cgit v1.2.3 From 0c29f8612420d94006b6d7b274762764faf7dd0b Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Sat, 1 Oct 2011 10:59:30 +0200 Subject: Add rc.d manual page Thanks to Elvis Stansvik for its template. Fix bug: FS#25269 Signed-off-by: Sebastien Luttringer --- Makefile | 15 +++++++-- PKGBUILD | 1 + rc.d.8.txt | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 rc.d.8.txt diff --git a/Makefile b/Makefile index a6262e2..c7eaa5f 100644 --- a/Makefile +++ b/Makefile @@ -12,14 +12,17 @@ DIRS := \ /usr/lib/sysctl.d \ /usr/lib/initscripts \ /etc/bash_completion.d \ - /usr/share/zsh/site-functions + /usr/share/zsh/site-functions \ + /usr/share/man/man8 + +all: minilogd doc minilogd: minilogd.o installdirs: install -dm755 $(foreach DIR, $(DIRS), $(DESTDIR)$(DIR)) -install: minilogd installdirs +install: minilogd 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 @@ -27,13 +30,19 @@ install: minilogd installdirs 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 -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 install -m644 -T bash-completion $(DESTDIR)/etc/bash_completion.d/rc.d install -m644 -T zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_rc.d +rc.d.8: rc.d.8.txt + a2x -d manpage -f manpage rc.d.8.txt + +doc: rc.d.8 + clean: - rm -f minilogd minilogd.o + rm -f minilogd minilogd.o rc.d.8 release: git archive HEAD --prefix=initscripts-$(VER)/ | xz > initscripts-$(VER).tar.xz diff --git a/PKGBUILD b/PKGBUILD index d8b4717..8b4472d 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -9,6 +9,7 @@ groups=('base') 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>=139-1' 'iproute2' 'ncurses' 'kbd' 'findutils' 'sysvinit') optdepends=('net-tools: legacy networking support' diff --git a/rc.d.8.txt b/rc.d.8.txt new file mode 100644 index 0000000..d0bbcce --- /dev/null +++ b/rc.d.8.txt @@ -0,0 +1,103 @@ +///// +vim:set ts=4 sw=4 syntax=asciidoc noet: +///// +rc.d(8) +======= + +Name +---- +rc.d - Initscripts power tool + +Synopsis +-------- +*rc.d [options] [rc [rc] ...]* + +Description +----------- +The *rc.d* program controls and lists rc scripts on the system. An action may be +invoked on one or more scripts using *rc.d action rc1 rc2...*. See <> +below for more information. +Use *rc.d list* to get the list of all rc scripts on the system. + +Actions[[A]] +------------ +The actions supported by a rc scripts may be different from script to script, but +commonly supported actions include: + +*start*:: + Starts the script if it's not already running. + +*stop*:: + Stops a running script. + +*restart*:: + Restarts a running script. + +More uncommon actions are: + +*reload*:: + Signals the script to reload its configuration. + +*status*:: + Shows the status of the script. + +Options[[O]] +------------ +*-s, --started*:: + Filter to started scripts. + +*-S, --stopped*:: + Filter to stopped scripts. + +*-a, --auto*:: + Filter to auto started scripts. + +*-A, --noauto*:: + Filter to manually started scripts. + +Examples[[E]] +------------- +*rc.d list*:: + List all scripts. + +*rc.d list sshd gpm*:: + List only *sshd* and *gpm* scripts. + +*rc.d list --started gpm*:: + List *gpm* script only if started. + +*rc.d list --started --auto*:: + List all auto started scripts. + +*rc.d start sshd gpm*:: + Starts *sshd* and *gpm* scripts. + +*rc.d start --auto --stopped*:: + Starts all stopped scripts which are started at startup. + +*rc.d stop crond*:: + Stops the *crond* script. + +*rc.d stop --noauto*:: + Stop all script which are not runned at startup + +*rc.d restart crond*:: + Restarts the *crond* script. + +*rc.d restart --stopped crond*:: + Restarts the *crond* script only if stopped. + +*rc.d help*:: + Display help. + +Directories[[D]] +---------------- +'/etc/rc.d':: + Directory containing available daemons on the system. + +'/usr/lib/initscripts':: + Directory containing available initscripts plugins. + +Authors +------- + Written by Sebastien Luttringer and Dave Reisner. -- cgit v1.2.3 From 38ecbbdad78ad58a9c6a6eaaca3af89d81299d6d Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Tue, 18 Oct 2011 09:55:51 +0200 Subject: PKGBUILD: update We now require udev 173, and the manpages use asciidoc. --- PKGBUILD | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PKGBUILD b/PKGBUILD index 8b4472d..18b53b7 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -10,12 +10,13 @@ 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>=139-1' 'iproute2' +depends=('glibc' 'bash' 'grep' 'coreutils' 'udev>=173' 'iproute2' 'ncurses' 'kbd' 'findutils' 'sysvinit') optdepends=('net-tools: legacy networking support' 'bridge-utils: Network bridging support' 'dhcpcd: DHCP network configuration' 'wireless_tools: Wireless networking') +makedepends=(asciidoc) source=() sha256sums=() -- cgit v1.2.3 From 4e45e539e811a1be7be024323c74ec3cccddc007 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Tue, 18 Oct 2011 10:15:24 +0200 Subject: DAEMON_LOCALE: support in the same way as locale.sh We don't have the problem with non-bash shells here, but better make the support uniform. --- functions | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions b/functions index 68f4229..938e5f9 100644 --- a/functions +++ b/functions @@ -68,11 +68,13 @@ unset LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \ LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE \ LC_MEASUREMENT LC_IDENTIFICATION LC_ALL if [[ $DAEMON_LOCALE = [yY][eE][sS] ]]; then + LANG="${LOCALE:=C}" if [ -r /etc/locale.conf ]; then . /etc/locale.conf - else - export LANG="${LOCALE}" fi + export LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \ + LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE \ + LC_MEASUREMENT LC_IDENTIFICATION LC_ALL else export LANG=C fi -- cgit v1.2.3 From 750db158fca0681273b65b354716469168e341c1 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Tue, 18 Oct 2011 18:01:33 +0200 Subject: mtab: delete any stale locks This should fix (to the extent possible) #FS26337. Figured-out-by: Dave Reisner Signed-off-by: Tom Gundersen --- rc.sysinit | 1 + 1 file changed, 1 insertion(+) diff --git a/rc.sysinit b/rc.sysinit index d6e7bbd..dffea4d 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -200,6 +200,7 @@ status "Remounting Root Read/Write" \ # don't touch /etc/mtab if it is a symlink to /proc/self/mounts if [[ ! -L /etc/mtab ]]; then stat_busy "Creating mtab" + rm -f /etc/mtab~* # delete any stale locks if [[ -x $(type -P findmnt) && -e /proc/self/mountinfo ]]; then findmnt -rnu -o SOURCE,TARGET,FSTYPE,OPTIONS >| /etc/mtab else -- cgit v1.2.3 From 559175f82d6320af8855c34b7e4b9b3cb4a3ad9a Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Wed, 19 Oct 2011 10:20:41 +0200 Subject: config: add /etc/vconsole.conf support 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 --- rc.sysinit | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rc.sysinit b/rc.sysinit index dffea4d..415b482 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -237,6 +237,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 @@ -258,6 +262,12 @@ else echo 0 >| /sys/module/vt/parameters/default_utf8 stat_done fi + +if [[ -s /etc/vconsole.conf ]]; then + . /etc/vconsole.conf + [[ $FONT ]] && CONSOLEFONT=$FONT + [[ $FONT_MAP ]] && CONSOLEMAP=$FONT_MAP +fi [[ $KEYMAP ]] && status "Loading Keyboard Map: $KEYMAP" loadkeys -q $KEYMAP -- cgit v1.2.3 From 697aa90c7eede255635f9c6d2e7fe12338aa2886 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sat, 22 Oct 2011 14:21:48 +0200 Subject: bits, bytes, who cares? Signed-off-by: Tom Gundersen --- rc.shutdown | 1 + 1 file changed, 1 insertion(+) 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 -- cgit v1.2.3 From e46ee7e6c9fbbd8d21c306719170ae086cf12761 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sun, 23 Oct 2011 18:02:20 +0200 Subject: udev: exit on shutdown 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 --- rc.shutdown | 2 ++ 1 file changed, 2 insertions(+) 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 -- cgit v1.2.3 From 1fdaa33f06786231da3b86e5d8b646b46f6ca1f9 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sun, 23 Oct 2011 21:03:46 +0200 Subject: udev: binary moved, require 174 --- 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" -- cgit v1.2.3 From fbff8c64e2be9cbb24bd7f824552842d0bd6442d Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Mon, 24 Oct 2011 21:34:14 +0200 Subject: locale: fix locale.sh for zsh Uglier script, but should now work with zsh as well as bash. v2: only read rc.conf if LANG is not set in locale.conf, no functional change. Based on suggestion by Dave. Signed-off-by: Tom Gundersen --- locale.sh | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 75 insertions(+), 6 deletions(-) diff --git a/locale.sh b/locale.sh index e774659..e9d0da1 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}") -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 + if [ -s /etc/rc.conf ]; then + export LANG=$(. /etc/rc.conf 2> /dev/null ; echo "$LOCALE") + else + export LANG="C" + fi +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 -- cgit v1.2.3 From 00070eca730dec9c6d587cc1639f6abaca83fa34 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Wed, 26 Oct 2011 23:11:20 +0200 Subject: minilogd: kill 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 Signed-off-by: Dan McGee --- .gitignore | 2 - Makefile | 10 ++- PKGBUILD | 2 +- minilogd.c | 202 ------------------------------------------------------------- rc.sysinit | 3 +- 5 files changed, 6 insertions(+), 213 deletions(-) delete mode 100644 minilogd.c diff --git a/.gitignore b/.gitignore index d07d3f9..5200eb7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -minilogd -minilogd.o tags *.tar.xz* pkg/ 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 -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef __USE_BSD -# define __USE_BSD -#endif -#include - -#include -#include -#include -#include - -#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 (x0) && (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 415b482..1c74bd9 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 -- cgit v1.2.3