summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorChristian Heim <phreak@gentoo.org>2006-01-10 15:39:39 +0000
committerChristian Heim <phreak@gentoo.org>2006-01-10 15:39:39 +0000
commitced906bbd71781d3e5766c470a18619f27386198 (patch)
tree96ed38ca2bbde50c4cc5f43d1e7eafa80144ccb3 /sbin
parentImporting latest baselayout/trunk changes. This is a merge with revision 1768. (diff)
downloadbaselayout-vserver-ced906bbd71781d3e5766c470a18619f27386198.tar.gz
baselayout-vserver-ced906bbd71781d3e5766c470a18619f27386198.tar.bz2
baselayout-vserver-ced906bbd71781d3e5766c470a18619f27386198.zip
Importing latest baselayout/trunk changes. This merge is based upon revision 1797.
svn path=/baselayout-vserver/trunk/; revision=194
Diffstat (limited to 'sbin')
-rwxr-xr-xsbin/MAKEDEV3
-rwxr-xr-xsbin/functions.sh29
-rwxr-xr-xsbin/init-common-post.sh2
-rwxr-xr-xsbin/init-common-pre.sh2
-rwxr-xr-xsbin/init-functions.sh19
-rwxr-xr-xsbin/init.linux.sh8
-rwxr-xr-xsbin/rc7
-rwxr-xr-xsbin/rc-daemon.sh12
-rwxr-xr-xsbin/rc-help.sh4
-rwxr-xr-xsbin/rc-update2
-rwxr-xr-xsbin/runscript.sh41
11 files changed, 71 insertions, 58 deletions
diff --git a/sbin/MAKEDEV b/sbin/MAKEDEV
index a826c33..10bdaa3 100755
--- a/sbin/MAKEDEV
+++ b/sbin/MAKEDEV
@@ -561,7 +561,7 @@ do
symlink mouse sunmouse
makedev openprom c 10 139 root root 0664
;;
- generic-vserver)
+ generic-vps)
makedev null c 1 3 $public
makedev zero c 1 5 $public
makedev full c 1 7 $public
@@ -577,6 +577,7 @@ do
makedev ttyp$i c 3 $i $tty
done
;;
+
generic-*)
echo "$0: no support for generic on this arch" >&2
exit 1
diff --git a/sbin/functions.sh b/sbin/functions.sh
index dc7997f..ea09893 100755
--- a/sbin/functions.sh
+++ b/sbin/functions.sh
@@ -1,4 +1,4 @@
-# Copyright 1999-2005 Gentoo Foundation
+# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
RC_GOT_FUNCTIONS="yes"
@@ -108,7 +108,7 @@ setup_defaultlevels() {
if [[ -f "${svcdir}/softlevel" ]] ; then
export SOFTLEVEL=$(< "${svcdir}/softlevel")
else
- export SOFTLEVEL=${BOOTLEVEL}
+ export SOFTLEVEL="${BOOTLEVEL}"
fi
fi
@@ -121,7 +121,7 @@ setup_defaultlevels() {
#
get_libdir() {
if [[ -n ${CONF_LIBDIR_OVERRIDE} ]] ; then
- CONF_LIBDIR=${CONF_LIBDIR_OVERRIDE}
+ CONF_LIBDIR="${CONF_LIBDIR_OVERRIDE}"
elif [[ -x /usr/bin/portageq ]] ; then
CONF_LIBDIR=$(/usr/bin/portageq envvar CONF_LIBDIR)
fi
@@ -137,8 +137,8 @@ esyslog() {
local tag=
if [[ -x /usr/bin/logger ]] ; then
- pri=$1
- tag=$2
+ pri="$1"
+ tag="$2"
shift 2
[[ -z "$*" ]] && return 0
@@ -154,7 +154,7 @@ esyslog() {
# increase the indent used for e-commands.
#
eindent() {
- local i=$1
+ local i="$1"
(( i > 0 )) || (( i = RC_DEFAULT_INDENT ))
esetdent $(( ${#RC_INDENTATION} + i ))
}
@@ -164,7 +164,7 @@ eindent() {
# decrease the indent used for e-commands.
#
eoutdent() {
- local i=$1
+ local i="$1"
(( i > 0 )) || (( i = RC_DEFAULT_INDENT ))
esetdent $(( ${#RC_INDENTATION} - i ))
}
@@ -175,7 +175,7 @@ eoutdent() {
# num defaults to 0
#
esetdent() {
- local i=$1
+ local i="$1"
(( i < 0 )) && (( i = 0 ))
RC_INDENTATION=$(printf "%${i}s" '')
}
@@ -471,7 +471,7 @@ dolisting() {
# save the settings ("optstring") for "option"
#
save_options() {
- local myopts=$1
+ local myopts="$1"
shift
if [[ ! -d "${svcdir}/options/${myservice}" ]] ; then
@@ -502,6 +502,7 @@ get_options() {
# appended to it. For use with multi-config services.
add_suffix() {
echo "$1"
+
return 0
}
@@ -529,7 +530,7 @@ NET_FS_LIST="afs cifs coda davfs gfs ncpfs nfs nfs4 ocfs2 shfs smbfs"
is_net_fs() {
local fstype
# /proc/mounts is always accurate
- fstype=$( sed -n -e '/^rootfs/!s:.* '"$1"' \([^ ]*\).*:\1:p' /proc/mounts )
+ fstype=$( mount | sed -n -e 's:.* on '"$1"' type \([^ ]*\).*:\1:p' )
[[ " ${NET_FS_LIST} " == *" ${fstype} "* ]]
return $?
}
@@ -591,7 +592,7 @@ reverse_list() {
# Starts addon.
#
start_addon() {
- local addon=$1
+ local addon="$1"
(import_addon "${addon}-start.sh")
return 0
}
@@ -630,7 +631,7 @@ stop_volumes() {
# EXAMPLE: if is_older_than a.out *.o ; then ...
is_older_than() {
local x=
- local ref=$1
+ local ref="$1"
shift
for x in "$@" ; do
@@ -708,7 +709,7 @@ else
# Should we use colors ?
if [[ $* != *depend* ]] ; then
# Check user pref in portage
- RC_NOCOLOR=$(portageq envvar NOCOLOR 2>/dev/null)
+ RC_NOCOLOR="$(portageq envvar NOCOLOR 2>/dev/null)"
[[ ${RC_NOCOLOR} == "true" ]] && RC_NOCOLOR="yes"
else
# We do not want colors during emerge depend
@@ -724,7 +725,7 @@ if [[ -n ${EBUILD} && $* == *depend* ]] ; then
else
# Setup COLS and ENDCOL so eend can line up the [ ok ]
COLS=${COLUMNS:-0} # bash's internal COLUMNS variable
- (( COLS == 0 )) && COLS=$(stty size 2>/dev/null | cut -d' ' -f2)
+ (( COLS == 0 )) && COLS=$(set -- `stty size 2>/dev/null` ; echo $2)
(( COLS > 0 )) || (( COLS = 80 )) # width of [ ok ] == 7
fi
diff --git a/sbin/init-common-post.sh b/sbin/init-common-post.sh
index 5d4e102..2537b21 100755
--- a/sbin/init-common-post.sh
+++ b/sbin/init-common-post.sh
@@ -1,4 +1,4 @@
-# Copyright 1999-2005 Gentoo Foundation
+# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# We set the forced softlevel from the kernel command line
diff --git a/sbin/init-common-pre.sh b/sbin/init-common-pre.sh
index 5c4ef4c..3795498 100755
--- a/sbin/init-common-pre.sh
+++ b/sbin/init-common-pre.sh
@@ -1,4 +1,4 @@
-# Copyright 1999-2005 Gentoo Foundation
+# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Setup initial $PATH just in case
diff --git a/sbin/init-functions.sh b/sbin/init-functions.sh
index 04a1f13..2cf46b9 100755
--- a/sbin/init-functions.sh
+++ b/sbin/init-functions.sh
@@ -1,4 +1,4 @@
-# Copyright 1999-2005 Gentoo Foundation
+# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# bool check_statedir(dir)
@@ -40,14 +40,21 @@ start_critical_service() {
# Needed for some addons like dm-crypt that starts in critical services
local myservice=$1
- source "/etc/init.d/${service}" || eerror "Failed to source /etc/init.d/${service}"
+ source "/etc/init.d/${service}"
retval=$?
- [[ ${retval} -ne 0 ]] && return "${retval}"
- [[ -e /etc/conf.d/${service} ]] && source "/etc/conf.d/${service}"
- source /etc/rc.conf
+ if [[ ${retval} -ne 0 ]]; then
+ eerror "Failed to source /etc/init.d/${service}"
+ return "${retval}"
+ fi
- start || eerror "Failed to start /etc/init.d/${service}"
+ local conf="$(add_suffix /etc/conf.d/${service})"
+ [[ -e ${conf} ]] && source "${conf}"
+ conf="$(add_suffix /etc/rc.conf)"
+ [[ -e ${conf} ]] && source "${conf}"
+
+ start
retval=$?
+ [[ ${retval} -ne 0 ]] && eerror "Failed to start /etc/init.d/${service}"
return "${retval}"
)
diff --git a/sbin/init.linux.sh b/sbin/init.linux.sh
index ca4fca5..6c37cd6 100755
--- a/sbin/init.linux.sh
+++ b/sbin/init.linux.sh
@@ -1,4 +1,4 @@
-# Copyright 1999-2005 Gentoo Foundation
+# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# void single_user()
@@ -15,7 +15,7 @@ source "${svclib}"/sh/init-common-pre.sh
echo
echo -e "${GOOD}Gentoo Linux${GENTOO_VERS}; ${BRACKET}http://www.gentoo.org/${NORMAL}"
-echo -e " Copyright 1999-2005 Gentoo Foundation; Distributed under the GPLv2"
+echo -e " Copyright 1999-2006 Gentoo Foundation; Distributed under the GPLv2"
echo
echo -e "Press ${GOOD}I${NORMAL} to enter interactive boot mode"
echo
@@ -32,12 +32,12 @@ fi
if [[ ! -e /dev/pts/0 ]]; then
have_devpts="$(awk '($2 == "devpts") { print "yes"; exit 0 }' /proc/filesystems)"
- if [ "${have_devpts}" = "yes" ]; then
+ if [ "${have_devpts}" = "yes" ] ; then
# Make sure we have /dev/pts
mkdir -p /dev/pts &>/dev/null || \
ewarn "Could not create /dev/pts!"
- if [[ -d /dev/pts ]]; then
+ if [[ -d /dev/pts ]] ; then
ebegin "Mounting devpts at /dev/pts"
mount -n -t devpts -o gid=5,mode=0620 devpts /dev/pts
eend $?
diff --git a/sbin/rc b/sbin/rc
index 6471ace..000fabe 100755
--- a/sbin/rc
+++ b/sbin/rc
@@ -1,5 +1,5 @@
#!/sbin/runscript
-# Copyright 1999-2005 Gentoo Foundation
+# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
trap ":" INT QUIT TSTP
@@ -235,12 +235,12 @@ if [[ ${SOFTLEVEL} == "reboot" || ${SOFTLEVEL} == "shutdown" ]] ; then
# should help speed things up a bit
rm -rf $(ls -d1 "${svcdir}/"* 2>/dev/null | \
grep -ve '\(depcache\|deptree\|envcache\)')
-
+
# Need try(), etc
source "${svclib}"/sh/init-functions.sh
source /etc/init.d/halt.sh
-
+
if [[ ${SOFTLEVEL} == "reboot" ]] ; then
source /etc/init.d/reboot.sh
else
@@ -296,5 +296,4 @@ rm -rf "${svcdir}/failed" &>/dev/null
# Remove the cached CONSOLETYPE
unset CONSOLETYPE
-
# vim:ts=4
diff --git a/sbin/rc-daemon.sh b/sbin/rc-daemon.sh
index 8ef6bc6..51fc834 100755
--- a/sbin/rc-daemon.sh
+++ b/sbin/rc-daemon.sh
@@ -1,4 +1,4 @@
-# Copyright 1999-2005 Gentoo Foundation
+# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# RC functions to work with daemons
@@ -35,6 +35,8 @@ RC_WAIT_ON_START="0.1"
# Proccess vars - makes things easier by using the shift command
# and indirect variables
rc_shift_args() {
+ local addvar
+
while [[ $# != "0" ]]; do
if [[ $1 != "-"* && -n ${addvar} ]]; then
if [[ -z ${!addvar} ]]; then
@@ -95,7 +97,7 @@ rc_setup_daemon_vars() {
local x="${args// \'--\' /}"
[[ ${x} != "${args}" ]] && eargs=( "${args##* \'--\' }" )
- rc_shift_args ${sargs[@]}
+ eval rc_shift_args "${sargs[@]}"
[[ -z ${cmd} ]] && cmd="${name}"
@@ -224,7 +226,7 @@ is_daemon_running() {
read pid < "${pidfile}"
pids=" ${pids} "
- [[ ${pids// ${pid} } != "${pids}" ]]
+ [[ ${pids// ${pid} /} != "${pids}" ]]
}
# int rc_start_daemon(void)
@@ -276,9 +278,9 @@ rc_stop_daemon() {
# Check that the given program is actually running the pid
if [[ -n ${pids} ]]; then
pids=" ${pids} "
- [[ ${pids// ${pid} } == ${pids} ]] && return 1
+ [[ ${pids// ${pid} /} == "${pids}" ]] && return 1
fi
- pids=${pid}
+ pids="${pid}"
fi
# If there's nothing to kill then return without error
diff --git a/sbin/rc-help.sh b/sbin/rc-help.sh
index 214c19d..1799d96 100755
--- a/sbin/rc-help.sh
+++ b/sbin/rc-help.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 1999-2005 Gentoo Foundation
+# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
source /sbin/functions.sh
@@ -40,7 +40,7 @@ extra_opts=$(source "${myscript}" 2>/dev/null ; echo ${opts})
if [[ ${BE_VERBOSE} == "yes" ]] ; then
echo -e "
${GREEN}Gentoo RC-Scripts; ${BLUE}http://www.gentoo.org/${OFF}
- Copyright 1999-2005 Gentoo Foundation; Distributed under the GPL
+ Copyright 1999-2006 Gentoo Foundation; Distributed under the GPL
"
fi
diff --git a/sbin/rc-update b/sbin/rc-update
index a4150f8..3f9a980 100755
--- a/sbin/rc-update
+++ b/sbin/rc-update
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 1999-2005 Gentoo Foundation
+# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
source /sbin/functions.sh
diff --git a/sbin/runscript.sh b/sbin/runscript.sh
index 67626ed..ce1d1e9 100755
--- a/sbin/runscript.sh
+++ b/sbin/runscript.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 1999-2005 Gentoo Foundation
+# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Common functions
@@ -19,20 +19,20 @@ fi
svcpause="no"
svcrestart="no"
-myscript=$1
+myscript="$1"
if [[ -L $1 && ! -L /etc/init.d/${1##*/} ]] ; then
- myservice=$(readlink "$1")
+ myservice="$(readlink $1)"
else
- myservice=$1
+ myservice="$1"
fi
-myservice=${myservice##*/}
-export SVCNAME=${myservice}
-mylevel=$(<"${svcdir}/softlevel")
+myservice="${myservice##*/}"
+export SVCNAME="${myservice}"
+mylevel="$(<${svcdir}/softlevel)"
# Set $IFACE to the name of the network interface if it is a 'net.*' script
if [[ ${myservice%%.*} == "net" && ${myservice##*.} != "${myservice}" ]] ; then
- IFACE=${myservice##*.}
+ IFACE="${myservice##*.}"
NETSERVICE="yes"
else
IFACE=
@@ -40,22 +40,25 @@ else
fi
# Check if the textdomain is non-default
-search_lang=${LC_ALL:-${LC_MESSAGES:-${LANG}}}
+search_lang="${LC_ALL:-${LC_MESSAGES:-${LANG}}}"
[[ -f ${TEXTDOMAINDIR}/${search_lang%.*}/LC_MESSAGES/${myservice}.mo ]] \
- && TEXTDOMAIN=${myservice}
+ && TEXTDOMAIN="${myservice}"
# Source configuration files.
-# (1) Source /etc/conf.d/${myservice} to get initscript-specific
+# (1) Source /etc/conf.d/net if it is a net.* service
+# (2) Source /etc/conf.d/${myservice} to get initscript-specific
# configuration (if it exists).
-# (2) Source /etc/conf.d/net if it is a net.* service
# (3) Source /etc/rc.conf to pick up potentially overriding
# configuration, if the system administrator chose to put it
# there (if it exists).
-
-[[ -e $(add_suffix /etc/conf.d/${myservice}) ]] && source "$(add_suffix /etc/conf.d/${myservice})"
-[[ -e $(add_suffix /etc/conf.d/net) ]] && \
-[[ ${NETSERVICE} == "yes" ]] && source "$(add_suffix /etc/conf.d/net)"
-[[ -e $(add_suffix /etc/rc.conf) ]] && source "$(add_suffix /etc/rc.conf)"
+if [[ ${NETSERVICE} == "yes" ]]; then
+ conf="$(add_suffix /etc/conf.d/net)"
+ [[ -e ${conf} ]] && source "${conf}"
+fi
+conf="$(add_suffix /etc/conf.d/${myservice})"
+[[ -e ${conf} ]] && source "${conf}"
+conf="$(add_suffix /etc/rc.conf)"
+[[ -e ${conf} ]] && source "${conf}"
usage() {
local IFS="|"
@@ -132,7 +135,7 @@ svc_stop() {
mydeps="${mydeps} ${myservice}"
else
- mydeps=${myservice}
+ mydeps="${myservice}"
fi
fi
@@ -302,7 +305,7 @@ svc_start() {
$(dolisting "/etc/runlevels/${mylevel}/net.*")"
for y in ${netservices} ; do
- mynetservice=${y##*/}
+ mynetservice="${y##*/}"
if service_stopped "${mynetservice}" ; then
start_service "${mynetservice}"
fi