[arch-projects] [INITSCRIPTS][PATCH 1/3] Fix console verbosity and add config via rc.conf
This patch fix verbosity which use var exported by initcpio in place of kernel. Verbosity is an initscripts parameter, so it should have a definition in rc.conf. Kernel parameter should be a shortcut. New option is called VERBOSE. Signed-off-by: Sebastien Luttringer <seblu@seblu.net> --- rc.conf | 2 ++ rc.sysinit | 13 ++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/rc.conf b/rc.conf index 02bb1d7..e4751ca 100644 --- a/rc.conf +++ b/rc.conf @@ -17,6 +17,7 @@ # CONSOLEFONT: found in /usr/share/kbd/consolefonts (only needed for non-US) # CONSOLEMAP: found in /usr/share/kbd/consoletrans # USECOLOR: use ANSI color sequences in startup messages +# VERBOSE: Verbose level (from 1 to 8). man 3 syslog for level info # LOCALE="en_US.UTF-8" DAEMON_LOCALE="no" @@ -26,6 +27,7 @@ KEYMAP="us" CONSOLEFONT= CONSOLEMAP= USECOLOR="yes" +VERBOSE="3" # ----------------------------------------------------------------------- # HARDWARE diff --git a/rc.sysinit b/rc.sysinit index 9d7c250..93c66cf 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -31,13 +31,12 @@ fi # start up our mini logger until syslog takes over /sbin/minilogd -# anything more serious than KERN_WARNING goes to the console -# 'verbose' cmdline parameter enables more messages -if [[ -n "$verbose" ]]; then - /bin/dmesg -n 8 -else - /bin/dmesg -n 3 -fi +# Set console verbosity +for cmdarg in $(< /proc/cmdline); do + [[ "$cmdarg" == verbose ]] && VERBOSE=8 && break + [[ "$cmdarg" =~ verbose=[1-8] ]] && VERBOSE=${BASH_REMATCH[0]-8} && break +done +/bin/dmesg -n ${VERBOSE:-3} HWCLOCK_PARAMS="--hctosys" case $HARDWARECLOCK in -- Sebastien Seblu Luttringer
A daemon is an executable _file_ in /etc/rc.d. Directory like functions.d is not a daemon. Signed-off-by: Sebastien Luttringer <seblu@seblu.net> --- functions | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/functions b/functions index 090f099..8a191e6 100644 --- a/functions +++ b/functions @@ -170,8 +170,9 @@ ck_daemon() { [[ ! -f /var/run/daemons/$1 ]] } +# Check if $1 is a valid daemon name have_daemon() { - [[ -x /etc/rc.d/$1 ]] + [[ -f /etc/rc.d/$1 && -x /etc/rc.d/$1 ]] } start_daemon() { -- Sebastien Seblu Luttringer
This is allow a quick calling to /etc/rc.d scripts by calling a shell command. By example, starting sshd and gpm can be done by typing: rc start sshd gpm rc can also list available scripts and show which is started/stopped in DAEMONS Signed-off-by: Sebastien Luttringer <seblu@seblu.net> --- functions | 9 +++++++++ install.sh | 2 ++ rc | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 0 deletions(-) create mode 100755 rc diff --git a/functions b/functions index 8a191e6..e0f3bec 100644 --- a/functions +++ b/functions @@ -175,6 +175,15 @@ have_daemon() { [[ -f /etc/rc.d/$1 && -x /etc/rc.d/$1 ]] } +# Check if $1 is started at boot +ck_autostart() { + local d + for d in "${DAEMONS[@]}"; do + [[ "$1" = $d ]] && return 1 + done + return 0 +} + start_daemon() { have_daemon "$1" && /etc/rc.d/"$1" start } diff --git a/install.sh b/install.sh index 8e6c3d7..c70a10e 100755 --- a/install.sh +++ b/install.sh @@ -21,3 +21,5 @@ done gcc $CFLAGS -o minilogd minilogd.c || exit 1 install -D -m755 minilogd ${DESTDIR}/sbin/minilogd || exit 1 + +install -D -m755 rc ${DESTDIR}/sbin/rc || exit 1 diff --git a/rc b/rc new file mode 100755 index 0000000..4bb9730 --- /dev/null +++ b/rc @@ -0,0 +1,51 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions + +usage() { + cat >&2 << EOF +usage: rc action daemon ... + +e.g: rc list + rc help + rc start sshd gpm +EOF +} + +(( $# < 1 )) && usage && exit 1 + +case $1 in + help) + usage + ;; + list) + cd /etc/rc.d/ + for d in *; do + have_daemon "$d" || continue + # print running / stopped satus + if ! ck_daemon "$d"; then + printf "${C_OTHER}[${C_DONE}STARTED${C_OTHER}]" + else + printf "${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}]" + else + printf "${C_OTHER}[${C_FAIL} ${C_OTHER}]" + fi + printf " ${C_MAIN}$d${C_CLEAR}\n" + done + ;; + *) + action=$1 + shift + for i; do + [[ -x "/etc/rc.d/$i" ]] && "/etc/rc.d/$i" $action + done +esac + +true + +# vim: set ts=2 sw=2 noet: -- Sebastien Seblu Luttringer
I'm about to push this patch, but there is a bug. "rc list" will not show "AUTO" on daemons that are started in the background. I fixed it here: <https://github.com/teg/initscripts-arch/commit/2800e50847f3217b60eb07138c7f6fda05467616>, could you check that it is correct? -t On Sat, Apr 2, 2011 at 11:52 PM, Sebastien Luttringer <seblu@seblu.net> wrote:
This is allow a quick calling to /etc/rc.d scripts by calling a shell command. By example, starting sshd and gpm can be done by typing: rc start sshd gpm rc can also list available scripts and show which is started/stopped in DAEMONS
Signed-off-by: Sebastien Luttringer <seblu@seblu.net> --- functions | 9 +++++++++ install.sh | 2 ++ rc | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 0 deletions(-) create mode 100755 rc
diff --git a/functions b/functions index 8a191e6..e0f3bec 100644 --- a/functions +++ b/functions @@ -175,6 +175,15 @@ have_daemon() { [[ -f /etc/rc.d/$1 && -x /etc/rc.d/$1 ]] }
+# Check if $1 is started at boot +ck_autostart() { + local d + for d in "${DAEMONS[@]}"; do + [[ "$1" = $d ]] && return 1 + done + return 0 +} + start_daemon() { have_daemon "$1" && /etc/rc.d/"$1" start } diff --git a/install.sh b/install.sh index 8e6c3d7..c70a10e 100755 --- a/install.sh +++ b/install.sh @@ -21,3 +21,5 @@ done
gcc $CFLAGS -o minilogd minilogd.c || exit 1 install -D -m755 minilogd ${DESTDIR}/sbin/minilogd || exit 1 + +install -D -m755 rc ${DESTDIR}/sbin/rc || exit 1 diff --git a/rc b/rc new file mode 100755 index 0000000..4bb9730 --- /dev/null +++ b/rc @@ -0,0 +1,51 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions + +usage() { + cat >&2 << EOF +usage: rc action daemon ... + +e.g: rc list + rc help + rc start sshd gpm +EOF +} + +(( $# < 1 )) && usage && exit 1 + +case $1 in + help) + usage + ;; + list) + cd /etc/rc.d/ + for d in *; do + have_daemon "$d" || continue + # print running / stopped satus + if ! ck_daemon "$d"; then + printf "${C_OTHER}[${C_DONE}STARTED${C_OTHER}]" + else + printf "${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}]" + else + printf "${C_OTHER}[${C_FAIL} ${C_OTHER}]" + fi + printf " ${C_MAIN}$d${C_CLEAR}\n" + done + ;; + *) + action=$1 + shift + for i; do + [[ -x "/etc/rc.d/$i" ]] && "/etc/rc.d/$i" $action + done +esac + +true + +# vim: set ts=2 sw=2 noet: -- Sebastien Seblu Luttringer
I'm about to push this patch, but there is a bug. "rc list" will not show "AUTO" on daemons that are started in the background. I fixed it here: <https://github.com/teg/initscripts-arch/commit/2800e50847f3217b60eb07138c7f6fda05467616>, could you check that it is correct? Thanks for the correction. I was not "plugged" last few days. Your
On Sat, Apr 16, 2011 at 3:41 AM, Tom Gundersen <teg@jklm.no> wrote: patch looks fine but i've not tested it.
-t
On Sat, Apr 2, 2011 at 11:52 PM, Sebastien Luttringer <seblu@seblu.net> wrote:
This is allow a quick calling to /etc/rc.d scripts by calling a shell command. By example, starting sshd and gpm can be done by typing: rc start sshd gpm rc can also list available scripts and show which is started/stopped in DAEMONS
Signed-off-by: Sebastien Luttringer <seblu@seblu.net> --- functions | 9 +++++++++ install.sh | 2 ++ rc | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 0 deletions(-) create mode 100755 rc
diff --git a/functions b/functions index 8a191e6..e0f3bec 100644 --- a/functions +++ b/functions @@ -175,6 +175,15 @@ have_daemon() { [[ -f /etc/rc.d/$1 && -x /etc/rc.d/$1 ]] }
+# Check if $1 is started at boot +ck_autostart() { + local d + for d in "${DAEMONS[@]}"; do + [[ "$1" = $d ]] && return 1 + done + return 0 +} + start_daemon() { have_daemon "$1" && /etc/rc.d/"$1" start } diff --git a/install.sh b/install.sh index 8e6c3d7..c70a10e 100755 --- a/install.sh +++ b/install.sh @@ -21,3 +21,5 @@ done
gcc $CFLAGS -o minilogd minilogd.c || exit 1 install -D -m755 minilogd ${DESTDIR}/sbin/minilogd || exit 1 + +install -D -m755 rc ${DESTDIR}/sbin/rc || exit 1 diff --git a/rc b/rc new file mode 100755 index 0000000..4bb9730 --- /dev/null +++ b/rc @@ -0,0 +1,51 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions + +usage() { + cat >&2 << EOF +usage: rc action daemon ... + +e.g: rc list + rc help + rc start sshd gpm +EOF +} + +(( $# < 1 )) && usage && exit 1 + +case $1 in + help) + usage + ;; + list) + cd /etc/rc.d/ + for d in *; do + have_daemon "$d" || continue + # print running / stopped satus + if ! ck_daemon "$d"; then + printf "${C_OTHER}[${C_DONE}STARTED${C_OTHER}]" + else + printf "${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}]" + else + printf "${C_OTHER}[${C_FAIL} ${C_OTHER}]" + fi + printf " ${C_MAIN}$d${C_CLEAR}\n" + done + ;; + *) + action=$1 + shift + for i; do + [[ -x "/etc/rc.d/$i" ]] && "/etc/rc.d/$i" $action + done +esac + +true + +# vim: set ts=2 sw=2 noet: -- Sebastien Seblu Luttringer
-- Sébastien Luttringer www.seblu.net
participants (3)
-
Sebastien Luttringer
-
Seblu
-
Tom Gundersen