On Tue, Mar 29, 2011 at 03:15:32AM +0200, Seblu wrote:
Hello,
You can see 2 patches.
First add a new rc helper which allow to do thing list this # rc start sshd dbus gpm # rc stop syslog-ng # rc list This is a similar behaviour to debian invoke-rc.d.
Second fix bug: https://bugs.archlinux.org/task/23373
Regards,
-- Sébastien Luttringer www.seblu.net
From 1a88a9d40727b2565d155060fef261e9d30781b3 Mon Sep 17 00:00:00 2001 From: Seblu <seblu@seblu.net> Date: Tue, 29 Mar 2011 02:35:04 +0200 Subject: [PATCH 1/2] Add an rc helper
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 in DAEMONS
Signed-off-by: Seblu <seblu@seblu.net> --- install.sh | 2 ++ rc | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 0 deletions(-) create mode 100755 rc
diff --git a/install.sh b/install.sh index 2b2cbbc..116daed 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
/sbin is typically reserved for programs which an unpriveleged user gets no use out of. Since we've got a "list" function, this is probably better suited for /bin (could make a case for /usr/bin as well).
diff --git a/rc b/rc new file mode 100755 index 0000000..63669b8 --- /dev/null +++ b/rc @@ -0,0 +1,43 @@ +#!/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 rcs in *; do + [[ -x $rcs && ! -d $rcs ]] || continue + echo -n "$rcs" + for rcu in "${DAEMONS[@]}"; do + [[ "$rcu" = $rcs ]] && echo -n " (DAEMONS)" && break + done + echo + done + ;;
Couldn't we get more mileage out of this? Why not list all the daemons, with an indication of their status (based on /var/run/daemons) and whether or not they're enabled in /etc/rc.conf. For example... [STOPPED] *dbus <- stopped, enabled [STOPPED] kexec <- stopped, not enabled [RUNNING] *mpd <- running, enabled [RUNNING] cups <- running, not enabled Bonus points: colorize if USECOLOR, sort by status (stopped first, then running) and by name within each status. Shouldn't be too hard -- something similar to this appeared on the forums a while back.
+ *) + action=$1 + shift + for i in $*; do
$* is superfluous, and mildly sloppy. "for i" is sufficient to iterate over positional parameters.
+ [[ -x "/etc/rc.d/$i" ]] && "/etc/rc.d/$i" $action + done +esac + +true
Why not keep a counter of errors and exit with a meaningful value?
+ +# vim: set ts=2 sw=2 noet: -- 1.7.4.1
From 40a7b8cad1b7197aa97f5a391b6a071faef032c5 Mon Sep 17 00:00:00 2001 From: Seblu <seblu@seblu.net> Date: Tue, 29 Mar 2011 03:41:14 +0200 Subject: [PATCH 2/2] Allow loading of multiple keymaps when LOCALE is UTF-8
Close FS#23373.
Signed-off-by: Seblu <seblu@seblu.net> --- rc.sysinit | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/rc.sysinit b/rc.sysinit index 9797611..19a71b4 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -380,7 +380,7 @@ if [[ ${LOCALE,,} =~ utf ]]; then done echo 1 > /sys/module/vt/parameters/default_utf8 stat_done - [[ $KEYMAP ]] && status "Loading Keyboard Map: $KEYMAP" /bin/loadkeys -q -u "$KEYMAP" + [[ $KEYMAP ]] && status "Loading Keyboard Map: $KEYMAP" /bin/loadkeys -q -u $KEYMAP else stat_busy "Setting Consoles to legacy mode" # make non-UTF-8 consoles work on 2.6.24 and newer kernels -- 1.7.4.1
dave