summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorChristian Heim <phreak@gentoo.org>2005-10-07 13:24:55 +0000
committerChristian Heim <phreak@gentoo.org>2005-10-07 13:24:55 +0000
commitd92f250b81bfa5d6bf76c620ca4bcd4d05fcedd3 (patch)
tree7f1117b3f38f3ef27d0635076ce68b5220e9ebcc /sbin
parentFixing ChangeLog.vserver (diff)
downloadbaselayout-vserver-d92f250b81bfa5d6bf76c620ca4bcd4d05fcedd3.tar.gz
baselayout-vserver-d92f250b81bfa5d6bf76c620ca4bcd4d05fcedd3.tar.bz2
baselayout-vserver-d92f250b81bfa5d6bf76c620ca4bcd4d05fcedd3.zip
Refreshing baselayout-vserver with revision 1560 from baselayout.
svn path=/baselayout-vserver/trunk/; revision=51
Diffstat (limited to 'sbin')
-rwxr-xr-xsbin/rc-update49
1 files changed, 27 insertions, 22 deletions
diff --git a/sbin/rc-update b/sbin/rc-update
index 62b2d06..90c0b7a 100755
--- a/sbin/rc-update
+++ b/sbin/rc-update
@@ -1,12 +1,8 @@
#!/bin/bash
-# Copyright 1999-2004 Gentoo Foundation
+# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
source /sbin/functions.sh
-if [[ ${EUID} -ne 0 ]] ; then
- eerror "$0: must be root."
- exit 1
-fi
usage() {
cat << FOO
@@ -40,35 +36,34 @@ add() {
local myscript=
if [[ $# -lt 3 ]] ; then
- eerror "${0}: at least two arguments expected after \"$1\"."
+ eerror "$0: at least two arguments expected after \"$1\"."
exit 1
fi
shift
myscript="$1"
- if [[ ! -e /etc/init.d/${myscript} ]] ; then
- eerror "$0: /etc/init.d/${myscript} not found; aborting."
+ if [[ ! -e ${ROOT}/etc/init.d/${myscript} ]] ; then
+ eerror "$0: '${ROOT}/etc/init.d/${myscript}' not found; aborting."
exit 1
fi
shift
for x in $* ; do
- if [[ ! -e /etc/runlevels/${x} ]] ; then
+ if [[ ! -e ${ROOT}/etc/runlevels/${x} ]] ; then
ewarn "runlevel ${x} not found; skipping"
continue
fi
- if [[ -L /etc/runlevels/${x}/${myscript} ]] ; then
+ if [[ -L ${ROOT}/etc/runlevels/${x}/${myscript} ]] ; then
ewarn "${myscript} already installed in runlevel ${x}; skipping"
continue
fi
- if [[ ! -x /etc/init.d/${myscript} ]] ; then
+ if [[ ! -x ${ROOT}/etc/init.d/${myscript} ]] ; then
ewarn "${myscript} not executable; skipping"
continue
fi
- ln -snf "/etc/init.d/${myscript}" "/etc/runlevels/${x}/${myscript}"
+ ln -snf "/etc/init.d/${myscript}" "${ROOT}/etc/runlevels/${x}/${myscript}"
if [[ $? -ne 0 ]] ; then
eerror "$0: failed to add ${myscript} to ${x}."
exit 1
fi
- regen=1
einfo "${myscript} added to runlevel ${x}"
done
}
@@ -87,15 +82,14 @@ del() {
myscript=$1
shift
if [[ $# -eq 0 ]] ; then
- mylevels=$(cd /etc/runlevels/; ls)
+ mylevels=$(cd "${ROOT}"/etc/runlevels/; ls)
else
mylevels="$*"
fi
remlevels=""
for x in ${mylevels} ; do
- if [[ -L /etc/runlevels/${x}/${myscript} ]] ; then
- regen=1
- rm -f "/etc/runlevels/${x}/${myscript}"
+ if [[ -L ${ROOT}/etc/runlevels/${x}/${myscript} ]] ; then
+ rm -f "${ROOT}/etc/runlevels/${x}/${myscript}"
remlevels="${remlevels} ${x}"
fi
done
@@ -114,17 +108,17 @@ show() {
shift
if [[ $# -eq 0 ]] ; then
- mylevels=$(cd /etc/runlevels/; ls)
+ mylevels=$(cd "${ROOT}"/etc/runlevels/; ls)
else
mylevels="$*"
fi
- myscripts=$(cd /etc/init.d; ls)
+ myscripts=$(cd "${ROOT}"/etc/init.d; ls)
for x in ${myscripts} ; do
if [[ ${x%%.sh} = "${x}" ]] ; then
printf "%20s | " ${x:0:19}
for y in ${mylevels} ; do
- if [[ -L /etc/runlevels/${y}/${x} ]] ; then
+ if [[ -L ${ROOT}/etc/runlevels/${y}/${x} ]] ; then
echo -n "${y} "
else
printf "%${#y}s " " "
@@ -135,18 +129,30 @@ show() {
done
}
+check_is_root() {
+ if [[ ${EUID} -ne 0 ]] ; then
+ eerror "$0: must be root."
+ exit 1
+ fi
+}
+
if [[ $# -lt 1 ]] ; then
usage
exit 1
fi
-regen=0
+if [[ -n ${ROOT} ]] ; then
+ [[ ${ROOT:0-1} == "/" ]] && export ROOT=${ROOT:0:${#ROOT}-1}
+ einfo "Working with files in root ${ROOT} ..."
+fi
case "$1" in
add|-a)
+ check_is_root
add "$@"
;;
del|delete|-d)
+ check_is_root
del "$@"
;;
show|-s)
@@ -158,5 +164,4 @@ case "$1" in
;;
esac
-
# vim:ts=4