Adopt a more C style for scripts and remove vim settings.
This commit is contained in:
@@ -2,14 +2,16 @@
|
||||
# Copyright 2007-2008 Roy Marples
|
||||
# All rights reserved
|
||||
|
||||
depend() {
|
||||
depend()
|
||||
{
|
||||
use hostname
|
||||
need localmount
|
||||
before logger
|
||||
after clock sysctl
|
||||
}
|
||||
|
||||
cleanup_tmp_dir() {
|
||||
cleanup_tmp_dir()
|
||||
{
|
||||
local dir=$1
|
||||
|
||||
mkdir -p "${dir}"
|
||||
@@ -48,7 +50,8 @@ cleanup_tmp_dir() {
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
start()
|
||||
{
|
||||
if ! mkdir /.test.$$ 2>/dev/null; then
|
||||
ewarn "Skipping /var and /tmp initialization (ro root?)"
|
||||
return 0
|
||||
@@ -73,12 +76,14 @@ start() {
|
||||
|
||||
ebegin "Cleaning /var/run"
|
||||
for x in $(find /var/run ! -type d ! -name utmp ! -name innd.pid \
|
||||
! -name random-seed ! -name ld-elf.so.hints ! -name ld.so.hints); do
|
||||
! -name random-seed ! -name ld-elf.so.hints \
|
||||
! -name ld.so.hints); do
|
||||
[ ! -f "${x}" ] && continue
|
||||
# Do not remove pidfiles of already running daemons
|
||||
case "${x}" in
|
||||
*.pid)
|
||||
start-stop-daemon --test --quiet --stop --pidfile "${x}"
|
||||
start-stop-daemon --test --quiet --stop \
|
||||
--pidfile "${x}"
|
||||
[ $? -eq 0 ] && continue
|
||||
;;
|
||||
esac
|
||||
@@ -110,7 +115,8 @@ start() {
|
||||
rm -f /etc/nologin
|
||||
}
|
||||
|
||||
stop() {
|
||||
stop()
|
||||
{
|
||||
# Write a halt record if we're shutting down
|
||||
case "${RC_SOFTLEVEL}" in
|
||||
reboot|shutdown) [ "${RC_UNAME}" = "Linux" ] && halt -w;;
|
||||
@@ -118,5 +124,3 @@ stop() {
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# vim: set ts=4 :
|
||||
|
@@ -5,13 +5,15 @@
|
||||
description="Check filesystems according to /etc/fstab for errors and \
|
||||
optionally repair them."
|
||||
|
||||
depend() {
|
||||
depend()
|
||||
{
|
||||
need checkroot
|
||||
after modules
|
||||
keywords notimeout
|
||||
}
|
||||
|
||||
do_checkfs() {
|
||||
do_checkfs()
|
||||
{
|
||||
local retval=0 mode="-p" opts= parts=
|
||||
|
||||
ebegin "Checking all filesystems"
|
||||
@@ -56,16 +58,16 @@ do_checkfs() {
|
||||
return ${retval}
|
||||
}
|
||||
|
||||
start() {
|
||||
start()
|
||||
{
|
||||
do_checkfs
|
||||
}
|
||||
|
||||
stop() {
|
||||
stop()
|
||||
{
|
||||
# fsck on shutdown if we need to
|
||||
if yesno "${fsck_shutdown:-${FSCK_SHUTDOWN}}"; then
|
||||
do_checkfs
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# vim: set ts=4 :
|
||||
|
@@ -5,11 +5,13 @@
|
||||
description="Check the root filesystem according to /etc/fstab for errors \
|
||||
and optionally repair them."
|
||||
|
||||
depend() {
|
||||
depend()
|
||||
{
|
||||
keywords notimeout
|
||||
}
|
||||
|
||||
do_mtab() {
|
||||
do_mtab()
|
||||
{
|
||||
# Don't create mtab if /etc is readonly
|
||||
if ! echo 2>/dev/null >/etc/mtab; then
|
||||
ewarn "Skipping /etc/mtab initialization (ro root)"
|
||||
@@ -28,12 +30,14 @@ do_mtab() {
|
||||
eend 0
|
||||
}
|
||||
|
||||
root_rw() {
|
||||
root_rw()
|
||||
{
|
||||
echo 2>/dev/null >/.test.$$ || return 1
|
||||
rm -f /.test.$$
|
||||
}
|
||||
|
||||
do_fsck() {
|
||||
do_fsck()
|
||||
{
|
||||
local retval=0 opts= root=
|
||||
case "${RC_UNAME}" in
|
||||
FreeBSD) opts="-F";;
|
||||
@@ -104,7 +108,8 @@ do_fsck() {
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
start()
|
||||
{
|
||||
do_fsck || return 1
|
||||
|
||||
if ! root_rw; then
|
||||
@@ -123,5 +128,3 @@ start() {
|
||||
# We got here, so return 0
|
||||
return 0
|
||||
}
|
||||
|
||||
# vim: set ts=4 :
|
||||
|
@@ -97,5 +97,3 @@ fi
|
||||
|
||||
# Always exit 0 here
|
||||
exit 0
|
||||
|
||||
# vim: set ts=4 :
|
||||
|
@@ -4,15 +4,15 @@
|
||||
|
||||
description="Sets the hostname of the machine."
|
||||
|
||||
depend() {
|
||||
depend()
|
||||
{
|
||||
need checkroot
|
||||
}
|
||||
|
||||
start() {
|
||||
start()
|
||||
{
|
||||
hostname=${hostname-${HOSTNAME-localhost}}
|
||||
ebegin "Setting hostname to ${hostname}"
|
||||
hostname "${hostname}"
|
||||
eend $? "Failed to set the hostname"
|
||||
}
|
||||
|
||||
# vim: set ts=4 :
|
||||
|
11
init.d/local
11
init.d/local
@@ -4,12 +4,14 @@
|
||||
|
||||
description="Executes user commands in /etc/conf.d/local"
|
||||
|
||||
depend() {
|
||||
depend()
|
||||
{
|
||||
after *
|
||||
keywords notimeout
|
||||
}
|
||||
|
||||
start() {
|
||||
start()
|
||||
{
|
||||
ebegin "Starting local"
|
||||
|
||||
if type local_start >/dev/null 2>&1; then
|
||||
@@ -24,7 +26,8 @@ start() {
|
||||
eend $? "Failed to start local"
|
||||
}
|
||||
|
||||
stop() {
|
||||
stop()
|
||||
{
|
||||
ebegin "Stopping local"
|
||||
|
||||
if type local_start >/dev/null 2>&1; then
|
||||
@@ -38,5 +41,3 @@ stop() {
|
||||
|
||||
eend $? $"Failed to stop local"
|
||||
}
|
||||
|
||||
# vim: set ts=4 :
|
||||
|
@@ -4,11 +4,13 @@
|
||||
|
||||
description="Mounts disks and swap according to /etc/fstab."
|
||||
|
||||
depend() {
|
||||
depend()
|
||||
{
|
||||
need checkfs
|
||||
}
|
||||
|
||||
start() {
|
||||
start()
|
||||
{
|
||||
# Mount local filesystems in /etc/fstab.
|
||||
local types="noproc" x=
|
||||
for x in ${net_fs_list}; do
|
||||
@@ -23,7 +25,8 @@ start() {
|
||||
return 0
|
||||
}
|
||||
|
||||
stop() {
|
||||
stop()
|
||||
{
|
||||
# Don't unmount anything for VPS systems
|
||||
[ "${RC_SYS}" = "VPS" ] && return 0
|
||||
|
||||
@@ -80,5 +83,3 @@ stop() {
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# vim: set ts=4 :
|
||||
|
@@ -4,7 +4,8 @@
|
||||
|
||||
description="Mounts network shares according to /etc/fstab."
|
||||
|
||||
need_portmap() {
|
||||
need_portmap()
|
||||
{
|
||||
local opts=
|
||||
local IFS="
|
||||
"
|
||||
@@ -18,9 +19,10 @@ need_portmap() {
|
||||
return 1
|
||||
}
|
||||
|
||||
depend() {
|
||||
# Only have portmap as a dependency if there is a nfs mount in fstab that
|
||||
# is set to mount at boot
|
||||
depend()
|
||||
{
|
||||
# Only have portmap as a dependency if there is a nfs mount in fstab
|
||||
# that is set to mount at boot
|
||||
local pmap=""
|
||||
if need_portmap; then
|
||||
pmap="${pmap} rpc.statd"
|
||||
@@ -34,7 +36,8 @@ depend() {
|
||||
use afc-client amd autofs dns nfs nfsmount portmap rpcbind rpc.statd
|
||||
}
|
||||
|
||||
start() {
|
||||
start()
|
||||
{
|
||||
local myneed= myuse= pmap="portmap" nfsmounts=
|
||||
[ -x /etc/init.d/rpcbind ] && pmap="rpcbind"
|
||||
|
||||
@@ -42,17 +45,18 @@ start() {
|
||||
for x in ${net_fs_list}; do
|
||||
case "${x}" in
|
||||
nfs|nfs4)
|
||||
# If the nfsmount script took care of the nfs filesystems,
|
||||
# then there's no point in trying them twice
|
||||
service_started nfsmount && continue
|
||||
# If the nfsmount script took care of the nfs
|
||||
# filesystems, then there's no point in trying
|
||||
# them twice
|
||||
service_started nfsmount && continue
|
||||
|
||||
# Only try to mount NFS filesystems if portmap was started.
|
||||
# This is to fix "hang" problems for new users who do not
|
||||
# add portmap to the default runlevel.
|
||||
if need_portmap && ! service_started "${pmap}"; then
|
||||
continue
|
||||
fi
|
||||
;;
|
||||
# Only try to mount NFS filesystems if portmap was
|
||||
# started. This is to fix "hang" problems for new
|
||||
# users who do not add portmap to the default runlevel.
|
||||
if need_portmap && ! service_started "${pmap}"; then
|
||||
continue
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fs="${fs}${fs:+,}${x}"
|
||||
done
|
||||
@@ -63,7 +67,8 @@ start() {
|
||||
return 0
|
||||
}
|
||||
|
||||
stop() {
|
||||
stop()
|
||||
{
|
||||
local x= fs=
|
||||
|
||||
ebegin "Unmounting network filesystems"
|
||||
@@ -73,7 +78,7 @@ stop() {
|
||||
fs="${fs}${fs:+,}${x}"
|
||||
done
|
||||
if [ -n "${fs}" ]; then
|
||||
umount -at ${fs} || eerror "Failed to simply unmount filesystems"
|
||||
umount -at ${fs} || eerror "Failed to simply unmount filesystems"
|
||||
fi
|
||||
|
||||
eindent
|
||||
@@ -88,5 +93,3 @@ stop() {
|
||||
eoutdent
|
||||
eend ${retval} "Failed to unmount network filesystems"
|
||||
}
|
||||
|
||||
# vim: set ts=4 :
|
||||
|
@@ -2,17 +2,20 @@
|
||||
# Copyright 2007-2008 Roy Marples
|
||||
# All rights reserved
|
||||
|
||||
depend() {
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
}
|
||||
|
||||
start() {
|
||||
start()
|
||||
{
|
||||
ebegin "Activating swap"
|
||||
swapon -a >/dev/null
|
||||
eend 0 # If swapon has nothing todo it errors, so always return 0
|
||||
}
|
||||
|
||||
stop() {
|
||||
stop()
|
||||
{
|
||||
ebegin "Deactivating swap"
|
||||
swapoff -a >/dev/null
|
||||
eend 0
|
||||
|
@@ -6,24 +6,27 @@ urandom_seed=${urandom_seed:-${URANDOM_SEED:-/var/run/random-seed}}
|
||||
|
||||
description="Initializes the random number generator."
|
||||
|
||||
depend() {
|
||||
depend()
|
||||
{
|
||||
need localmount
|
||||
}
|
||||
|
||||
save_seed() {
|
||||
local poolsize=1
|
||||
save_seed()
|
||||
{
|
||||
local psz=1
|
||||
|
||||
if [ -e /proc/sys/kernel/random/poolsize ]; then
|
||||
poolsize=$(($(cat /proc/sys/kernel/random/poolsize) / 4096))
|
||||
psz=$(($(cat /proc/sys/kernel/random/poolsize) / 4096))
|
||||
fi
|
||||
|
||||
( # sub shell to prevent umask pollution
|
||||
umask 077
|
||||
dd if=/dev/urandom of="${urandom_seed}" count=${poolsize} 2>/dev/null
|
||||
dd if=/dev/urandom of="${urandom_seed}" count=${psz} 2>/dev/null
|
||||
)
|
||||
}
|
||||
|
||||
start() {
|
||||
start()
|
||||
{
|
||||
[ -c /dev/urandom ] || return
|
||||
if [ -f "${urandom_seed}" ]; then
|
||||
ebegin "Initializing random number generator"
|
||||
@@ -34,10 +37,9 @@ start() {
|
||||
return 0
|
||||
}
|
||||
|
||||
stop() {
|
||||
stop()
|
||||
{
|
||||
ebegin "Saving random seed"
|
||||
save_seed
|
||||
eend $? "Failed to save random seed"
|
||||
}
|
||||
|
||||
# vim: set ts=4 :
|
||||
|
Reference in New Issue
Block a user