* [gentoo-commits] eselect r578 - in trunk: . man modules
@ 2009-06-05 19:07 Ulrich Mueller (ulm)
0 siblings, 0 replies; only message in thread
From: Ulrich Mueller (ulm) @ 2009-06-05 19:07 UTC (permalink / raw
To: gentoo-commits
Author: ulm
Date: 2009-06-05 19:07:36 +0000 (Fri, 05 Jun 2009)
New Revision: 578
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/man/rc.eselect.5
trunk/modules/rc.eselect
Log:
Add "--unused" option to show status of scripts that are not assigned
to any runlevel; bug 271208. Several small changes in the rc module.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-06-04 11:03:22 UTC (rev 577)
+++ trunk/ChangeLog 2009-06-05 19:07:36 UTC (rev 578)
@@ -1,3 +1,16 @@
+2009-06-05 Ulrich Mueller <ulm@gentoo.org>
+
+ * modules/rc.eselect (is_script): Symlinks are implicitly
+ resolved, so no need to canonicalise.
+ (do_start, do_stop, do_pause, do_reload, do_restart)
+ (run_runscript): Move output message to calling functions.
+ (do_list): Output colours also if only one runlevel is shown.
+ (find_unused_scripts, show_script_status): New functions.
+ (do_show): Add "--unused" option to show status of scripts that
+ are not assigned to any runlevel; bug 271208.
+ (describe_show_options): Document new option.
+ * man/rc.eselect.5: Document new option for "show" action.
+
2009-06-04 Ulrich Mueller <ulm@gentoo.org>
* modules/package-manager.eselect: New module, managing the
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2009-06-04 11:03:22 UTC (rev 577)
+++ trunk/NEWS 2009-06-05 19:07:36 UTC (rev 578)
@@ -5,6 +5,8 @@
New features:
- Add a test if the selected package manager is valid.
- Extended syntax in editor-variable library.
+ - The rc module can show the status of scripts that are not assigned to any
+ runlevel (bug #271208).
1.1:
Bug fixes:
Modified: trunk/man/rc.eselect.5
===================================================================
--- trunk/man/rc.eselect.5 2009-06-04 11:03:22 UTC (rev 577)
+++ trunk/man/rc.eselect.5 2009-06-05 19:07:36 UTC (rev 578)
@@ -2,7 +2,7 @@
.\" Distributed under the terms of the GNU General Public License v2
.\" $Id$
.\"
-.TH rc.eselect 5 "May 2009" "Gentoo Linux" eselect
+.TH rc.eselect 5 "June 2009" "Gentoo Linux" eselect
.SH NAME
rc.eselect \- Runlevel configuration module
.SH SYNOPSIS
@@ -185,9 +185,12 @@
and list them together with their status. If no
.I runlevel
is given, list the scripts from the current runlevel.
-With option
+With options
.B --all
-the scripts of all runlevels are shown.
+or
+.B --unused
+the scripts of all runlevels or the scripts not assigned to any
+runlevel are shown, respectively.
# eselect rc show
.br
Modified: trunk/modules/rc.eselect
===================================================================
--- trunk/modules/rc.eselect 2009-06-04 11:03:22 UTC (rev 577)
+++ trunk/modules/rc.eselect 2009-06-05 19:07:36 UTC (rev 578)
@@ -37,11 +37,10 @@
# list_runlevels PRIVATE
# list runlevels for file $1
list_runlevels() {
- [[ ${#@} -eq 1 ]] || return
+ [[ $# -eq 1 ]] || return
local x runlevels
for x in ${ROOT}/etc/runlevels/* ; do
- [[ -d ${x} ]] || continue
- [[ -L ${ROOT}/etc/runlevels/${x##*/}/${1} ]] \
+ [[ -d ${x} && -L ${x}/${1} ]] \
&& runlevels=(${runlevels[@]} "${x##*/}")
done
echo -ne "${runlevels[@]}"
@@ -51,38 +50,65 @@
# check if file $1 is a valid init script
is_script() {
local file=${1}
- [[ -n ${file} ]] \
- || return 1
- ( [[ -L ${file} ]] \
- && [[ ! -e $(canonicalise -f ${file}) ]] ) \
- && return 1
- [[ -e ${file} ]] \
- && [[ ${file%%.sh} == ${file} ]] \
- && [[ ${file%%\~} == ${file} ]] \
- && [[ -n `grep "^#\!/sbin/runscript" ${file}` ]]
+ [[ -n ${file} \
+ && ${file%%.sh} = ${file} \
+ && ${file%%\~} = ${file} \
+ && -e ${file} ]] \
+ && grep "^#\!/sbin/runscript" "${file}" &>/dev/null
}
# find_scripts PRIVATE
# browse directory $1 for init scripts and return a list
find_scripts() {
- local ret
for file in ${1}/* ; do
- is_script ${file} \
- && ret=(${ret[@]} "${file##*/}")
+ is_script ${file} && echo "${file##*/}"
done
- echo -ne ${ret[@]}
}
+# find_unused_scripts PRIVATE
+# find scripts in /etc/init.d not belonging to any runlevel
+find_unused_scripts() {
+ local file x
+ for file in $(find_scripts "${ROOT}/etc/init.d"); do
+ for x in "${ROOT}"/etc/runlevels/*; do
+ [[ -d ${x} && -L ${x}/${file} ]] && continue 2
+ done
+ echo "${file##*/}"
+ done
+}
+
+# show_script_status PRIVATE
+# output list entry for script $1 and show its status
+show_script_status() {
+ local script=${1} status=unknown x
+
+ for x in stopping starting inactive started stopped; do
+ if service_${x} ${script}; then
+ status=${x}
+ break
+ fi
+ done
+ case ${status} in
+ stopped)
+ write_kv_list_entry ${script} [${x}]
+ ;;
+ started)
+ write_kv_list_entry ${script} "$(highlight [${x}])"
+ ;;
+ *)
+ write_kv_list_entry ${script} "$(highlight_warning [${x}])"
+ ;;
+ esac
+}
+
# run_runscript PRIVATE
# run RC_RUNSCRIPT with script $2- and command $1
run_runscript() {
local command=${1}
shift
- write_list_start "${1}"
- shift
- for script in ${@} ; do
- is_script ${ROOT}/etc/init.d/${script} \
- && /sbin/runscript ${ROOT}/etc/init.d/${script} ${command}
+ for script in "$@"; do
+ is_script "${ROOT}/etc/init.d/${script}" \
+ && /sbin/runscript "${ROOT}/etc/init.d/${script}" "${command}"
done
}
@@ -102,7 +128,7 @@
}
do_add() {
- [[ ${#@} -gt 0 ]] \
+ [[ $# -gt 0 ]] \
|| die -q "Please specify the init script to be added!"
local script=${1##*/}
[[ -e ${ROOT}/etc/init.d/${script} ]] \
@@ -144,7 +170,7 @@
}
do_delete() {
- [[ ${#@} -gt 0 ]] \
+ [[ $# -gt 0 ]] \
|| die -q "Please specify the init script to be deleted!"
local script=${1##*/}
shift 1
@@ -194,12 +220,9 @@
die -q "${1} is no valid runlevel!"
fi
- for file in $(find_scripts ${dir}) ; do
- [[ ${dir##*/} = init.d ]] \
- && write_kv_list_entry ${file} "$(list_runlevels ${file})" \
- || echo " ${file}"
-# && echo " ${file} $(space $((20 - ${#file}))) | $(list_runlevels ${file})" \
-# || echo " ${file}"
+ for file in $(find_scripts "${dir}") ; do
+ write_kv_list_entry "${file}" \
+ $([[ ${dir##*/} = init.d ]] && list_runlevels "${file}")
done
}
@@ -216,10 +239,11 @@
describe_show_options() {
echo "runlevels : Runlevels to list (defaults to current runlevel)"
echo "--all : List all runlevels"
+ echo "--unused : Show scripts not assigned to any runlevel"
}
do_show() {
- local runlevel status n x
+ local runlevel all unused n x
# core.bash redefines eval; unset it because OpenRC's
# functions.sh needs the bash builtin
@@ -228,43 +252,46 @@
if [[ $# -eq 0 ]]; then
set -- "$(get_runlevel)"
- elif [[ ${1##--} = all ]]; then
- for x in "${ROOT}"/etc/runlevels/*; do
- [[ -d "${x}" ]] && runlevels=("${runlevels[@]}" "${x##*/}")
+ else
+ while [[ $# -gt 0 ]]; do
+ case ${1##--} in
+ all) all=1 ;;
+ unused) unused=1 ;;
+ *) break ;;
+ esac
+ shift
done
- set -- "${runlevels[@]}"
+ if [[ -n ${all} ]]; then
+ local runlevels=()
+ for x in "${ROOT}"/etc/runlevels/*; do
+ [[ -d "${x}" ]] && runlevels=("${runlevels[@]}" "${x##*/}")
+ done
+ set -- "${runlevels[@]}"
+ fi
fi
for runlevel in "$@"; do
[[ -n ${runlevel} && -d ${ROOT}/etc/runlevels/${runlevel} ]] \
|| die -q "\"${runlevel}\" is no valid runlevel"
- write_list_start \
- "Status of init scripts in runlevel \"${runlevel}\""
+ write_list_start "Status of init scripts in runlevel \"${runlevel}\""
n=0
for script in $(find_scripts "${ROOT}/etc/runlevels/${runlevel}"); do
- status=unknown
- for x in stopping starting inactive started stopped; do
- if service_${x} ${script}; then
- status=${x}
- break
- fi
- done
- case ${status} in
- stopped)
- write_kv_list_entry ${script} [${x}]
- ;;
- started)
- write_kv_list_entry ${script} "$(highlight [${x}])"
- ;;
- *)
- write_kv_list_entry ${script} "$(highlight_warning [${x}])"
- ;;
- esac
+ show_script_status ${script}
((n++))
done
[[ ${n} -eq 0 ]] && write_kv_list_entry "(none found)" ""
done
+
+ if [[ -n ${unused} ]]; then
+ write_list_start "Status of init scripts not assigned to any runlevel"
+ n=0
+ for script in $(find_unused_scripts); do
+ show_script_status ${script}
+ ((n++))
+ done
+ [[ ${n} -eq 0 ]] && write_kv_list_entry "(none found)" ""
+ fi
}
### start action
@@ -282,9 +309,10 @@
}
do_start() {
- [[ ${#@} -gt 0 ]] \
+ [[ $# -gt 0 ]] \
|| die -q "Please specify the init script to be started!"
- run_runscript start "Starting init script$([[ ${#@} -gt 1 ]] && echo -ne 's')" ${@}
+ write_list_start "Starting init script$([[ $# -gt 1 ]] && echo -n 's')"
+ run_runscript start "$@"
}
### stop action
@@ -302,9 +330,10 @@
}
do_stop() {
- [[ ${#@} -gt 0 ]] \
+ [[ $# -gt 0 ]] \
|| die -q "Please specify the init script to be stopped!"
- run_runscript stop "Stopping init script$([[ ${#@} -gt 1 ]] && echo -ne 's')" ${@}
+ write_list_start "Stopping init script$([[ $# -gt 1 ]] && echo -n 's')"
+ run_runscript stop "$@"
}
### pause action
@@ -322,9 +351,10 @@
}
do_pause() {
- [[ ${#@} -gt 0 ]] \
+ [[ $# -gt 0 ]] \
|| die -q "Please specify the init script to be paused!"
- run_runscript pause "Pausing init script$([[ ${#@} -gt 1 ]] && echo -ne 's')" ${@}
+ write_list_start "Pausing init script$([[ $# -gt 1 ]] && echo -n 's')"
+ run_runscript pause "$@"
}
### reload action
@@ -342,9 +372,10 @@
}
do_reload() {
- [[ ${#@} -gt 0 ]] \
+ [[ $# -gt 0 ]] \
|| die -q "Please specify the init script to be reloaded!"
- run_runscript reload "Reloading init script$([[ ${#@} -gt 1 ]] && echo -ne 's')" ${@}
+ write_list_start "Reloading init script$([[ $# -gt 1 ]] && echo -n 's')"
+ run_runscript reload "$@"
}
### restart action
@@ -362,9 +393,10 @@
}
do_restart() {
- [[ ${#@} -gt 0 ]] \
+ [[ $# -gt 0 ]] \
|| die -q "Please specify the init script to be restarted!"
- run_runscript restart "Restarting init script$([[ ${#@} -gt 1 ]] && echo -ne 's')" ${@}
+ write_list_start "Restarting init script$([[ $# -gt 1 ]] && echo -n 's')"
+ run_runscript restart "$@"
}
# vim: set ft=eselect :
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-06-05 19:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-05 19:07 [gentoo-commits] eselect r578 - in trunk: . man modules Ulrich Mueller (ulm)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox