summaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-01-11 12:13:46 +0000
committerRoy Marples <roy@marples.name>2008-01-11 12:13:46 +0000
commit3bf49a9bd19d5bbcf6976dd42b4f87f1b173e287 (patch)
tree8b4d6121f0d4b921566eeec2844c9bf76131de78 /sh
parent1f4422c72f968405a0b8bf56d4f9c3b619b1b80d (diff)
downloadopenrc-3bf49a9bd19d5bbcf6976dd42b4f87f1b173e287.tar.gz
openrc-3bf49a9bd19d5bbcf6976dd42b4f87f1b173e287.tar.bz2
openrc-3bf49a9bd19d5bbcf6976dd42b4f87f1b173e287.tar.xz
Adopt a more C style for scripts and remove vim settings.
Diffstat (limited to 'sh')
-rw-r--r--sh/functions.sh11
-rwxr-xr-xsh/gendepends.sh10
-rw-r--r--sh/init-common-post.sh2
-rwxr-xr-xsh/net.sh38
-rwxr-xr-xsh/rc-functions.sh23
-rw-r--r--sh/rc-mount.sh5
-rwxr-xr-xsh/runscript.sh18
7 files changed, 61 insertions, 46 deletions
diff --git a/sh/functions.sh b/sh/functions.sh
index feab3f2..56af00f 100644
--- a/sh/functions.sh
+++ b/sh/functions.sh
@@ -6,13 +6,15 @@
RC_GOT_FUNCTIONS="yes"
-eindent() {
+eindent()
+{
EINFO_INDENT=$((${EINFO_INDENT:-0} + 2))
[ "${EINFO_INDENT}" -gt 40 ] && EINFO_INDENT=40
export EINFO_INDENT
}
-eoutdent() {
+eoutdent()
+{
EINFO_INDENT=$((${EINFO_INDENT:-0} - 2))
[ "${EINFO_INDENT}" -lt 0 ] && EINFO_INDENT=0
return 0
@@ -36,7 +38,8 @@ yesno()
esac
}
-_sanitize_path() {
+_sanitize_path()
+{
local IFS=":" p= path=
for p in ${PATH}; do
case "${p}" in
@@ -81,5 +84,3 @@ else
export EINFO_LASTCMD=${_e}; return \$_r; }"
done
fi
-
-# vim: set ts=4 :
diff --git a/sh/gendepends.sh b/sh/gendepends.sh
index 5536c3f..de12bc2 100755
--- a/sh/gendepends.sh
+++ b/sh/gendepends.sh
@@ -49,11 +49,15 @@ for _dir in /etc/init.d /usr/local/etc/init.d; do
_rc_c=${SVCNAME%%.*}
if [ -n "${_rc_c}" -a "${_rc_c}" != "${SVCNAME}" ]; then
- [ -e "${_dir}/../conf.d/${_rc_c}" ] && . "${_dir}/../conf.d/${_rc_c}"
+ if [ -e "${_dir}/../conf.d/${_rc_c}" ]; then
+ . "${_dir}/../conf.d/${_rc_c}"
+ fi
fi
unset _rc_c
- [ -e "${_dir}/../conf.d/${SVCNAME}" ] && . "${_dir}/../conf.d/${SVCNAME}"
+ if [ -e "${_dir}/../conf.d/${SVCNAME}" ]; then
+ . "${_dir}/../conf.d/${SVCNAME}"
+ fi
[ -e /etc/rc.conf ] && . /etc/rc.conf
@@ -71,5 +75,3 @@ for _dir in /etc/init.d /usr/local/etc/init.d; do
)
done
done
-
-# vim: set ts=4 :
diff --git a/sh/init-common-post.sh b/sh/init-common-post.sh
index 0aa378a..ca61d09 100644
--- a/sh/init-common-post.sh
+++ b/sh/init-common-post.sh
@@ -23,5 +23,3 @@ echo "sysinit" > "${RC_SVCDIR}/softlevel"
[ -e /dev/.rcsysinit ] && rm -f /dev/.rcsysinit
exit 0
-
-# vim: set ts=4 :
diff --git a/sh/net.sh b/sh/net.sh
index 27bc305..f3e43e2 100755
--- a/sh/net.sh
+++ b/sh/net.sh
@@ -13,7 +13,8 @@ description="Configures network interfaces."
# Handy var so we don't have to embed new lines everywhere for array splitting
__IFS="
"
-depend() {
+depend()
+{
local IFACE=${SVCNAME#*.}
local IFVAR=$(shell_var "${IFACE}")
@@ -43,7 +44,8 @@ depend() {
}
# Support bash arrays - sigh
-_get_array() {
+_get_array()
+{
local _a=
if [ -n "${BASH}" ]; then
case "$(declare -p "$1" 2>/dev/null)" in
@@ -64,7 +66,8 @@ _get_array() {
}
# Flatten bash arrays to simple strings
-_flatten_array() {
+_flatten_array()
+{
if [ -n "${BASH}" ]; then
case "$(declare -p "$1" 2>/dev/null)" in
"declare -a "*)
@@ -83,7 +86,8 @@ _flatten_array() {
[ -n "${_a}" ]
}
-_wait_for_carrier() {
+_wait_for_carrier()
+{
local timeout= efunc=einfon
_has_carrier && return 0
@@ -112,7 +116,8 @@ _wait_for_carrier() {
return 1
}
-_netmask2cidr() {
+_netmask2cidr()
+{
# Some shells cannot handle hex arithmetic, so we massage it slightly
# Buggy shells include FreeBSD sh, dash and busybox.
# bash and NetBSD sh don't need this.
@@ -140,7 +145,8 @@ _netmask2cidr() {
echo "${len}"
}
-_configure_variables() {
+_configure_variables()
+{
local var= v= t=
for var in ${_config_vars}; do
@@ -155,12 +161,14 @@ _configure_variables() {
done
}
-_show_address() {
+_show_address()
+{
einfo "received address $(_get_inet_address "${IFACE}")"
}
# Basically sorts our modules into order and saves the list
-_gen_module_list() {
+_gen_module_list()
+{
local x= f= force=$1
if ! ${force} && [ -s "${MODULESLIST}" -a "${MODULESLIST}" -nt "${MODULESDIR}" ]; then
local update=false
@@ -269,7 +277,8 @@ _gen_module_list() {
return 0
}
-_load_modules() {
+_load_modules()
+{
local starting=$1 mymods=
# Ensure our list is up to date
@@ -380,7 +389,8 @@ _load_modules() {
veinfo "Loaded modules: ${MODULES}"
}
-_load_config() {
+_load_config()
+{
local config="$(_get_array "config_${IFVAR}")"
local fallback="$(_get_array fallback_${IFVAR})"
@@ -437,7 +447,8 @@ _load_config() {
config_index=-1
}
-start() {
+start()
+{
local IFACE=${SVCNAME#*.} oneworked=false module=
local IFVAR=$(shell_var "${IFACE}") cmd= our_metric=
local metric=0
@@ -612,7 +623,8 @@ ${routes}"
return 0
}
-stop() {
+stop()
+{
local IFACE=${SVCNAME#*.} module=
local IFVAR=$(shell_var "${IFACE}") opts=
@@ -677,5 +689,3 @@ stop() {
return 0
}
-
-# vim: set ts=4 sw=4 :
diff --git a/sh/rc-functions.sh b/sh/rc-functions.sh
index 2e6fc31..66a26f4 100755
--- a/sh/rc-functions.sh
+++ b/sh/rc-functions.sh
@@ -2,11 +2,13 @@
# Copyright 2007-2008 Roy Marples
# All rights reserved
-has_addon() {
+has_addon()
+{
[ -e "${RC_LIBDIR}/addons/$1.sh" ] || [ -e /lib/rcscripts/addons/"$1".sh ]
}
-import_addon() {
+import_addon()
+{
if [ -e "${RC_LIBDIR}/addons/$1.sh" ]; then
. "${RC_LIBDIR}/addons/$1.sh"
elif [ -e /lib/rcscripts/addons/"$1".sh ]; then
@@ -16,16 +18,19 @@ import_addon() {
fi
}
-start_addon() {
+start_addon()
+{
( import_addon "$1-start" )
}
-stop_addon() {
+stop_addon()
+{
( import_addon "$1-stop" )
}
net_fs_list="afs cifs coda davfs fuse gfs ncpfs nfs nfs4 ocfs2 shfs smbfs"
-is_net_fs() {
+is_net_fs()
+{
[ -z "$1" ] && return 1
# Check OS specific flags to see if we're local or net mounted
@@ -40,12 +45,14 @@ is_net_fs() {
return 1
}
-is_union_fs() {
+is_union_fs()
+{
[ ! -x /sbin/unionctl ] && return 1
unionctl "$1" --list >/dev/null 2>&1
}
-get_bootparam() {
+get_bootparam()
+{
local match="$1"
[ -z "${match}" -o ! -r /proc/cmdline ] && return 1
@@ -71,5 +78,3 @@ case "${PATH}" in
/lib/rc/sbin|/lib/rc/sbin:*);;
*) export PATH="/lib/rc/sbin:${PATH}";;
esac
-
-# vim: set ts=4 :
diff --git a/sh/rc-mount.sh b/sh/rc-mount.sh
index 946a5e7..5e791b7 100644
--- a/sh/rc-mount.sh
+++ b/sh/rc-mount.sh
@@ -5,7 +5,8 @@
# mountinfo is a C program to actually find our mounts on our supported OS's
# We rely on fuser being preset, so if it's not then we don't unmount anything.
# This isn't a real issue for the BSD's, but it is for Linux.
-do_unmount() {
+do_unmount()
+{
type fuser >/dev/null 2>&1 || return 0
local cmd="$1" retval=0 retry=
@@ -73,5 +74,3 @@ do_unmount() {
done
return ${retval}
}
-
-# vim: set ts=4 :
diff --git a/sh/runscript.sh b/sh/runscript.sh
index 19d5941..eea9a3e 100755
--- a/sh/runscript.sh
+++ b/sh/runscript.sh
@@ -19,7 +19,8 @@ if [ -z "$1" -o -z "$2" ]; then
fi
# Descript the init script to the user
-describe() {
+describe()
+{
if [ -n "${description}" ]; then
einfo "${description}"
else
@@ -135,10 +136,11 @@ while [ -n "$1" ]; do
${extra_started_commands}; do
if [ "${_cmd}" = "$1" ]; then
if type "$1" >/dev/null 2>&1; then
- # If we're in the background, we may wish to fake some
- # commands. We do this so we can "start" ourselves from
- # inactive which then triggers other services to start
- # which depend on us. A good example of this is openvpn.
+ # If we're in the background, we may wish to
+ # fake some commands. We do this so we can
+ # "start" ourselves from inactive which then
+ # triggers other services to start which depend
+ # on us. A good example of this is openvpn.
if yesno ${IN_BACKGROUND}; then
for _cmd in ${in_background_fake}; do
if [ "${_cmd}" = "$1" ]; then
@@ -147,8 +149,8 @@ while [ -n "$1" ]; do
fi
done
fi
- # Check to see if we need to be started before we can run
- # this command
+ # Check to see if we need to be started before
+ # we can run this command
for _cmd in ${extra_started_commands}; do
if [ "${_cmd}" = "$1" ]; then
if ! service_started "${SVCNAME}"; then
@@ -180,5 +182,3 @@ while [ -n "$1" ]; do
eerror "${SVCNAME}: unknown function \`$1'"
exit 1
done
-
-# vim: set ts=4 :