1 systemv启动
(1) 启动脚本
inittab 脚本
# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $
# The default runlevel.
id:5:initdefault:
# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS
# What to do in single-user mode.
~~:S:wait:/sbin/sulogin
# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.
l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin
#mxc0:12345:respawn:/bin/start_getty 115200 ttymxc0
mxc0:12345:respawn:/sbin/getty -l /bin/autologin -n -L 115200 ttymxc0
# /sbin/getty invocations for the runlevels.
#
# The "id" field MUST be the same as the last
# characters of the device (after "tty").
#
# Format:
# <id>:<runlevels>:<action>:<process>
#
1:12345:respawn:/sbin/getty 38400 tty1
/etc/init.d/rcS 脚本
#! /bin/sh
#
# rcS
#
# Call all S??* scripts in /etc/rcS.d/ in numerical/alphabetical order
#
exec /etc/init.d/rc S
/etc/init.d/rc
#! /bin/sh
#
# rc
#
# Starts/stops services on runlevel changes.
#
# Optimization: A start script is not run when the service was already
# configured to run in the previous runlevel. A stop script is not run
# when the the service was already configured not to run in the previous
# runlevel.
#
# Authors:
# Miquel van Smoorenburg <miquels@cistron.nl>
# Bruce Perens <Bruce@Pixar.com>
PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH
# Un-comment the following for interactive debugging. Do not un-comment
# this for debugging a real boot process as no scripts will be executed.
# debug=echo
# Make sure the name survive changing the argument list
scriptname="$0"
umask 022
on_exit() {
echo "error: '$scriptname' exited outside the expected code flow."
}
trap on_exit EXIT # Enable emergency handler
# Ignore CTRL-C only in this shell, so we can interrupt subprocesses.
trap ":" INT QUIT TSTP
# Set onlcr to avoid staircase effect.
stty onlcr 0>&1
# Now find out what the current and what the previous runlevel are.
runlevel=$RUNLEVEL
# Get first argument. Set new runlevel to this argument.
[ "$1" != "" ] && runlevel=$1
if [ "$runlevel" = "" ]
then
echo "Usage: $scriptname <runlevel>" >&2
exit 1
fi
previous=$PREVLEVEL
[ "$previous" = "" ] && previous=N
export runlevel previous
if [ -f /etc/default/rcS ] ; then
. /etc/default/rcS
fi
export VERBOSE
if [ -f /lib/lsb/init-functions ] ; then
. /lib/lsb/init-functions
else
log_action_msg() { echo $@; }
log_failure_msg() { echo $@; }
log_warning_msg() { echo $@; }
fi
#
# Check if we are able to use make like booting. It require the
# insserv package to be enabled. Boot concurrency also requires
# startpar to be installed.
#
#CONCURRENCY=makefile
# disable startpar, incompatible with "task" upstart jobs
CONCURRENCY=none
test -s /etc/init.d/.depend.boot || CONCURRENCY="none"
test -s /etc/init.d/.depend.start || CONCURRENCY="none"
test -s /etc/init.d/.depend.stop || CONCURRENCY="none"
if test -e /etc/init.d/.legacy-bootordering ; then
CONCURRENCY="none"
fi
if ! test -e /proc/stat; then
# startpar requires /proc/stat
if [ "$(uname)" = "GNU/kFreeBSD" ] ; then
mount -t linprocfs linprocfs /proc
elif [ "$(uname)" = "GNU" ] ; then
mount -t proc none /proc
fi
fi
if [ -x /lib/startpar/startpar ] ; then
STARTPAR=/lib/startpar/startpar
else
STARTPAR=startpar
fi
$STARTPAR -v > /dev/null 2>&1 || CONCURRENCY="none"
#
# Start script or program.
#
case "$CONCURRENCY" in
makefile|startpar|shell) # startpar and shell are obsolete
CONCURRENCY=makefile
log_action_msg "Using makefile-style concurrent boot in runlevel $runlevel"
startup() {
eval "$($STARTPAR -p 4 -t 20 -T 3 -M $1 -P $previous -R $runlevel)"
if [ -n "$failed_service" ]
then
log_failure_msg "startpar: service(s) returned failure: $failed_service"
fi
if [ -n "$skipped_service_not_installed" ]
then
log_warning_msg "startpar: service(s) skipped, program is not installed: $skipped_service_not_installed"
fi
if [ -n "$skipped_service_not_configured" ]
then
log_warning_msg "startpar: service(s) skipped, program is not configured: $skipped_service_not_configured"
fi
unset failed_service skipped_service_not_installed skipped_service_not_configured
}
;;
none|*)
startup() {
action=$1
shift
scripts="$@"
for script in $scripts ; do
$debug "$script" $action
done
}
;;
esac
# Is there an rc directory for this new runlevel?
if [ -d /etc/rc$runlevel.d ]
then
case "$runlevel" in
0|6)
ACTION=stop
;;
S)
ACTION=start
;;
*)
ACTION=start
;;
esac
# First, run the KILL scripts.
if [ makefile = "$CONCURRENCY" ]
then
if [ "$ACTION" = "start" ] && [ "$previous" != N ]
then
startup stop
fi
elif [ "$previous" != N ]
then
# Run all scripts with the same level in parallel
CURLEVEL=""
for s in /etc/rc$runlevel.d/K*
do
# Extract order value from symlink
level=${s#/etc/rc$runlevel.d/K}
level=${level%%[a-zA-Z]*}
if [ "$level" = "$CURLEVEL" ]
then
continue
fi
CURLEVEL=$level
SCRIPTS=""
for i in /etc/rc$runlevel.d/K$level*
do
# Check if the script is there.
[ ! -f $i ] && continue
#
# Find stop script in previous runlevel but
# no start script there.
#
suffix=${i#/etc/rc$runlevel.d/K[0-9][0-9]}
previous_stop=/etc/rc$previous.d/K[0-9][0-9]$suffix
previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix
#
# If there is a stop script in the previous level
# and _no_ start script there, we don't
# have to re-stop the service.
#
[ -f $previous_stop ] && [ ! -f $previous_start ] && continue
# Stop the service.
SCRIPTS="$SCRIPTS $i"
done
startup stop $SCRIPTS
done
fi
if [ makefile = "$CONCURRENCY" ]
then
if [ S = "$runlevel" ]
then
startup boot
else
startup $ACTION
fi
else
# Now run the START scripts for this runlevel.
# Run all scripts with the same level in parallel
CURLEVEL=""
for s in /etc/rc$runlevel.d/S*
do
# Extract order value from symlink
level=${s#/etc/rc$runlevel.d/S}
level=${level%%[a-zA-Z]*}
if [ "$level" = "$CURLEVEL" ]
then
continue
fi
CURLEVEL=$level
SCRIPTS=""
for i in /etc/rc$runlevel.d/S$level*
do
[ ! -f $i ] && continue
suffix=${i#/etc/rc$runlevel.d/S[0-9][0-9]}
if [ "$previous" != N ]
then
#
# Find start script in previous runlevel and
# stop script in this runlevel.
#
stop=/etc/rc$runlevel.d/K[0-9][0-9]$suffix
previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix
#
# If there is a start script in the previous level
# and _no_ stop script in this level, we don't
# have to re-start the service.
#
if [ start = "$ACTION" ] ; then
[ -f $previous_start ] && [ ! -f $stop ] && continue
else
# Workaround for the special
# handling of runlevels 0 and 6.
previous_stop=/etc/rc$previous.d/K[0-9][0-9]$suffix
#
# If there is a stop script in the previous level
# and _no_ start script there, we don't
# have to re-stop the service.
#
[ -f $previous_stop ] && [ ! -f $previous_start ] && continue
fi
fi
SCRIPTS="$SCRIPTS $i"
done
startup $ACTION $SCRIPTS
done
fi
fi
trap - EXIT # Disable emergency handler
exit 0
(2) rcS.d 目录文件
S00psplash
#!/bin/sh
### BEGIN INIT INFO
# Provides: psplash
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop:
### END INIT INFO
read CMDLINE < /proc/cmdline
for x in $CMDLINE; do
case $x in
psplash=false)
echo "Boot splashscreen disabled"
exit 0;
;;
esac
done
export TMPDIR=/mnt/.psplash
mount tmpfs -t tmpfs $TMPDIR -o,size=40k
rotation=0
if [ -e /etc/rotation ]; then
read rotation < /etc/rotation
fi
arg=$(ps -aux | egrep "Q" | grep -v grep |awk '{print $2}')
if [ -n "$arg" ];then
kill -9 $arg
fi
/usr/bin/psplash --angle $rotation &
S02banner
#!/bin/sh
### BEGIN INIT INFO
# Provides: banner
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop:
### END INIT INFO
if [ ! -e /dev/tty ]; then
/bin/mknod -m 0666 /dev/tty c 5 0
fi
if ( > /dev/tty0 ) 2>/dev/null; then
vtmaster=/dev/tty0
elif ( > /dev/vc/0 ) 2>/dev/null; then
vtmaster=/dev/vc/0
elif ( > /dev/console ) 2>/dev/null; then
vtmaster=/dev/console
else
vtmaster=/dev/null
fi
echo > $vtmaster
echo "Please wait: booting..." > $vtmaster
S02sysfs
#!/bin/sh
### BEGIN INIT INFO
# Provides: mountvirtfs
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Mount kernel virtual file systems.
# Description: Mount initial set of virtual filesystems the kernel
# provides and that are required by everything.
### END INIT INFO
if [ -e /proc ] && ! [ -e /proc/mounts ]; then
mount -t proc proc /proc
fi
if [ -e /sys ] && grep -q sysfs /proc/filesystems && ! [ -e /sys/class ]; then
mount -t sysfs sysfs /sys
fi
if [ -e /sys/kernel/debug ] && grep -q debugfs /proc/filesystems; then
mount -t debugfs debugfs /sys/kernel/debug
fi
if ! [ -e /dev/zero ] && [ -e /dev ] && grep -q devtmpfs /proc/filesystems; then
mount -n -t devtmpfs devtmpfs /dev
fi
S03mountall
#!/bin/sh
### BEGIN INIT INFO
# Provides: mountall
# Required-Start: mountvirtfs
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Mount all filesystems.
# Description:
### END INIT INFO
. /etc/default/rcS
#
# Mount local filesystems in /etc/fstab. For some reason, people
# might want to mount "proc" several times, and mount -v complains
# about this. So we mount "proc" filesystems without -v.
#
test "$VERBOSE" != no && echo "Mounting local filesystems..."
mount -at nonfs,nosmbfs,noncpfs 2>/dev/null
#
# We might have mounted something over /dev, see if /dev/initctl is there.
#
if test ! -p /dev/initctl
then
rm -f /dev/initctl
mknod -m 600 /dev/initctl p
fi
kill -USR1 1
#
# Execute swapon command again, in case we want to swap to
# a file on a now mounted filesystem.
#
swapon -a 2> /dev/null
: exit 0
S04udev
#!/bin/sh
### BEGIN INIT INFO
# Provides: udev
# Required-Start: mountvirtfs
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Start udevd, populate /dev and load drivers.
### END INIT INFO
export TZ=/etc/localtime
[ -d /sys/class ] || exit 1
[ -r /proc/mounts ] || exit 1
[ -x /sbin/udevd ] || exit 1
SYSCONF_CACHED="/etc/udev/cache.data"
SYSCONF_TMP="/dev/shm/udev.cache"
DEVCACHE_REGEN="/dev/shm/udev-regen" # create to request cache regen
# A list of files which are used as a criteria to judge whether the udev cache could be reused.
CMP_FILE_LIST="/proc/version /proc/cmdline /proc/devices"
[ -f /proc/atags ] && CMP_FILE_LIST="$CMP_FILE_LIST /proc/atags"
# List of files whose metadata (size/mtime/name) will be included in cached
# system state.
META_FILE_LIST="lib/udev/rules.d/* etc/udev/rules.d/*"
# Command to compute system configuration.
sysconf_cmd () {
cat -- $CMP_FILE_LIST
stat -c '%s %Y %n' -- $META_FILE_LIST | awk -F/ '{print $1 " " $NF;}'
}
[ -f /etc/default/udev-cache ] && . /etc/default/udev-cache
[ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf
[ -f /etc/default/rcS ] && . /etc/default/rcS
kill_udevd () {
pid=`pidof -x udevd`
[ -n "$pid" ] && kill $pid
}
case "$1" in
start)
export ACTION=add
# propagate /dev from /sys
echo "Starting udev"
# Check for requireed devtmpfs before trying to start udev and
# mount a no-existant fs.
if ! grep -q devtmpfs /proc/filesystems
then
echo "Missing devtmpfs, which is required for udev to run";
echo "Halting..."
halt
fi
# mount the devtmpfs on /dev, if not already done
LANG=C awk '$2 == "/dev" && ($3 == "devtmpfs") { exit 1 }' /proc/mounts && {
mount -n -o mode=0755 -t devtmpfs none "/dev"
}
[ -e /dev/pts ] || mkdir -m 0755 /dev/pts
[ -e /dev/shm ] || mkdir -m 1777 /dev/shm
# the automount rule for udev needs /tmp directory available, as /tmp is a symlink
# to /var/tmp which in turn is a symlink to /var/volatile/tmp, we need to make sure
# /var/volatile/tmp directory to be available.
mkdir -m 1777 -p /var/volatile/tmp
# Cache handling.
if [ "$DEVCACHE" != "" ]; then
if [ -e $DEVCACHE ]; then
sysconf_cmd > "$SYSCONF_TMP"
if cmp $SYSCONF_CACHED $SYSCONF_TMP >/dev/null; then
tar xmf $DEVCACHE -C / -m
not_first_boot=1
[ "$VERBOSE" != "no" ] && echo "udev: using cache file $DEVCACHE"
[ -e $SYSCONF_TMP ] && rm -f "$SYSCONF_TMP"
[ -e "$DEVCACHE_REGEN" ] && rm -f "$DEVCACHE_REGEN"
else
# Output detailed reason why the cached /dev is not used
cat <<EOF
udev: Not using udev cache because of changes detected in the following files:
udev: $CMP_FILE_LIST
udev: $META_FILE_LIST
udev: The udev cache will be regenerated. To identify the detected changes,
udev: compare the cached sysconf at $SYSCONF_CACHED
udev: against the current sysconf at $SYSCONF_TMP
EOF
touch "$DEVCACHE_REGEN"
fi
else
if [ "$ROOTFS_READ_ONLY" != "yes" ]; then
# If rootfs is not read-only, it's possible that a new udev cache would be generated;
# otherwise, we do not bother to read files.
touch "$DEVCACHE_REGEN"
fi
fi
fi
# make_extra_nodes
kill_udevd > "/dev/null" 2>&1
# trigger the sorted events
[ -e /proc/sys/kernel/hotplug ] && echo -e '\000' >/proc/sys/kernel/hotplug
/sbin/udevd -d
udevadm control --env=STARTUP=1
if [ "$not_first_boot" != "" ];then
if [ "$PROBE_PLATFORM_BUS" != "yes" ]; then
PLATFORM_BUS_NOMATCH="--subsystem-nomatch=platform"
else
PLATFORM_BUS_NOMATCH=""
fi
udevadm trigger --action=add --subsystem-nomatch=tty --subsystem-nomatch=mem --subsystem-nomatch=vc --subsystem-nomatch=vtconsole --subsystem-nomatch=misc --subsystem-nomatch=dcon --subsystem-nomatch=pci_bus --subsystem-nomatch=graphics --subsystem-nomatch=backlight --subsystem-nomatch=video4linux $PLATFORM_BUS_NOMATCH
(udevadm settle --timeout=3; udevadm control --env=STARTUP=)&
else
udevadm trigger --action=add
udevadm settle
fi
;;
stop)
echo "Stopping udevd"
start-stop-daemon --stop --name udevd --quiet
;;
restart)
$0 stop
sleep 1
$0 start
;;
status)
pid=`pidof -x udevd`
if [ -n "$pid" ]; then
echo "udevd (pid $pid) is running ..."
else
echo "udevd is stopped"
fi
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
esac
exit 0
S05modutils
#!/bin/sh
### BEGIN INIT INFO
# Provides: module-init-tools
# Required-Start:
# Required-Stop:
# Should-Start: checkroot
# Should-stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Process /etc/modules.
# Description: Load the modules listed in /etc/modules.
### END INIT INFO
LOAD_MODULE=modprobe
[ -f /proc/modules ] || exit 0
[ -f /etc/modules ] || [ -d /etc/modules-load.d ] || exit 0
[ -e /sbin/modprobe ] || LOAD_MODULE=insmod
if [ ! -f /lib/modules/`uname -r`/modules.dep ]; then
[ "$VERBOSE" != no ] && echo "Calculating module dependencies ..."
depmod -Ae
fi
loaded_modules=" "
process_file() {
file=$1
(cat $file; echo; ) |
while read module args
do
case "$module" in
\#*|"") continue ;;
esac
[ -n "$(echo $loaded_modules | grep " $module ")" ] && continue
[ "$VERBOSE" != no ] && echo -n "$module "
eval "$LOAD_MODULE $module $args >/dev/null 2>&1"
loaded_modules="${loaded_modules}${module} "
done
}
[ "$VERBOSE" != no ] && echo -n "Loading modules: "
[ -f /etc/modules ] && process_file /etc/modules
[ -d /etc/modules-load.d ] || exit 0
for f in /etc/modules-load.d/*.conf; do
process_file $f
done
[ "$VERBOSE" != no ] && echo
exit 0
S06alignment
#!/bin/sh
### BEGIN INIT INFO
# Provides: alignment
# Required-Start: mountkernfs
# Required-Stop: mountkernfs
# Default-Start: S
# Default-Stop:
### END INIT INFO
S06checkroot
#!/bin/sh
### BEGIN INIT INFO
# Provides: checkroot
# Required-Start: udev
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Check to root file system.
### END INIT INFO
. /etc/default/rcS
#
# Set SULOGIN in /etc/default/rcS to yes if you want a sulogin to be spawned
# from this script *before anything else* with a timeout, like SCO does.
#
test "$SULOGIN" = yes && sulogin -t 30 $CONSOLE
#
# Read /etc/fstab.
#
exec 9< /etc/fstab
rootmode=rw
rootopts=rw
rootcheck=$ENABLE_ROOTFS_FSCK
swap_on_md=no
devfs=
while read fs mnt type opts dump pass junk <&9
do
case "$fs" in
""|\#*)
continue;
;;
/dev/md*)
# Swap on md device.
test "$type" = swap && swap_on_md=yes
;;
/dev/*)
;;
*)
# Might be a swapfile.
test "$type" = swap && swap_on_md=yes
;;
esac
test "$type" = devfs && devfs="$fs"
test "$mnt" != / && continue
rootopts="$opts"
test "$pass" = 0 -o "$pass" = "" && rootcheck=no
case "$opts" in
ro|ro,*|*,ro|*,ro,*)
rootmode=ro
;;
esac
done
exec 0>&9 9>&-
# Check for conflicting configurations
if [ "$rootmode" = "ro" -a "$ROOTFS_READ_ONLY" = "no" ] || \
[ "$rootmode" = "rw" -a "$ROOTFS_READ_ONLY" = "yes" ]; then
echo ""
echo "WARN: conflicting configurations in /etc/fstab and /etc/default/rcS"
echo " regarding the writability of rootfs. Please fix one of them."
echo ""
fi
#
# Activate the swap device(s) in /etc/fstab. This needs to be done
# before fsck, since fsck can be quite memory-hungry.
#
test "$VERBOSE" != no && echo "Activating swap"
swapon -a 2> /dev/null
#
# Check the root filesystem.
#
if test -f /fastboot || test $rootcheck = no
then
test $rootcheck = yes && echo "Fast boot, no filesystem check"
else
#
# Ensure that root is quiescent and read-only before fsck'ing.
#
mount -n -o remount,ro /
if test $? = 0
then
if test -f /forcefsck
then
force="-f"
else
force=""
fi
if test "$FSCKFIX" = yes
then
fix="-y"
else
fix="-a"
fi
spinner="-C"
case "$TERM" in
dumb|network|unknown|"") spinner="" ;;
esac
test `uname -m` = s390 && spinner="" # This should go away
test "$VERBOSE" != no && echo "Checking root filesystem..."
fsck $spinner $force $fix /
#
# If there was a failure, drop into single-user mode.
#
# NOTE: "failure" is defined as exiting with a return code of
# 2 or larger. A return code of 1 indicates that filesystem
# errors were corrected but that the boot may proceed.
#
if test "$?" -gt 1
then
# Surprise! Re-directing from a HERE document (as in
# "cat << EOF") won't work, because the root is read-only.
echo
echo "fsck failed. Please repair manually and reboot. Please note"
echo "that the root filesystem is currently mounted read-only. To"
echo "remount it read-write:"
echo
echo " # mount -n -o remount,rw /"
echo
echo "CONTROL-D will exit from this shell and REBOOT the system."
echo
# Start a single user shell on the console
/sbin/sulogin $CONSOLE
reboot -f
fi
else
echo "*** ERROR! Cannot fsck root fs because it is not mounted read-only!"
echo
fi
fi
#
# If the root filesystem was not marked as read-only in /etc/fstab,
# remount the rootfs rw but do not try to change mtab because it
# is on a ro fs until the remount succeeded. Then clean up old mtabs
# and finally write the new mtab.
#
mount -n -o remount,$rootmode /
if test "$rootmode" = rw
then
ln -sf /proc/mounts /dev/mtab
fi
exit 0
S07bootlogd
hawkbot@ubuntu:rcS.d$ cat S07bootlogd
#! /bin/sh
### BEGIN INIT INFO
# Provides: bootlogd
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop: 2 3 4 5
# Short-Description: One of the first scripts to be executed. Starts or stops
# the bootlogd log program. If this script is called as
# "stop-bootlogd", it will stop the daemon instead of
# starting it even when called with the "start" argument.
#
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/sbin/bootlogd
NAME=bootlogd
DESC="Bootlog daemon"
# source function library
. /etc/init.d/functions
test -f $DAEMON || exit 0
[ -r /etc/default/bootlogd ] && . /etc/default/bootlogd
## set -e # not needed
case "$BOOTLOGD_ENABLE" in
[Nn]*)
exit 0
;;
esac
STOPPER=
ACTION="$1"
case "$0" in
*stop-bootlog*)
STOPPER=Y
if [ "$ACTION" = start ]
then
ACTION=stop
fi
;;
esac
case "$ACTION" in
start)
[ "${VERBOSE}" != "no" ] && echo -n "Starting $DESC: "
if [ -d /proc/1/. ]
then
umask 027
start-stop-daemon --start --quiet \
--exec $DAEMON -- -r -c
else
$DAEMON -r -c
fi
[ "${VERBOSE}" != "no" ] && echo "$NAME."
;;
stop)
# stop may get called during bootup, so let it honor
# rcS VERBOSE setting
[ "${VERBOSE}" != "no" ] && echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --exec $DAEMON
if [ "$STOPPER" ] && [ "$(which savelog 2>/dev/null)" ] && \
[ -f /var/log/boot ] && [ -f /var/log/boot~ ]
then
cd /var/log
chgrp adm boot
savelog -p -c 5 boot > /dev/null 2>&1
mv boot.0 boot
mv boot~ boot.0
fi
[ "${VERBOSE}" != "no" ] && echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --exec $DAEMON
echo "$NAME."
;;
status)
status $DAEMON
exit $?
;;
*)
N=${0##*/}
N=${N#[SK]??}
echo "Usage: $N {start|stop|status|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
S29read-only-rootfs-hook
#!/bin/sh
. /etc/default/rcS
[ "$ROOTFS_READ_ONLY" = "no" ] && exit 0
is_on_read_only_partition () {
DIRECTORY=$1
dir=`readlink -f $DIRECTORY`
while true; do
if [ ! -d "$dir" ]; then
echo "ERROR: $dir is not a directory"
exit 1
else
for flag in `awk -v dir=$dir '{ if ($2 == dir) { print "FOUND"; split($4,FLAGS,",") } }; \
END { for (f in FLAGS) print FLAGS[f] }' < /proc/mounts`; do
[ "$flag" = "FOUND" ] && partition="read-write"
[ "$flag" = "ro" ] && { partition="read-only"; break; }
done
if [ "$dir" = "/" -o -n "$partition" ]; then
break
else
dir=`dirname $dir`
fi
fi
done
[ "$partition" = "read-only" ] && echo "yes" || echo "no"
}
if [ "$1" = "start" ] ; then
if [ `is_on_read_only_partition /var/lib` = "yes" ]; then
grep -q "tmpfs /var/volatile" /proc/mounts || mount /var/volatile
mkdir -p /var/volatile/lib
cp -a /var/lib/* /var/volatile/lib
mount --bind /var/volatile/lib /var/lib
fi
fi
S36udev-cache
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: udev-cache
# Required-Start: mountall
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: cache /dev to speedup the udev next boot
### END INIT INFO
export TZ=/etc/localtime
[ -r /proc/mounts ] || exit 1
[ -x /sbin/udevd ] || exit 1
[ -d /sys/class ] || exit 1
[ -f /etc/default/rcS ] && . /etc/default/rcS
DEVCACHE_TMP="/dev/shm/udev-cache-tmp.tar"
SYSCONF_CACHED="/etc/udev/cache.data"
SYSCONF_TMP="/dev/shm/udev.cache"
DEVCACHE_REGEN="/dev/shm/udev-regen" # create to request cache regen
# A list of files which are used as a criteria to judge whether the udev cache could be reused.
CMP_FILE_LIST="/proc/version /proc/cmdline /proc/devices"
[ -f /proc/atags ] && CMP_FILE_LIST="$CMP_FILE_LIST /proc/atags"
# List of files whose metadata (size/mtime/name) will be included in cached
# system state.
META_FILE_LIST="lib/udev/rules.d/* etc/udev/rules.d/*"
# Command to compute system configuration.
sysconf_cmd () {
cat -- $CMP_FILE_LIST
stat -c '%s %Y %n' -- $META_FILE_LIST | awk -F/ '{print $1 " " $NF;}'
}
[ -f /etc/default/udev-cache ] && . /etc/default/udev-cache
if [ "$ROOTFS_READ_ONLY" = "yes" ]; then
[ "$VERBOSE" != "no" ] && echo "udev-cache: read-only rootfs, skip generating udev-cache"
exit 0
fi
[ "$DEVCACHE" != "" ] || exit 0
[ "${VERBOSE}" == "no" ] || echo -n "udev-cache: checking for ${DEVCACHE_REGEN}... "
if ! [ -e "$DEVCACHE_REGEN" ]; then
[ "${VERBOSE}" == "no" ] || echo "not found."
exit 0
fi
[ "${VERBOSE}" == "no" ] || echo "found."
echo "Populating dev cache"
err_cleanup () {
echo "udev-cache: update failed!"
udevadm control --start-exec-queue
rm -f -- "$SYSCONF_TMP" "$DEVCACHE_TMP" "$DEVCACHE" "$SYSCONF_CACHED"
}
(
set -e
trap 'err_cleanup' EXIT
udevadm control --stop-exec-queue
sysconf_cmd > "$SYSCONF_TMP"
find /dev -xdev \( -type b -o -type c -o -type l \) | cut -c 2- \
| xargs tar cf "${DEVCACHE_TMP}"
gzip < "${DEVCACHE_TMP}" > "$DEVCACHE"
rm -f "${DEVCACHE_TMP}"
mv "$SYSCONF_TMP" "$SYSCONF_CACHED"
udevadm control --start-exec-queue
rm -f "$DEVCACHE_REGEN"
trap - EXIT
) &
exit 0
S37populate-volatile
#!/bin/sh
### BEGIN INIT INFO
# Provides: volatile
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: S
# Default-Stop:
# Short-Description: Populate the volatile filesystem
### END INIT INFO
# Get ROOT_DIR
DIRNAME=`dirname $0`
ROOT_DIR=`echo $DIRNAME | sed -ne 's:/etc/.*::p'`
[ -e ${ROOT_DIR}/etc/default/rcS ] && . ${ROOT_DIR}/etc/default/rcS
# When running populate-volatile.sh at rootfs time, disable cache.
[ -n "$ROOT_DIR" ] && VOLATILE_ENABLE_CACHE=no
# If rootfs is read-only, disable cache.
[ "$ROOTFS_READ_ONLY" = "yes" ] && VOLATILE_ENABLE_CACHE=no
CFGDIR="${ROOT_DIR}/etc/default/volatiles"
TMPROOT="${ROOT_DIR}/var/volatile/tmp"
COREDEF="00_core"
[ "${VERBOSE}" != "no" ] && echo "Populating volatile Filesystems."
create_file() {
EXEC="
touch \"$1\";
chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/tty0 2>&1;
chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 "
test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build
[ -e "$1" ] && {
[ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
} || {
if [ -z "$ROOT_DIR" ]; then
eval $EXEC &
else
# Creating some files at rootfs time may fail and should fail,
# but these failures should not be logged to make sure the do_rootfs
# process doesn't fail. This does no harm, as this script will
# run on target to set up the correct files and directories.
eval $EXEC > /dev/null 2>&1
fi
}
}
mk_dir() {
EXEC="
mkdir -p \"$1\";
chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/tty0 2>&1;
chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 "
test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build
[ -e "$1" ] && {
[ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
} || {
if [ -z "$ROOT_DIR" ]; then
eval $EXEC
else
# For the same reason with create_file(), failures should
# not be logged.
eval $EXEC > /dev/null 2>&1
fi
}
}
link_file() {
EXEC="
if [ -L \"$2\" ]; then
[ \"\$(readlink -f \"$2\")\" != \"\$(readlink -f \"$1\")\" ] && { rm -f \"$2\"; ln -sf \"$1\" \"$2\"; };
elif [ -d \"$2\" ]; then
if awk '\$2 == \"$2\" {exit 1}' /proc/mounts; then
cp -a $2/* $1 2>/dev/null;
cp -a $2/.[!.]* $1 2>/dev/null;
rm -rf \"$2\";
ln -sf \"$1\" \"$2\";
fi
else
ln -sf \"$1\" \"$2\";
fi
"
test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >> /etc/volatile.cache.build
if [ -z "$ROOT_DIR" ]; then
eval $EXEC &
else
# For the same reason with create_file(), failures should
# not be logged.
eval $EXEC > /dev/null 2>&1
fi
}
check_requirements() {
cleanup() {
rm "${TMP_INTERMED}"
rm "${TMP_DEFINED}"
rm "${TMP_COMBINED}"
}
CFGFILE="$1"
[ `basename "${CFGFILE}"` = "${COREDEF}" ] && return 0
TMP_INTERMED="${TMPROOT}/tmp.$$"
TMP_DEFINED="${TMPROOT}/tmpdefined.$$"
TMP_COMBINED="${TMPROOT}/tmpcombined.$$"
sed 's@\(^:\)*:.*@\1@' ${ROOT_DIR}/etc/passwd | sort | uniq > "${TMP_DEFINED}"
cat ${CFGFILE} | grep -v "^#" | cut -s -d " " -f 2 > "${TMP_INTERMED}"
cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}"
NR_DEFINED_USERS="`cat "${TMP_DEFINED}" | wc -l`"
NR_COMBINED_USERS="`cat "${TMP_COMBINED}" | wc -l`"
[ "${NR_DEFINED_USERS}" -ne "${NR_COMBINED_USERS}" ] && {
echo "Undefined users:"
diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>"
cleanup
return 1
}
sed 's@\(^:\)*:.*@\1@' ${ROOT_DIR}/etc/group | sort | uniq > "${TMP_DEFINED}"
cat ${CFGFILE} | grep -v "^#" | cut -s -d " " -f 3 > "${TMP_INTERMED}"
cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}"
NR_DEFINED_GROUPS="`cat "${TMP_DEFINED}" | wc -l`"
NR_COMBINED_GROUPS="`cat "${TMP_COMBINED}" | wc -l`"
[ "${NR_DEFINED_GROUPS}" -ne "${NR_COMBINED_GROUPS}" ] && {
echo "Undefined groups:"
diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>"
cleanup
return 1
}
# Add checks for required directories here
cleanup
return 0
}
apply_cfgfile() {
CFGFILE="$1"
check_requirements "${CFGFILE}" || {
echo "Skipping ${CFGFILE}"
return 1
}
cat ${CFGFILE} | grep -v "^#" | \
while read LINE; do
eval `echo "$LINE" | sed -n "s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\ \(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p"`
TNAME=${ROOT_DIR}${TNAME}
[ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-."
[ "${TTYPE}" = "l" ] && {
TSOURCE="$TLTARGET"
[ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}- pointing to -${TSOURCE}-."
link_file "${TSOURCE}" "${TNAME}"
continue
}
[ "${TTYPE}" = "b" ] && {
TSOURCE="$TLTARGET"
[ "${VERBOSE}" != "no" ] && echo "Creating mount-bind -${TNAME}- from -${TSOURCE}-."
mount --bind "${TSOURCE}" "${TNAME}"
EXEC="
mount --bind \"${TSOURCE}\" \"${TNAME}\""
test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build
continue
}
[ -L "${TNAME}" ] && {
[ "${VERBOSE}" != "no" ] && echo "Found link."
NEWNAME=`ls -l "${TNAME}" | sed -e 's/^.*-> \(.*\)$/\1/'`
echo ${NEWNAME} | grep -v "^/" >/dev/null && {
TNAME="`echo ${TNAME} | sed -e 's@\(.*\)/.*@\1@'`/${NEWNAME}"
[ "${VERBOSE}" != "no" ] && echo "Converted relative linktarget to absolute path -${TNAME}-."
} || {
TNAME="${NEWNAME}"
[ "${VERBOSE}" != "no" ] && echo "Using absolute link target -${TNAME}-."
}
}
case "${TTYPE}" in
"f") [ "${VERBOSE}" != "no" ] && echo "Creating file -${TNAME}-."
create_file "${TNAME}" &
;;
"d") [ "${VERBOSE}" != "no" ] && echo "Creating directory -${TNAME}-."
mk_dir "${TNAME}"
# Add check to see if there's an entry in fstab to mount.
;;
*) [ "${VERBOSE}" != "no" ] && echo "Invalid type -${TTYPE}-."
continue
;;
esac
done
return 0
}
clearcache=0
exec 9</proc/cmdline
while read line <&9
do
case "$line" in
*clearcache*) clearcache=1
;;
*) continue
;;
esac
done
exec 9>&-
if test -e ${ROOT_DIR}/etc/volatile.cache -a "$VOLATILE_ENABLE_CACHE" = "yes" -a "x$1" != "xupdate" -a "x$clearcache" = "x0"
then
sh ${ROOT_DIR}/etc/volatile.cache
else
rm -f ${ROOT_DIR}/etc/volatile.cache ${ROOT_DIR}/etc/volatile.cache.build
for file in `ls -1 "${CFGDIR}" | sort`; do
apply_cfgfile "${CFGDIR}/${file}"
done
[ -e ${ROOT_DIR}/etc/volatile.cache.build ] && sync && mv ${ROOT_DIR}/etc/volatile.cache.build ${ROOT_DIR}/etc/volatile.cache
fi
if [ -z "${ROOT_DIR}" ] && [ -f /etc/ld.so.cache ] && [ ! -f /var/run/ld.so.cache ]
then
ln -s /etc/ld.so.cache /var/run/ld.so.cache
fi
S38devpts
#!/bin/sh
### BEGIN INIT INFO
# Provides: devpts
# Required-Start: udev
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Mount /dev/pts file systems.
### END INIT INFO
. /etc/default/devpts
if grep -q devpts /proc/filesystems
then
#
# Create multiplexor device.
#
test -c /dev/ptmx || mknod -m 666 /dev/ptmx c 5 2
#
# Mount /dev/pts if needed.
#
if ! grep -q devpts /proc/mounts
then
mkdir -p /dev/pts
mount -t devpts devpts /dev/pts -ogid=${TTYGRP},mode=${TTYMODE}
fi
fi
S38dmesg
#!/bin/sh
### BEGIN INIT INFO
# Provides: dmesg
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop:
### END INIT INFO
if [ -f /var/log/dmesg ]; then
if [ -f /usr/sbin/logrotate ]; then
logrotate -f /etc/logrotate-dmesg.conf
else
mv -f /var/log/dmesg /var/log/dmesg.old
fi
fi
dmesg -s 131072 > /var/log/dmesg
S38urandom
#!/bin/sh
### BEGIN INIT INFO
# Provides: urandom
# Required-Start: $local_fs mountvirtfs
# Required-Stop: $local_fs
# Default-Start: S
# Default-Stop: 0 6
# Short-Description: Save and restore the random seed
# Description: Save the random seed on shutdown and restore it on boot,
# to ensure that the seed isn't predicable on startup
# (because the boot process is predictable)
### END INIT INFO
test -c /dev/urandom || exit 0
RANDOM_SEED_FILE=/var/lib/urandom/random-seed
. /etc/default/rcS
[ -f /etc/default/urandom ] && . /etc/default/urandom
case "$1" in
start|"")
test "$VERBOSE" != no && echo "Initializing random number generator..."
# Load and then save 512 bytes, which is the size of the entropy
# pool. Also load the current date, in case the seed file is
# empty.
( date +%s.%N; [ -f "$RANDOM_SEED_FILE" ] && cat "$RANDOM_SEED_FILE" ) \
>/dev/urandom
rm -f "$RANDOM_SEED_FILE"
umask 077
dd if=/dev/urandom of=$RANDOM_SEED_FILE count=1 \
>/dev/null 2>&1 || echo "urandom start: failed."
umask 022
;;
stop)
# Carry a random seed from shut-down to start-up;
# see documentation in linux/drivers/char/random.c
test "$VERBOSE" != no && echo "Saving random seed..."
umask 077
dd if=/dev/urandom of=$RANDOM_SEED_FILE count=1 \
>/dev/null 2>&1 || echo "urandom stop: failed."
;;
*)
echo "Usage: urandom {start|stop}" >&2
exit 1
;;
esac
exit 0
S39alsa-state
#! /bin/sh
#
# Copyright Matthias Hentges <devel@hentges.net> (c) 2007
# License: GPL (see http://www.gnu.org/licenses/gpl.txt for a copy of the license)
#
# Filename: alsa-state
# Date: 20070308 (YMD)
# source function library
. /etc/init.d/functions
asound_restore(){
echo "ALSA: Restoring mixer settings..."
if test -x /usr/sbin/alsactl -a -e /var/lib/alsa/asound.state
then
/usr/sbin/alsactl -f /var/lib/alsa/asound.state restore &
fi
}
asound_store(){
echo "ALSA: Storing mixer settings..."
if test -x /usr/sbin/alsactl
then
/usr/sbin/alsactl -f /var/lib/alsa/asound.state store
fi
}
case "$1" in
start) asound_restore ;;
stop) asound_store ;;
status)
status /usr/sbin/alsactl;
exit $?
;;
*)
echo "Usage: /etc/init.d/alsa-state {start|stop|status}"
exit 1
;;
esac
S39hostname
#!/bin/sh
### BEGIN INIT INFO
# Provides: hostname
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Set hostname based on /etc/hostname
### END INIT INFO
HOSTNAME=$(/bin/hostname)
hostname -b -F /etc/hostname 2> /dev/null
if [ $? -eq 0 ]; then
exit
fi
# Busybox hostname doesn't support -b so we need implement it on our own
if [ -f /etc/hostname ];then
hostname `cat /etc/hostname`
elif [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" -o ! -z "`echo $HOSTNAME | sed -n '/^[0-9]*\.[0-9].*/p'`" ] ; then
hostname localhost
fi
S55bootmisc
#!/bin/sh
### BEGIN INIT INFO
# Provides: bootmisc
# Required-Start: $local_fs mountvirtfs
# Required-Stop: $local_fs
# Default-Start: S
# Default-Stop: 0 6
# Short-Description: Misc and other.
### END INIT INFO
. /etc/default/rcS
#
# Put a nologin file in /etc to prevent people from logging in before
# system startup is complete.
#
if test "$DELAYLOGIN" = yes
then
echo "System bootup in progress - please wait" > /etc/nologin
cp /etc/nologin /etc/nologin.boot
fi
#
# Set pseudo-terminal access permissions.
#
if test -c /dev/ttyp0
then
chmod 666 /dev/tty[p-za-e][0-9a-f]
chown root:tty /dev/tty[p-za-e][0-9a-f]
fi
#
# Apply /proc settings if defined
#
SYSCTL_CONF="/etc/sysctl.conf"
if [ -f "${SYSCTL_CONF}" ]
then
if [ -x "/sbin/sysctl" ]
then
# busybox sysctl does not support -q
VERBOSE_REDIR="1>/dev/null"
if [ "${VERBOSE}" != "no" ]; then
VERBOSE_REDIR="1>&1"
fi
eval /sbin/sysctl -p "${SYSCTL_CONF}" $VERBOSE_REDIR
else
echo "To have ${SYSCTL_CONF} applied during boot, install package <procps>."
fi
fi
#
# Update /etc/motd.
#
if test "$EDITMOTD" != no
then
uname -a > /etc/motd.tmp
sed 1d /etc/motd >> /etc/motd.tmp
mv /etc/motd.tmp /etc/motd
fi
#
# This is as good a place as any for a sanity check
#
# Set the system clock from hardware clock
# If the timestamp is more recent than the current time,
# use the timestamp instead.
test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh start
if test -e /etc/timestamp
then
SYSTEMDATE=`date -u +%4Y%2m%2d%2H%2M%2S`
read TIMESTAMP < /etc/timestamp
if [ ${TIMESTAMP} -gt $SYSTEMDATE ]; then
# format the timestamp as date expects it (2m2d2H2M4Y.2S)
TS_YR=${TIMESTAMP%??????????}
TS_SEC=${TIMESTAMP#????????????}
TS_FIRST12=${TIMESTAMP%??}
TS_MIDDLE8=${TS_FIRST12#????}
date -u ${TS_MIDDLE8}${TS_YR}.${TS_SEC}
test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh stop
fi
fi
exit 0
(3) rc5.d 目录文件
S01networking
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: networking
# Required-Start: mountvirtfs $local_fs
# Required-Stop: $local_fs
# Should-Start: ifupdown
# Should-Stop: ifupdown
# Default-Start: S
# Default-Stop: 0 6
# Short-Description: Raise network interfaces.
### END INIT INFO
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
[ -x /sbin/ifup ] || exit 0
check_network_file_systems() {
[ -e /proc/mounts ] || return 0
if [ -e /etc/iscsi/iscsi.initramfs ]; then
echo "not deconfiguring network interfaces: iSCSI root is mounted."
exit 0
fi
exec 9<&0 < /proc/mounts
while read DEV MTPT FSTYPE REST; do
case $DEV in
/dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
echo "not deconfiguring network interfaces: network devices still mounted."
exit 0
;;
esac
case $FSTYPE in
nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|pvfs|pvfs2|fuse.httpfs|fuse.curlftpfs)
echo "not deconfiguring network interfaces: network file systems still mounted."
exit 0
;;
esac
done
exec 0<&9 9<&-
}
check_network_swap() {
[ -e /proc/swaps ] || return 0
exec 9<&0 < /proc/swaps
while read DEV MTPT FSTYPE REST; do
case $DEV in
/dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
echo "not deconfiguring network interfaces: network swap still mounted."
exit 0
;;
esac
done
exec 0<&9 9<&-
}
case "$1" in
start)
echo -n "Configuring network interfaces... "
sysctl -e -p /etc/sysctl.conf >/dev/null 2>&1
ifup -a
echo "done."
;;
stop)
check_network_file_systems
check_network_swap
echo -n "Deconfiguring network interfaces... "
ifdown -a
echo "done."
;;
force-reload|restart)
echo "Running $0 $1 is deprecated because it may not enable again some interfaces"
echo "Reconfiguring network interfaces... "
ifdown -a || true
ifup -a
echo "done."
;;
*)
echo "Usage: /etc/init.d/networking {start|stop}"
exit 1
;;
esac
exit 0
S01rsyslogd
#!/bin/sh
DAEMON="rsyslogd"
PIDFILE="/var/run/$DAEMON.pid"
RSYSLOGD_ARGS=""
# shellcheck source=/dev/null
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
start() {
printf 'Starting %s: ' "$DAEMON"
# shellcheck disable=SC2086 # we need the word splitting
start-stop-daemon -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \
-- $RSYSLOGD_ARGS
status=$?
if [ "$status" -eq 0 ]; then
echo "OK"
else
echo "FAIL"
fi
return "$status"
}
stop() {
printf 'Stopping %s: ' "$DAEMON"
start-stop-daemon -K -q -p "$PIDFILE"
status=$?
if [ "$status" -eq 0 ]; then
echo "OK"
else
echo "FAIL"
fi
return "$status"
}
restart() {
stop
sleep 1
start
}
case "$1" in
start|stop|restart)
"$1";;
reload)
# Restart, since there is no true "reload" feature (does not
# reconfigure/restart on SIGHUP, just closes all open files).
restart;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
S01xserver-nodm
hawkbot@ubuntu:rc5.d$ cat S01xserver-nodm
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: xserver
# Required-Start: $local_fs $remote_fs dbus
# Required-Stop: $local_fs $remote_fs
# Default-Start: 5
# Default-Stop: 0 1 2 3 6
### END INIT INFO
. /etc/init.d/functions
for x in $(cat /proc/cmdline); do
case $x in
x11=false)
echo "X Server disabled"
exit 0;
;;
esac
done
case "$1" in
start)
# We don't want this script to block the rest of the boot process
if [ "$2" != "background" ]; then
$0 $1 background &
else
# work around from /etc/X11/Xinit
export USER=root
export HOME=/home/root
if [ ! -d $HOME ] && [ -d /root ]; then
HOME=/root
fi
. /etc/profile
echo "Starting Xserver"
. /etc/X11/xserver-common
#xinit /etc/X11/Xsession -- `which $XSERVER` $ARGS >/var/log/Xsession.log 2>&1
fi
;;
stop)
echo "Stopping XServer"
killproc xinit
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 { start | stop | restart }"
;;
esac
exit 0
S02dbus-1
#! /bin/sh
### BEGIN INIT INFO
# Provides: dbus
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 1
# Short-Description: D-Bus systemwide message bus
# Description: D-Bus is a simple interprocess messaging system, used
# for sending messages between applications.
### END INIT INFO
#
# -*- coding: utf-8 -*-
# Debian init.d script for D-BUS
# Copyright © 2003 Colin Walters <walters@debian.org>
# set -e
# Source function library.
. /etc/init.d/functions
DAEMON=/usr/bin/dbus-daemon
NAME=dbus
DAEMONUSER=messagebus # must match /etc/dbus-1/system.conf
PIDFILE=/var/run/messagebus.pid # must match /etc/dbus-1/system.conf
UUIDDIR=/var/lib/dbus
DESC="system message bus"
EVENTDIR=/etc/dbus-1/event.d
test -x $DAEMON || exit 0
# Source defaults file; edit that file to configure this script.
ENABLED=1
PARAMS=""
if [ -e /etc/default/dbus ]; then
. /etc/default/dbus
fi
test "$ENABLED" != "0" || exit 0
start_it_up()
{
mkdir -p "`dirname $PIDFILE`"
if [ -e $PIDFILE ]; then
PIDDIR=/proc/$(cat $PIDFILE)
if [ -d ${PIDDIR} -a "$(readlink -f ${PIDDIR}/exe)" = "${DAEMON}" ]; then
echo "$DESC already started; not starting."
else
echo "Removing stale PID file $PIDFILE."
rm -f $PIDFILE
fi
fi
if [ ! -d $UUIDDIR ]; then
mkdir -p $UUIDDIR
chown $DAEMONUSER $UUIDDIR
chgrp $DAEMONUSER $UUIDDIR
fi
dbus-uuidgen --ensure
echo -n "Starting $DESC: "
start-stop-daemon -o --start --quiet --pidfile $PIDFILE \
--user $DAEMONUSER --exec $DAEMON -- --system $PARAMS
echo "$NAME."
if [ -d $EVENTDIR ]; then
run-parts --arg=start $EVENTDIR
fi
}
shut_it_down()
{
if [ -d $EVENTDIR ]; then
# TODO: --reverse when busybox supports it
run-parts --arg=stop $EVENTDIR
fi
echo -n "Stopping $DESC: "
start-stop-daemon -o --stop --quiet --pidfile $PIDFILE \
--user $DAEMONUSER
# We no longer include these arguments so that start-stop-daemon
# can do its job even given that we may have been upgraded.
# We rely on the pidfile being sanely managed
# --exec $DAEMON -- --system $PARAMS
echo "$NAME."
rm -f $PIDFILE
}
reload_it()
{
echo -n "Reloading $DESC config: "
dbus-send --print-reply --system --type=method_call \
--dest=org.freedesktop.DBus \
/ org.freedesktop.DBus.ReloadConfig > /dev/null
# hopefully this is enough time for dbus to reload it's config file.
echo "done."
}
case "$1" in
start)
start_it_up
;;
stop)
shut_it_down
;;
status)
status $DAEMON
exit $?
;;
reload|force-reload)
reload_it
;;
restart)
shut_it_down
sleep 1
start_it_up
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|status|restart|reload|force-reload}" >&2
exit 1
;;
esac
exit 0
S05connman
#!/bin/sh
DAEMON=/usr/sbin/connmand
PIDFILE=/var/run/connmand.pid
DESC="Connection Manager"
if [ -f /etc/default/connman ] ; then
. /etc/default/connman
fi
set -e
nfsroot=0
exec 9<&0 < /proc/mounts
while read dev mtpt fstype rest; do
if test $mtpt = "/" ; then
case $fstype in
nfs | nfs4)
nfsroot=1
break
;;
*)
;;
esac
fi
done
do_start() {
EXTRA_PARAM=""
if test $nfsroot -eq 1 ; then
NET_DEVS=`cat /proc/net/dev | sed -ne 's/^\([a-zA-Z0-9 ]*\):.*$/\1/p'`
NET_ADDR=`cat /proc/cmdline | sed -ne 's/^.*ip=\([^ :]*\).*$/\1/p'`
if [ -z "$NET_ADDR" ]; then
NET_ADDR=`cat /proc/cmdline | sed -ne 's/^.*eth[0-9]:\([^ :]*\).*$/\1/p'`
fi
if [ ! -z "$NET_ADDR" ]; then
if [ "$NET_ADDR" = dhcp ]; then
ethn=`dmesg | grep "device=eth" | sed -e "s/^.*\(eth[0-9]\)\(.*\)/\1/"`
if [ ! -z "$ethn" ]; then
EXTRA_PARAM="-I $ethn"
fi
else
for i in $NET_DEVS; do
ADDR=`ifconfig $i | sed 's/addr://g' | sed -ne 's/^.*inet \([0-9.]*\) .*$/\1/p'`
if [ "$NET_ADDR" = "$ADDR" ]; then
EXTRA_PARAM="-I $i"
break
fi
done
fi
fi
fi
if [ -f /usr/share/connman/wired-setup ] ; then
. /usr/share/connman/wired-setup
fi
$DAEMON $EXTRA_PARAM
}
do_stop() {
start-stop-daemon --stop --name connmand --quiet
}
case "$1" in
start)
echo "Starting $DESC"
do_start
;;
stop)
echo "Stopping $DESC"
do_stop
;;
restart|force-reload)
echo "Restarting $DESC"
do_stop
sleep 1
do_start
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
S10dropbear
#!/bin/sh
### BEGIN INIT INFO
# Provides: sshd
# Required-Start: $remote_fs $syslog $networking
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 1
# Short-Description: Dropbear Secure Shell server
### END INIT INFO
#
# Do not configure this file. Edit /etc/default/dropbear instead!
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/dropbear
NAME=dropbear
DESC="Dropbear SSH server"
PIDFILE=/var/run/dropbear.pid
DROPBEAR_PORT=22
DROPBEAR_EXTRA_ARGS=
NO_START=0
set -e
test ! -r /etc/default/dropbear || . /etc/default/dropbear
test "$NO_START" = "0" || exit 0
test -x "$DAEMON" || exit 0
test ! -h /var/service/dropbear || exit 0
readonly_rootfs=0
for flag in `awk '{ if ($2 == "/") { split($4,FLAGS,",") } }; END { for (f in FLAGS) print FLAGS[f] }' </proc/mounts`; do
case $flag in
ro)
readonly_rootfs=1
;;
esac
done
if [ $readonly_rootfs = "1" ]; then
mkdir -p /var/lib/dropbear
DROPBEAR_RSAKEY_DEFAULT="/var/lib/dropbear/dropbear_rsa_host_key"
DROPBEAR_DSSKEY_DEFAULT="/var/lib/dropbear/dropbear_dss_host_key"
else
DROPBEAR_RSAKEY_DEFAULT="/etc/dropbear/dropbear_rsa_host_key"
DROPBEAR_DSSKEY_DEFAULT="/etc/dropbear/dropbear_dss_host_key"
fi
test -z "$DROPBEAR_BANNER" || \
DROPBEAR_EXTRA_ARGS="$DROPBEAR_EXTRA_ARGS -b $DROPBEAR_BANNER"
test -n "$DROPBEAR_RSAKEY" || \
DROPBEAR_RSAKEY=$DROPBEAR_RSAKEY_DEFAULT
test -n "$DROPBEAR_DSSKEY" || \
DROPBEAR_DSSKEY=$DROPBEAR_DSSKEY_DEFAULT
test -n "$DROPBEAR_KEYTYPES" || \
DROPBEAR_KEYTYPES="rsa"
gen_keys() {
for t in $DROPBEAR_KEYTYPES; do
case $t in
rsa)
if [ -f "$DROPBEAR_RSAKEY" -a ! -s "$DROPBEAR_RSAKEY" ]; then
rm $DROPBEAR_RSAKEY || true
fi
test -f $DROPBEAR_RSAKEY || dropbearkey -t rsa -f $DROPBEAR_RSAKEY
;;
dsa)
if [ -f "$DROPBEAR_DSSKEY" -a ! -s "$DROPBEAR_DSSKEY" ]; then
rm $DROPBEAR_DSSKEY || true
fi
test -f $DROPBEAR_DSSKEY || dropbearkey -t dss -f $DROPBEAR_DSSKEY
;;
esac
done
}
case "$1" in
start)
echo -n "Starting $DESC: "
gen_keys
KEY_ARGS=""
test -f $DROPBEAR_DSSKEY && KEY_ARGS="$KEY_ARGS -d $DROPBEAR_DSSKEY"
test -f $DROPBEAR_RSAKEY && KEY_ARGS="$KEY_ARGS -r $DROPBEAR_RSAKEY"
start-stop-daemon -S -p $PIDFILE \
-x "$DAEMON" -- $KEY_ARGS \
-p "$DROPBEAR_PORT" $DROPBEAR_EXTRA_ARGS
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon -K -x "$DAEMON" -p $PIDFILE
echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon -K -x "$DAEMON" -p $PIDFILE
sleep 1
KEY_ARGS=""
test -f $DROPBEAR_DSSKEY && KEY_ARGS="$KEY_ARGS -d $DROPBEAR_DSSKEY"
test -f $DROPBEAR_RSAKEY && KEY_ARGS="$KEY_ARGS -r $DROPBEAR_RSAKEY"
start-stop-daemon -S -p $PIDFILE \
-x "$DAEMON" -- $KEY_ARGS \
-p "$DROPBEAR_PORT" $DROPBEAR_EXTRA_ARGS
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
S12rpcbind
#!/bin/sh
#
# start/stop rpcbind daemon.
### BEGIN INIT INFO
# Provides: rpcbind
# Required-Start: $network
# Required-Stop: $network
# Default-Start: S 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: RPC portmapper replacement
# Description: rpcbind is a server that converts RPC (Remote
# Procedure Call) program numbers into DARPA
# protocol port numbers. It must be running in
# order to make RPC calls. Services that use
# RPC include NFS and NIS.
### END INIT INFO
# Source function library.
. /etc/init.d/functions
test -f /usr/sbin/rpcbind || exit 0
OPTIONS=""
if [ -f /etc/default/rpcbind ]
then
. /etc/default/rpcbind
elif [ -f /etc/rpcbind.conf ]
then
. /etc/rpcbind.conf
fi
start ()
{
echo -n "Starting rpcbind daemon..."
if pidof /usr/sbin/rpcbind >/dev/null; then
echo "already running."
exit 0
fi
start-stop-daemon --start --quiet --exec /usr/sbin/rpcbind -- "$@"
if [ $? -eq 0 ]; then
echo "done."
else
echo "failed."
fi
}
stop ()
{
echo "Stopping rpcbind daemon..."
if ! pidof /usr/sbin/rpcbind >/dev/null; then
echo "not running."
return 0
fi
start-stop-daemon --stop --quiet --exec /usr/sbin/rpcbind
if [ $? -eq 0 ]; then
echo "done."
else
echo "failed."
fi
}
case "$1" in
start)
start $OPTIONS
;;
stop)
stop
;;
force-reload)
stop
start $OPTIONS
;;
restart)
stop
start $OPTIONS
;;
status)
status /usr/sbin/rpcbind
;;
*)
echo "Usage: /etc/init.d/rpcbind {start|stop|force-reload|restart|status}"
exit 1
;;
esac
exit $?
S15mountnfs
#!/bin/sh
### BEGIN INIT INFO
# Provides: mountnfs
# Required-Start: $local_fs $network $rpcbind
# Required-Stop:
# Default-Start: S
# Default-Stop:
### END INIT INFO
#
# Run in a subshell because of I/O redirection.
#
test -f /etc/fstab && (
#
# Read through fstab line by line. If it is NFS, set the flag
# for mounting NFS filesystems. If any NFS partition is found and it
# not mounted with the nolock option, we start the rpcbind.
#
rpcbind=no
mount_nfs=no
mount_smb=no
mount_ncp=no
mount_cifs=no
while read device mountpt fstype options
do
case "$device" in
""|\#*)
continue
;;
esac
case "$options" in
*noauto*)
continue
;;
esac
if test "$fstype" = nfs
then
mount_nfs=yes
case "$options" in
*nolock*)
;;
*)
rpcbind=yes
;;
esac
fi
if test "$fstype" = smbfs
then
mount_smb=yes
fi
if test "$fstype" = ncpfs
then
mount_ncp=yes
fi
if test "$fstype" = cifs
then
mount_cifs=yes
fi
done
exec 0>&1
if test "$rpcbind" = yes
then
if test -x /usr/sbin/rpcbind
then
echo -n "Starting rpcbind... "
start-stop-daemon --start --quiet --exec /usr/sbin/rpcbind
sleep 2
fi
fi
if test "$mount_nfs" = yes || test "$mount_smb" = yes || test "$mount_ncp" = yes || test "$mount_cifs" = yes
then
echo "Mounting remote filesystems..."
test "$mount_nfs" = yes && mount -a -t nfs
test "$mount_smb" = yes && mount -a -t smbfs
test "$mount_ncp" = yes && mount -a -t ncpfs
test "$mount_cifs" = yes && mount -a -t cifs
fi
) < /etc/fstab
exit 0
S19nfscommon
#!/bin/sh
### BEGIN INIT INFO
# Provides: nfs-common
# Required-Start: $portmap hwclock
# Required-Stop: $portmap hwclock
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: NFS support for both client and server
# Description: NFS is a popular protocol for file sharing across
# TCP/IP networks. This service provides various
# support functions for NFS mounts.
### END INIT INFO
#
# Startup script for nfs-utils
#
#
# Location of executables:
# Source function library.
. /etc/init.d/functions
test -x "$NFS_STATD" || NFS_STATD=/usr/sbin/rpc.statd
test -z "$STATD_PID" && STATD_PID=/var/run/rpc.statd.pid
#
# The default state directory is /var/lib/nfs
test -n "$NFS_STATEDIR" || NFS_STATEDIR=/var/lib/nfs
#
#----------------------------------------------------------------------
# Startup and shutdown functions.
# Actual startup/shutdown is at the end of this file.
start_statd(){
echo -n "starting statd: "
start-stop-daemon --start --exec "$NFS_STATD" --pidfile "$STATD_PID"
echo done
}
stop_statd(){
echo -n 'stopping statd: '
start-stop-daemon --stop --quiet --signal 1 --pidfile "$STATD_PID"
echo done
}
#----------------------------------------------------------------------
#
# supported options:
# start
# stop
# restart: stops and starts mountd
#FIXME: need to create the /var/lib/nfs/... directories
case "$1" in
start)
start_statd;;
stop)
stop_statd;;
status)
status $NFS_STATD
exit $?;;
restart)
$0 stop
$0 start;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1;;
esac
S20apmd
#!/bin/sh
### BEGIN INIT INFO
# Provides: apmd
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Advanced Power Management daemon
### END INIT INFO
# Source function library.
. /etc/init.d/functions
PATH=/bin:/usr/bin:/sbin:/usr/sbin
[ -f /etc/default/rcS ] && . /etc/default/rcS
[ -f /etc/default/apmd ] && . /etc/default/apmd
case "$1" in
start)
echo -n "Starting advanced power management daemon: "
start-stop-daemon -S -x /usr/sbin/apmd -- \
-P /etc/apm/apmd_proxy $APMD
if [ $? = 0 ]; then
echo "apmd."
else
echo "(failed.)"
fi
;;
stop)
echo -n "Stopping advanced power management daemon: "
start-stop-daemon -K \
-x /usr/sbin/apmd
echo "apmd."
;;
status)
status /usr/sbin/apmd;
exit $?
;;
restart|force-reload)
$0 stop
$0 start
exit
;;
*)
echo "Usage: /etc/init.d/apmd {start|stop|status|restart|force-reload}"
exit 1
;;
esac
exit 0
S20atd
#!/bin/sh
#
# Starts at daemon
#
umask 077
# Source function library.
. /etc/init.d/functions
start() {
echo -n "Starting atd: "
start-stop-daemon --start --quiet --pidfile /var/run/atd.pid --background --exec /usr/sbin/atd -- -f
echo "OK"
}
stop() {
echo -n "Stopping atd: "
start-stop-daemon --stop --quiet --pidfile /var/run/atd.pid
echo "OK"
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
status)
status /usr/sbin/atd
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit $?
S20hwclock
#!/bin/sh
### BEGIN INIT INFO
# Provides: hwclock
# Required-Start:
# Required-Stop: $local_fs
# Default-Start: S
# Default-Stop: 0 6
# Short-Description: Set system clock
# Description: Set system clock to hardware clock, according to the UTC
# setting in /etc/default/rcS (see also rcS(5)).
### END INIT INFO
#
# WARNING: If your hardware clock is not in UTC/GMT, this script
# must know the local time zone. This information is
# stored in /etc/localtime. This might be a problem if
# your /etc/localtime is a symlink to something in
# /usr/share/zoneinfo AND /usr isn't in the root
# partition! The workaround is to define TZ either
# in /etc/default/rcS, or in the proper place below.
[ ! -x /sbin/hwclock ] && exit 0
[ -f /etc/default/rcS ] && . /etc/default/rcS
[ "$UTC" = "yes" ] && tz="--utc" || tz="--localtime"
case "$1" in
start)
if [ "$VERBOSE" != no ]
then
echo "System time was `date`."
echo "Setting the System Clock using the Hardware Clock as reference..."
fi
if [ "$HWCLOCKACCESS" != no ]
then
if [ -z "$TZ" ]
then
hwclock $tz --hctosys
else
TZ="$TZ" hwclock $tz --hctosys
fi
fi
if [ "$VERBOSE" != no ]
then
echo "System Clock set. System local time is now `date`."
fi
;;
stop|restart|reload|force-reload)
#
# Updates the Hardware Clock with the System Clock time.
# This will *override* any changes made to the Hardware Clock.
#
# WARNING: If you disable this, any changes to the system
# clock will not be carried across reboots.
#
if [ "$VERBOSE" != no ]
then
echo "Saving the System Clock time to the Hardware Clock..."
fi
if [ "$HWCLOCKACCESS" != no ]
then
hwclock $tz --systohc
fi
if [ "$VERBOSE" != no ]
then
echo "Hardware Clock updated to `date`."
fi
exit 0
;;
show)
if [ "$HWCLOCKACCESS" != no ]
then
hwclock $tz --show
fi
;;
*)
echo "Usage: hwclock.sh {start|stop|show|reload|restart}" >&2
echo " start sets kernel (system) clock from hardware (RTC) clock" >&2
echo " stop and reload set hardware (RTC) clock from kernel (system) clock" >&2
exit 1
;;
esac
S20nfsserver
#!/bin/sh
### BEGIN INIT INFO
# Provides: nfs-kernel-server
# Required-Start: $remote_fs nfs-common $portmap hwclock
# Required-Stop: $remote_fs nfs-common $portmap hwclock
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Kernel NFS server support
# Description: NFS is a popular protocol for file sharing across
# TCP/IP networks. This service provides NFS server
# functionality, which is configured via the
# /etc/exports file.
### END INIT INFO
#
# Startup script for nfs-utils
#
# Source function library.
. /etc/init.d/functions
#
# The environment variable NFS_SERVERS may be set in /etc/default/nfsd
# Other control variables may be overridden here too
test -r /etc/default/nfsd && . /etc/default/nfsd
#
# Location of executables:
test -x "$NFS_MOUNTD" || NFS_MOUNTD=/usr/sbin/rpc.mountd
test -x "$NFS_NFSD" || NFS_NFSD=/usr/sbin/rpc.nfsd
#
# The user mode program must also exist (it just starts the kernel
# threads using the kernel module code).
test -x "$NFS_MOUNTD" || exit 0
test -x "$NFS_NFSD" || exit 0
#
# Default is 8 threads, value is settable between 1 and the truely
# ridiculous 99
test "$NFS_SERVERS" != "" && test "$NFS_SERVERS" -gt 0 && test "$NFS_SERVERS" -lt 100 || NFS_SERVERS=8
#
#----------------------------------------------------------------------
# Startup and shutdown functions.
# Actual startup/shutdown is at the end of this file.
#mountd
start_mountd(){
echo -n 'starting mountd: '
start-stop-daemon --start --exec "$NFS_MOUNTD" -- "-f /etc/exports $@"
echo done
}
stop_mountd(){
echo -n 'stopping mountd: '
start-stop-daemon --stop --quiet --exec "$NFS_MOUNTD"
echo done
}
#
#nfsd
start_nfsd(){
modprobe -q nfsd
grep -q nfsd /proc/filesystems || {
echo NFS daemon support not enabled in kernel
exit 1
}
grep -q nfsd /proc/mounts || mount -t nfsd nfsd /proc/fs/nfsd
grep -q nfsd /proc/mounts || {
echo nfsd filesystem could not be mounted at /proc/fs/nfsd
exit 1
}
echo -n "starting $1 nfsd kernel threads: "
start-stop-daemon --start --exec "$NFS_NFSD" -- "$@"
echo done
}
delay_nfsd(){
for delay in 0 1 2 3 4 5 6 7 8 9
do
if pidof nfsd >/dev/null
then
echo -n .
sleep 1
else
return 0
fi
done
return 1
}
stop_nfsd(){
# WARNING: this kills any process with the executable
# name 'nfsd'.
echo -n 'stopping nfsd: '
start-stop-daemon --stop --quiet --signal 1 --name nfsd
if delay_nfsd || {
echo failed
echo ' using signal 9: '
start-stop-daemon --stop --quiet --signal 9 --name nfsd
delay_nfsd
}
then
echo done
else
echo failed
fi
}
#----------------------------------------------------------------------
#
# supported options:
# start
# stop
# reload: reloads the exports file
# restart: stops and starts mountd
#FIXME: need to create the /var/lib/nfs/... directories
case "$1" in
start)
exportfs -r
start_nfsd "$NFS_SERVERS"
start_mountd
test -r /etc/exports && exportfs -a;;
stop) exportfs -ua
stop_mountd
stop_nfsd;;
status)
status /usr/sbin/rpc.mountd
RETVAL=$?
status nfsd
rval=$?
[ $RETVAL -eq 0 ] && exit $rval
exit $RETVAL;;
reload) test -r /etc/exports && exportfs -r;;
restart)
$0 stop
$0 start;;
*) echo "Usage: $0 {start|stop|status|reload|restart}"
exit 1;;
esac
S21avahi-daemon
#!/bin/sh
### BEGIN INIT INFO
# Provides: avahi
# Required-Start: $remote_fs dbus
# Required-Stop: $remote_fs dbus
# Should-Start: $syslog
# Should-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Avahi mDNS/DNS-SD Daemon
# Description: Zeroconf daemon for configuring your network
# automatically
### END INIT INFO
#
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# avahi is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with avahi; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
#
# avahi avahi daemon
# Daemon for ZeroConf
#
# Authors: <sebastien.estienne@gmail.com>
#
if [ -f /lib/lsb/init-functions ]
then
. /lib/lsb/init-functions
else
# int log_begin_message (char *message)
log_begin_msg () {
if [ -z "$1" ]; then
return 1
fi
echo " * $@"
}
# int log_end_message (int exitstatus)
log_end_msg () {
# If no arguments were passed, return
[ -z "$1" ] && return 1
# Only do the fancy stuff if we have an appropriate terminal
# and if /usr is already mounted
TPUT=/usr/bin/tput
EXPR=/usr/bin/expr
if [ -x $TPUT ] && [ -x $EXPR ] && $TPUT hpa 60 >/dev/null 2>&1; then
COLS=`$TPUT cols`
if [ -n "$COLS" ]; then
COL=`$EXPR $COLS - 7`
else
COL=73
fi
UP=`$TPUT cuu1`
END=`$TPUT hpa $COL`
START=`$TPUT hpa 0`
RED=`$TPUT setaf 1`
NORMAL=`$TPUT op`
if [ $1 -eq 0 ]; then
echo "$UP$END[ ok ]"
else
echo -e "$UP$START $RED*$NORMAL$END[${RED}fail${NORMAL}]"
fi
else
if [ $1 -eq 0 ]; then
echo " ...done."
else
echo " ...fail!"
fi
fi
return $1
}
log_warning_msg () {
if log_use_fancy_output; then
YELLOW=`$TPUT setaf 3`
NORMAL=`$TPUT op`
echo "$YELLOW*$NORMAL $@"
else
echo "$@"
fi
}
fi
#set -e
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DESC="Avahi mDNS/DNS-SD Daemon"
NAME="avahi-daemon"
DAEMON="/usr/sbin/$NAME"
SCRIPTNAME=/etc/init.d/$NAME
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
# don't start if /etc/default/avahi-daemon says so.
AVAHI_DAEMON_START=1
test -f /etc/default/avahi-daemon && . /etc/default/avahi-daemon
if [ "$AVAHI_DAEMON_START" != "1" -a "$1" != "stop" ]; then
log_warning_msg "Not starting $DESC $NAME, disabled via /etc/default/$NAME"
exit 0
fi
#
# Function that starts the daemon/service.
#
d_start() {
modprobe capability >/dev/null 2>&1 || true
$DAEMON -c && return 0
if [ -s /etc/localtime ]; then
if [ ! -d /etc/avahi/etc ]; then
mkdir -p /etc/avahi/etc >/dev/null 2>&1
fi
cp -fp /etc/localtime /etc/avahi/etc >/dev/null 2>&1
fi;
$DAEMON -D
}
#
# Function that stops the daemon/service.
#
d_stop() {
$DAEMON -c && $DAEMON -k
}
#
# Function that reload the config file for the daemon/service.
#
d_reload() {
$DAEMON -c && $DAEMON -r
}
#
# Function that check the status of the daemon/service.
#
d_status() {
$DAEMON -c
status=$?
if [ $status = 0 ]; then
echo "$DESC is running"
return 0
else
echo "$DESC is not running"
return 3
fi
}
case "$1" in
start)
log_begin_msg "Starting $DESC: $NAME"
d_start
log_end_msg $?
;;
stop)
log_begin_msg "Stopping $DESC: $NAME"
d_stop
log_end_msg $?
;;
reload)
log_begin_msg "Reloading services for $DESC: $NAME"
d_reload
log_end_msg $?
;;
restart|force-reload)
log_begin_msg "Restarting $DESC: $NAME"
$DAEMON -c && d_stop
d_start
log_end_msg $?
;;
status)
d_status
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|reload|status}" >&2
exit 1
;;
esac
exit $?
S22ofono
#!/bin/sh
DAEMON=/usr/sbin/ofonod
PIDFILE=/var/run/ofonod.pid
DESC="Telephony daemon"
if [ -f /etc/default/ofono ] ; then
. /etc/default/ofono
fi
set -e
do_start() {
$DAEMON
}
do_stop() {
start-stop-daemon --stop --name ofonod --quiet
}
case "$1" in
start)
echo "Starting $DESC"
do_start
;;
stop)
echo "Stopping $DESC"
do_stop
;;
restart|force-reload)
echo "Restarting $DESC"
do_stop
sleep 1
do_start
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
S64neard
#!/bin/sh
#
# start/stop neard daemon.
### BEGIN INIT INFO
# Provides: neard
# Required-Start: $network
# Required-Stop: $network
# Default-Start: S 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: NFC daemon
# Description: neard is a daemon used to enable NFC features
### END INIT INFO
DAEMON=/usr/libexec/nfc/neard
PIDFILE=/var/run/neard.pid
DESC="Linux NFC daemon"
if [ -f /etc/default/neard ] ; then
. /etc/default/neard
fi
set -e
do_start() {
$DAEMON
}
do_stop() {
start-stop-daemon --stop --name neard --quiet
}
case "$1" in
start)
echo "Starting $DESC"
do_start
;;
stop)
echo "Stopping $DESC"
do_stop
;;
restart|force-reload)
echo "Restarting $DESC"
do_stop
sleep 1
do_start
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
S90crond
#!/bin/sh
### BEGIN INIT INFO
# Provides: crond crontab
# Default-Start: 2345
# Default-Stop: 016
# Short-Description: run cron daemon
# Description: cron is a standard UNIX program that runs user-specified
# programs at periodic scheduled times. vixie cron adds a
# number of features to the basic UNIX cron, including better
# security and more powerful configuration options.
### END INIT INFO
CROND=/usr/sbin/crond
CONFIG=/etc/sysconfig/crond
[ -f $CONFIG ] || exit 1
[ -x $CROND ] || exit 1
. $CONFIG
# Source function library.
. /etc/init.d/functions
case "$1" in
start)
echo -n "Starting crond: "
start-stop-daemon --start --quiet --exec $CROND -- $CRONDARGS
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
echo "OK"
else
echo "FAIL"
fi
;;
stop)
echo -n "Stopping crond: "
start-stop-daemon --stop --quiet --pidfile /var/run/crond.pid
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
echo "OK"
else
echo "FAIL"
fi
;;
status)
status crond
exit $?
;;
restart)
$0 stop && sleep 1 && $0 start
;;
*)
echo "Usage: /etc/init.d/crond {start|stop|status|restart}"
exit 1
esac
exit 0
S99rc.local
#! /bin/sh
### BEGIN INIT INFO
# Provides: rc.local
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Run /etc/rc.local if it exist
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin
do_start() {
if [ -x /etc/rc.local ]; then
echo -n "Running local boot scripts (/etc/rc.local)"
/etc/rc.local
[ $? = 0 ] && echo "." || echo "error"
return $ES
fi
}
case "$1" in
start)
do_start
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
esac
S99rmnologin
#!/bin/sh
### BEGIN INIT INFO
# Provides: rmnologin
# Required-Start: $remote_fs $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Remove /etc/nologin at boot
# Description: This script removes the /etc/nologin file as the
# last step in the boot process, if DELAYLOGIN=yes.
# If DELAYLOGIN=no, /etc/nologin was not created by
# bootmisc earlier in the boot process.
### END INIT INFO
if test -f /etc/nologin.boot
then
rm -f /etc/nologin /etc/nologin.boot
fi
exit 0
S99stop-bootlogd
#! /bin/sh
### BEGIN INIT INFO
# Provides: bootlogd
# Required-Start:
# Required-Stop:
# Default-Stop: 2 3 4 5
# Short-Description: One of the first scripts to be executed. Starts or stops
# the bootlogd log program. If this script is called as
# "stop-bootlogd", it will stop the daemon instead of
# starting it even when called with the "start" argument.
#
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/sbin/bootlogd
NAME=bootlogd
DESC="Bootlog daemon"
# source function library
. /etc/init.d/functions
test -f $DAEMON || exit 0
[ -r /etc/default/bootlogd ] && . /etc/default/bootlogd
## set -e # not needed
case "$BOOTLOGD_ENABLE" in
[Nn]*)
exit 0
;;
esac
STOPPER=
ACTION="$1"
case "$0" in
*stop-bootlog*)
STOPPER=Y
if [ "$ACTION" = start ]
then
ACTION=stop
fi
;;
esac
case "$ACTION" in
start)
[ "${VERBOSE}" != "no" ] && echo -n "Starting $DESC: "
if [ -d /proc/1/. ]
then
umask 027
start-stop-daemon --start --quiet \
--exec $DAEMON -- -r -c
else
$DAEMON -r -c
fi
[ "${VERBOSE}" != "no" ] && echo "$NAME."
;;
stop)
# stop may get called during bootup, so let it honor
# rcS VERBOSE setting
[ "${VERBOSE}" != "no" ] && echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --exec $DAEMON
if [ "$STOPPER" ] && [ "$(which savelog 2>/dev/null)" ] && \
[ -f /var/log/boot ] && [ -f /var/log/boot~ ]
then
cd /var/log
chgrp adm boot
savelog -p -c 5 boot > /dev/null 2>&1
mv boot.0 boot
mv boot~ boot.0
fi
[ "${VERBOSE}" != "no" ] && echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --exec $DAEMON
echo "$NAME."
;;
status)
status $DAEMON
exit $?
;;
*)
N=${0##*/}
echo "Usage: $N {start|stop|status|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
2 安卓启动脚本
init.rc
on early-init
# Set init and its forked children's oom_adj.
write /proc/1/oom_adj -16
start ueventd
# create mountpoints
mkdir /mnt 0775 root system
on init
sysclktz 0
loglevel 3
# setup the global environment
export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
export LD_LIBRARY_PATH /vendor/lib:/system/lib
export ANDROID_BOOTLOGO 1
export ANDROID_ROOT /system
export ANDROID_ASSETS /system/app
export ANDROID_DATA /data
export ASEC_MOUNTPOINT /mnt/asec
export LOOP_MOUNTPOINT /mnt/obb
export BOOTCLASSPATH /system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/filterfw.jar
# Backward compatibility
symlink /system/etc /etc
symlink /sys/kernel/debug /d
# Right now vendor lives on the same filesystem as system,
# but someday that may change.
symlink /system/vendor /vendor
# Create cgroup mount point for cpu accounting
mkdir /acct
mount cgroup none /acct cpuacct
mkdir /acct/uid
mkdir /system
mkdir /data 0771 system system
mkdir /cache 0770 system cache
mkdir /config 0500 root root
# Directory for putting things only root should see.
mkdir /mnt/secure 0700 root root
# Directory for staging bindmounts
mkdir /mnt/secure/staging 0700 root root
# Directory-target for where the secure container
# imagefile directory will be bind-mounted
mkdir /mnt/secure/asec 0700 root root
# Secure container public mount points.
mkdir /mnt/asec 0700 root system
mount tmpfs tmpfs /mnt/asec mode=0755,gid=1000
# Filesystem image public mount points.
mkdir /mnt/obb 0700 root system
mount tmpfs tmpfs /mnt/obb mode=0755,gid=1000
write /proc/sys/kernel/panic_on_oops 1
write /proc/sys/kernel/hung_task_timeout_secs 0
write /proc/cpu/alignment 4
write /proc/sys/kernel/sched_latency_ns 10000000
write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000
write /proc/sys/kernel/sched_compat_yield 1
write /proc/sys/kernel/sched_child_runs_first 0
write /proc/sys/kernel/randomize_va_space 2
# Create cgroup mount points for process groups
mkdir /dev/cpuctl
mount cgroup none /dev/cpuctl cpu
chown system system /dev/cpuctl
chown system system /dev/cpuctl/tasks
chmod 0777 /dev/cpuctl/tasks
write /dev/cpuctl/cpu.shares 1024
mkdir /dev/cpuctl/fg_boost
chown system system /dev/cpuctl/fg_boost/tasks
chmod 0777 /dev/cpuctl/fg_boost/tasks
write /dev/cpuctl/fg_boost/cpu.shares 1024
mkdir /dev/cpuctl/bg_non_interactive
chown system system /dev/cpuctl/bg_non_interactive/tasks
chmod 0777 /dev/cpuctl/bg_non_interactive/tasks
# 5.0 %
write /dev/cpuctl/bg_non_interactive/cpu.shares 52
# Allow everybody to read the xt_qtaguid resource tracking misc dev.
# This is needed by any process that uses socket tagging.
chmod 0644 /dev/xt_qtaguid
on fs
# mount mtd partitions
# Mount /system rw first to give the filesystem a chance to save a checkpoint
mount yaffs2 mtd@system /system
mount yaffs2 mtd@system /system rw remount
mount yaffs2 mtd@userdata /data nosuid nodev
mount yaffs2 mtd@cache /cache nosuid nodev
on post-fs
# once everything is setup, no need to modify /
mount rootfs rootfs / rw remount
# We chown/chmod /cache again so because mount is run as root + defaults
chown system cache /cache
chmod 0770 /cache
# This may have been created by the recovery system with odd permissions
chown system cache /cache/recovery
chmod 0770 /cache/recovery
#change permissions on vmallocinfo so we can grab it from bugreports
chown root log /proc/vmallocinfo
chmod 0440 /proc/vmallocinfo
#change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks
chown root system /proc/kmsg
chmod 0440 /proc/kmsg
chown root system /proc/sysrq-trigger
chmod 0220 /proc/sysrq-trigger
# create the lost+found directories, so as to enforce our permissions
mkdir /cache/lost+found 0770 root root
on post-fs-data
# We chown/chmod /data again so because mount is run as root + defaults
chown system system /data
chmod 0771 /data
# Create dump dir and collect dumps.
# Do this before we mount cache so eventually we can use cache for
# storing dumps on platforms which do not have a dedicated dump partition.
mkdir /data/dontpanic 0750 root log
# Collect apanic data, free resources and re-arm trigger
copy /proc/apanic_console /data/dontpanic/apanic_console
chown root log /data/dontpanic/apanic_console
chmod 0640 /data/dontpanic/apanic_console
copy /proc/apanic_threads /data/dontpanic/apanic_threads
chown root log /data/dontpanic/apanic_threads
chmod 0640 /data/dontpanic/apanic_threads
write /proc/apanic_console 1
# create basic filesystem structure
mkdir /data/misc 01771 system misc
###cym mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth
###cym mkdir /data/misc/bluetooth 0770 system system
mkdir /data/misc/keystore 0700 keystore keystore
mkdir /data/misc/keychain 0771 system system
mkdir /data/misc/vpn 0770 system vpn
mkdir /data/misc/systemkeys 0700 system system
# give system access to wpa_supplicant.conf for backup and restore
###cym mkdir /data/misc/wifi 0770 wifi wifi
# chmod 0660 /data/misc/wifi/wpa_supplicant.conf
###cym chmod 0660 /system/etc/wifi/wpa_supplicant.conf
###cym chown wifi wifi /system/etc/wifi/wpa_supplicant.conf
###cym mkdir /data/misc/dhcp 0775 dhcp dhcp
###cym mkdir /data/misc/wifi/sockets 0777 wifi wifi
#mkdir /data/system 0775 wifi wifi
###cym mkdir /data/system 0775 system system
###cym mkdir /data/system/wpa_supplicant 0777 wifi wifi
mkdir /data/misc/wifi/hostapd 0777 wifi wifi
chown bluetooth bluetooth /dev/ttySAC0
chmod 0660 /dev/ttySAC0
mkdir /data/local 0771 shell shell
mkdir /data/local/tmp 0771 shell shell
mkdir /data/data 0771 system system
mkdir /data/app-private 0771 system system
mkdir /data/app 0771 system system
mkdir /data/property 0700 root root
# create dalvik-cache, so as to enforce our permissions
mkdir /data/dalvik-cache 0771 system system
# create resource-cache and double-check the perms
mkdir /data/resource-cache 0771 system system
chown system system /data/resource-cache
chmod 0771 /data/resource-cache
# create the lost+found directories, so as to enforce our permissions
mkdir /data/lost+found 0770 root root
# create directory for DRM plug-ins
mkdir /data/drm 0774 drm drm
# If there is no fs-post-data action in the init.<device>.rc file, you
# must uncomment this line, otherwise encrypted filesystems
# won't work.
# Set indication (checked by vold) that we have finished this action
#setprop vold.post_fs_data_done 1
chown system system /sys/class/android_usb/android0/f_mass_storage/lun/file
chmod 0660 /sys/class/android_usb/android0/f_mass_storage/lun/file
chown system system /sys/class/android_usb/android0/f_rndis/ethaddr
chmod 0660 /sys/class/android_usb/android0/f_rndis/ethaddr
on boot
# basic network init
ifup lo
hostname localhost
domainname localdomain
# set RLIMIT_NICE to allow priorities from 19 to -20
setrlimit 13 40 40
# Memory management. Basic kernel parameters, and allow the high
# level system server to be able to adjust the kernel OOM driver
# paramters to match how it is managing things.
write /proc/sys/vm/overcommit_memory 1
write /proc/sys/vm/min_free_order_shift 4
chown root system /sys/module/lowmemorykiller/parameters/adj
chmod 0664 /sys/module/lowmemorykiller/parameters/adj
chown root system /sys/module/lowmemorykiller/parameters/minfree
chmod 0664 /sys/module/lowmemorykiller/parameters/minfree
# Tweak background writeout
write /proc/sys/vm/dirty_expire_centisecs 200
write /proc/sys/vm/dirty_background_ratio 5
# Permissions for System Server and daemons.
chown radio system /sys/android_power/state
chown radio system /sys/android_power/request_state
chown radio system /sys/android_power/acquire_full_wake_lock
chown radio system /sys/android_power/acquire_partial_wake_lock
chown radio system /sys/android_power/release_wake_lock
chown radio system /sys/power/state
chown radio system /sys/power/wake_lock
chown radio system /sys/power/wake_unlock
chmod 0660 /sys/power/state
chmod 0660 /sys/power/wake_lock
chmod 0660 /sys/power/wake_unlock
#chy add for reset modem
chown root radio /sys/devices/platform/smm_modem/control
chmod 0666 /sys/devices/platform/smm_modem/control
chmod 0777 /dev/modemctl
chown system system /sys/class/timed_output/vibrator/enable
chown system system /sys/class/leds/keyboard-backlight/brightness
chown system system /sys/class/leds/lcd-backlight/brightness
chown system system /sys/class/leds/button-backlight/brightness
chown system system /sys/class/leds/jogball-backlight/brightness
chown system system /sys/class/leds/red/brightness
chown system system /sys/class/leds/green/brightness
chown system system /sys/class/leds/blue/brightness
chown system system /sys/class/leds/red/device/grpfreq
chown system system /sys/class/leds/red/device/grppwm
chown system system /sys/class/leds/red/device/blink
chown system system /sys/class/leds/red/brightness
chown system system /sys/class/leds/green/brightness
chown system system /sys/class/leds/blue/brightness
chown system system /sys/class/leds/red/device/grpfreq
chown system system /sys/class/leds/red/device/grppwm
chown system system /sys/class/leds/red/device/blink
chown system system /sys/class/timed_output/vibrator/enable
chown system system /sys/module/sco/parameters/disable_esco
chown system system /sys/kernel/ipv4/tcp_wmem_min
chown system system /sys/kernel/ipv4/tcp_wmem_def
chown system system /sys/kernel/ipv4/tcp_wmem_max
chown system system /sys/kernel/ipv4/tcp_rmem_min
chown system system /sys/kernel/ipv4/tcp_rmem_def
chown system system /sys/kernel/ipv4/tcp_rmem_max
chown root radio /proc/cmdline
# Define TCP buffer sizes for various networks
# ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax,
setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208
setprop net.tcp.buffersize.wifi 524288,1048576,2097152,262144,524288,1048576
setprop net.tcp.buffersize.lte 524288,1048576,2097152,262144,524288,1048576
setprop net.tcp.buffersize.umts 4094,87380,110208,4096,16384,110208
setprop net.tcp.buffersize.hspa 4094,87380,262144,4096,16384,262144
setprop net.tcp.buffersize.edge 4093,26280,35040,4096,16384,35040
setprop net.tcp.buffersize.gprs 4092,8760,11680,4096,8760,11680
setprop ro.nfc.port "I2C"
chmod 0666 /dev/snfc-n2
# Set this property so surfaceflinger is not started by system_init
setprop system_init.startsurfaceflinger 0
class_start core
class_start main
on nonencrypted
class_start late_start
on charger
class_start charger
on property:vold.decrypt=trigger_reset_main
class_reset main
on property:vold.decrypt=trigger_load_persist_props
load_persist_props
on property:vold.decrypt=trigger_post_fs_data
trigger post-fs-data
on property:vold.decrypt=trigger_restart_min_framework
class_start main
on property:vold.decrypt=trigger_restart_framework
class_start main
class_start late_start
on property:vold.decrypt=trigger_shutdown_framework
class_reset late_start
class_reset main
# Used to disable USB when switching states
on property:sys.usb.config=none
stop adbd
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/bDeviceClass 0
setprop sys.usb.state $sys.usb.config
# adb only USB configuration
# This should only be used during device bringup
# and as a fallback if the USB manager fails to set a standard configuration
on property:sys.usb.config=adb
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
write /sys/class/android_usb/android0/idProduct D002
write /sys/class/android_usb/android0/functions $sys.usb.config
write /sys/class/android_usb/android0/enable 1
start adbd
setprop sys.usb.state $sys.usb.config
# USB accessory configuration
on property:sys.usb.config=accessory
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
write /sys/class/android_usb/android0/idProduct 2d00
write /sys/class/android_usb/android0/functions $sys.usb.config
write /sys/class/android_usb/android0/enable 1
setprop sys.usb.state $sys.usb.config
# USB accessory configuration, with adb
on property:sys.usb.config=accessory,adb
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
write /sys/class/android_usb/android0/idProduct 2d01
write /sys/class/android_usb/android0/functions $sys.usb.config
write /sys/class/android_usb/android0/enable 1
start adbd
setprop sys.usb.state $sys.usb.config
# Used to set USB configuration at boot and to switch the configuration
# when changing the default configuration
on property:persist.sys.usb.config=*
setprop sys.usb.config $persist.sys.usb.config
## Daemon processes to be run by init.
##
service ueventd /sbin/ueventd
class core
critical
service console /system/bin/sh
class core
console
disabled
# user shell
group log
on property:ro.debuggable=1
start console
# adbd is controlled via property triggers in init.<platform>.usb.rc
service adbd /sbin/adbd
class core
disabled
# adbd on at boot in emulator
on property:ro.kernel.qemu=1
start adbd
# This property trigger has added to imitiate the previous behavior of "adb root".
# The adb gadget driver used to reset the USB bus when the adbd daemon exited,
# and the host side adb relied on this behavior to force it to reconnect with the
# new adbd instance after init relaunches it. So now we force the USB bus to reset
# here when adbd sets the service.adb.root property to 1. We also restart adbd here
# rather than waiting for init to notice its death and restarting it so the timing
# of USB resetting and adb restarting more closely matches the previous behavior.
on property:service.adb.root=1
write /sys/class/android_usb/android0/enable 0
restart adbd
write /sys/class/android_usb/android0/enable 1
service servicemanager /system/bin/servicemanager
class core
user system
group system
critical
onrestart restart zygote
onrestart restart media
onrestart restart surfaceflinger
onrestart restart drm
service vold /system/bin/vold
class core
socket vold stream 0660 root mount
ioprio be 2
service netd /system/bin/netd
class main
socket netd stream 0660 root system
socket dnsproxyd stream 0660 root inet
service debuggerd /system/bin/debuggerd
class main
#service ril-daemon /system/bin/rild
# class main
## socket rild stream 660 root radio
## chy modify @20120312
# socket rild stream 666 root radio
# socket rild-debug stream 660 radio system
# user root
# group radio cache inet misc audio sdcard_rw log
#add by cym for UNAPLUS
service ril-daemon /system/bin/rild -l /system/lib/usiuna-ril.so -- -d /dev/ttyUSB1
class main
socket rild stream 660 root radio
socket rild-debug stream 660 radio system
user root
group radio cache inet misc audio sdcard_rw log
service pppd_gprs /system/bin/logwrapper /etc/ppp/call-pppd
class main
user root
group radio cache inet misc
disabled
oneshot
service dhcpd_start /system/bin/logwrapper /etc/ppp/dhcpd_start
class main
user root
group radio dhcp
disabled
oneshot
service dhcp_stop /system/bin/logwrapper /etc/ppp/dhcpd_stop
class main
user root
group radio dhcp
disabled
oneshot
#on property:ril.unap_state=*
# write /sys/bus/usb/devices/1-2.1/power/control $ril.unap_state
#on property:ril.unap_state=*
# write /sys/bus/usb/devices/1-2.1/power/control ${ril.unap_state}
#end add
service surfaceflinger /system/bin/surfaceflinger
class main
user system
group graphics
onrestart restart zygote
service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
class main
socket zygote stream 666
onrestart write /sys/android_power/request_state wake
onrestart write /sys/power/state on
onrestart restart media
onrestart restart netd
service drm /system/bin/drmserver
class main
user drm
group system inet drmrpc
service media /system/bin/mediaserver
class main
user media
group audio camera inet net_bt net_bt_admin net_bw_acct drmrpc
ioprio rt 4
service bootanim /system/bin/bootanimation
class main
user graphics
group graphics
disabled
oneshot
service dbus /system/bin/dbus-daemon --system --nofork
class main
socket dbus stream 660 bluetooth bluetooth
user bluetooth
group bluetooth net_bt_admin
service bluetoothd /system/bin/bluetoothd -n
class main
socket bluetooth stream 660 bluetooth bluetooth
socket dbus_bluetooth stream 660 bluetooth bluetooth
# init.rc does not yet support applying capabilities, so run as root and
# let bluetoothd drop uid to bluetooth with the right linux capabilities
group bluetooth net_bt_admin misc
disabled
service hfag /system/bin/sdptool add --channel=10 HFAG
class main
user bluetooth
group bluetooth net_bt_admin
disabled
oneshot
service hsag /system/bin/sdptool add --channel=11 HSAG
class main
user bluetooth
group bluetooth net_bt_admin
disabled
oneshot
service opush /system/bin/sdptool add --channel=12 OPUSH
class main
user bluetooth
group bluetooth net_bt_admin
disabled
oneshot
service pbap /system/bin/sdptool add --channel=19 PBAP
class main
user bluetooth
group bluetooth net_bt_admin
disabled
oneshot
service installd /system/bin/installd
class main
socket installd stream 600 system system
service flash_recovery /system/etc/install-recovery.sh
class main
oneshot
service abtfilt /system/bin/wlan_tool abtfilt
class main
user bluetooth
group system bluetooth net_bt_admin inet
disabled
oneshot
service racoon /system/bin/racoon
class main
socket racoon stream 600 system system
# IKE uses UDP port 500. Racoon will setuid to vpn after binding the port.
group vpn net_admin inet
disabled
oneshot
service mtpd /system/bin/mtpd
class main
socket mtpd stream 600 system system
user vpn
group vpn net_admin inet net_raw
disabled
oneshot
service keystore /system/bin/keystore /data/misc/keystore
class main
user keystore
group keystore
socket keystore stream 666
service dumpstate /system/bin/dumpstate -s
class main
socket dumpstate stream 0660 shell log
disabled
oneshot
#remove by cym 20130408
#service bccmd /system/bin/bccmd -t bcsp -b 115200 -d /dev/ttySAC0 psload -r /system/bluetooth/A31_Script_20110215.psr
# class main
# disabled
# oneshot
#service hciattach /system/bin/hciattach -s 921600 /dev/ttySAC0 bcsp 921600 flow
# class main
# disabled
# oneshot
###cym service dhcpcd_bnep0 /system/bin/dhcpcd -ABKL
# class main
# disabled
# oneshot
#service iprenew_p2p /system/bin/dhcpcd -n
# class main
# disabled
# oneshot
#service iprenew_bnep0 /system/bin/dhcpcd -n
# class main
# disabled
# oneshot
mount yaffs2 mtd@cache /cache nosuid nodev
init.smdk4x12.rc
import init.wireless.rc
import init.smdk4x12.usb.rc
on early-init
export EXTERNAL_STORAGE /mnt/sdcard
mkdir /mnt/sdcard 0000 system system
mkdir /mnt/sdcard2 0775 system system
mkdir /mnt/udisk 0775 system system
mkdir /mnt/udisk1 0775 system system
symlink /mnt/sdcard /sdcard
# jmq.disable
#on post-fs-data
# we will remap this as /mnt/sdcard with the sdcard fuse tool
# mkdir /data/media 0775 media_rw media_rw
# chown media_rw media_rw /data/media
service console /system/bin/sh
class core
console
group log
#add by cym 20130622
service cfg_audio /system/bin/cfg_audio
user system
group system
class main
oneshot
#end add
on boot
setprop ro.build.product smdk4x12
setprop ro.product.device smdk4x12
setprop ro.radio.noril yes
on fs
mount ext4 /dev/block/mmcblk0p2 /system ro wait
# mount ext4 /dev/block/mmcblk0p3 /data wait nosuid nodev noatime nomblk_io_submit
mount ext4 /dev/block/mmcblk0p3 /data nosuid nodev noatime wait usedm discard,noauto_da_alloc,nodelalloc
mount ext4 /dev/block/mmcblk0p4 /cache wait nosuid nodev noatime nomblk_io_submit
# jmq.disable
# setprop ro.crypto.fuse_sdcard true
# Permissions for backlight
chmod 0665 /sys/class/backlight/pwm-backlight.0/brightness
chown system system /sys/class/backlight/pwm-backlight.0/brightness
# Permissions for btpower
chown system system /sys/devices/platform/bt-sysfs/bt_power
# create filesystem if necessary
#service setup_fs /system/bin/setup_fs \
# /dev/block/mmcblk0p3 \
# /dev/block/mmcblk0p4
# class core
# user root
# group root
# oneshot
# create virtual SD card at /mnt/sdcard, based on the /data/media directory
# daemon will drop to user/group system/media_rw after initializing
# underlying files in /data/media will be created with user and group media_rw (1023)
# jmq.disable
#service sdcard /system/bin/sdcard /data/media 1023 1023
# class late_start
# Permissions for GPS
chmod 0777 /dev/ttySAC3
chmod 0777 /dev/AGPS
chown root root /data
chmod 0771 /data
#add by cym support for RFID
chmod 0777 /dev/ttySAC1
chown root root /data
chmod 0771 /data
#yyd- 111206, add sensor
chmod 0777 /dev/mpu
chmod 0777 /dev/mpuirq
# chmod 0777 /dev/accelirq
chmod 0777 /dev/timerirq
#add by cym 20130305
chmod 0777 /linuxrc
chmod 0777 /dev/adc
chmod 0777 /dev/buzzer_ctl
chmod 0777 /dev/max485_ctl_pin
chmod 0777 /dev/leds
chmod 0777 /dev/rc522
chmod 0777 /dev/ttySAC0
chmod 0777 /dev/ttySAC2
chmod 0777 /dev/relay_ctl
init.smdk4x12.usb.rc
on boot
write /sys/class/android_usb/android0/iManufacturer $ro.product.manufacturer
write /sys/class/android_usb/android0/iProduct $ro.product.model
write /sys/class/android_usb/android0/iSerial $ro.serialno
write /sys/class/android_usb/android0/f_mass_storage/inquiry_string "Google Nexus S 0100"
write /sys/class/android_usb/android0/f_rndis/manufacturer Samsung
write /sys/class/android_usb/android0/f_rndis/vendorID 18d1
write /sys/class/android_usb/android0/f_rndis/wceis 1
on property:sys.usb.config=mass_storage
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
write /sys/class/android_usb/android0/idProduct 4e21
write /sys/class/android_usb/android0/functions $sys.usb.config
write /sys/class/android_usb/android0/enable 1
setprop sys.usb.state $sys.usb.config
on property:sys.usb.config=mass_storage,adb
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
write /sys/class/android_usb/android0/idProduct 4e22
write /sys/class/android_usb/android0/functions $sys.usb.config
write /sys/class/android_usb/android0/enable 1
start adbd
setprop sys.usb.state $sys.usb.config
on property:sys.usb.config=rndis
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
write /sys/class/android_usb/android0/idProduct 4e23
write /sys/class/android_usb/android0/functions $sys.usb.config
write /sys/class/android_usb/android0/bDeviceClass 224
write /sys/class/android_usb/android0/enable 1
setprop sys.usb.state $sys.usb.config
on property:sys.usb.config=rndis,adb
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
write /sys/class/android_usb/android0/idProduct 4e24
write /sys/class/android_usb/android0/functions $sys.usb.config
write /sys/class/android_usb/android0/bDeviceClass 224
write /sys/class/android_usb/android0/enable 1
start adbd
setprop sys.usb.state $sys.usb.config
on property:sys.usb.config=mtp,adb
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
write /sys/class/android_usb/android0/idProduct 4e26
write /sys/class/android_usb/android0/functions $sys.usb.config
write /sys/class/android_usb/android0/enable 1
start adbd
setprop sys.usb.state $sys.usb.config
on property:sys.usb.config=ptp,adb
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18d1
write /sys/class/android_usb/android0/idProduct 4e27
write /sys/class/android_usb/android0/functions $sys.usb.config
write /sys/class/android_usb/android0/enable 1
start adbd
setprop sys.usb.state $sys.usb.configinit.wireless.rc
init.wireless.rc
on post-fs-data
# mainly do mkdir/insmod/mknod in this section
#
# MT6620 related device nodes & modules & configuration (begin)
#
# BlueZ driver internal config file generated path
mkdir /data/bluetooth 0711 bluetooth bluetooth
# wpa_supplicant control socket for android wifi.c
mkdir /data/misc/wifi 0770 wifi wifi
mkdir /data/misc/wifi/sockets 0770 wifi wifi
chmod 0770 /data/misc/wifi
chmod 0660 /data/misc/wifi/wpa_supplicant.conf
chmod 0660 /data/misc/wifi/p2p_supplicant.conf
chown wifi wifi /data/misc/wifi
chown wifi wifi /data/misc/wifi/wpa_supplicant.conf
chown wifi wifi /data/misc/wifi/p2p_supplicant.conf
# wpa_supplicant socket
mkdir /data/system 0771 system system
mkdir /data/system/wpa_supplicant 0771 wifi wifi
chmod 0771 /data/system/wpa_supplicant
chown wifi wifi /data/system/wpa_supplicant
mkdir /data/misc/p2p_supplicant 0771 wifi wifi
chmod 0771 /data/misc/p2p_supplicant
chown wifi wifi /data/misc/p2p_supplicant
# wpa_supplicant control socket for android wifi.c
mkdir /data/misc/wifi 0770 wifi wifi
mkdir /data/misc/dhcp 0771 dhcp dhcp
mkdir /data/wifi 0771 wifi wifi
chown dhcp dhcp /data/misc/dhcp
setprop wifi.interface "wlan0"
setprop wifi.direct.multicast 1
# Load common part modules
insmod /system/lib/modules/mtk_hif_sdio.ko
insmod /system/lib/modules/mtk_stp_wmt.ko
insmod /system/lib/modules/mtk_stp_uart.ko
# Load GPS module
insmod /system/lib/modules/mtk_stp_gps.ko
# Load BlueZ module
insmod /system/lib/modules/hci_stp.ko
# Load FM modules
insmod /system/lib/modules/mt6620_fm_drv.ko
insmod /system/lib/modules/mtk_fm_priv.ko
# Load wifi modules
insmod /system/lib/modules/mtk_wmt_wifi.ko WIFI_major=194
insmod /system/lib/modules/wlan.ko
#Create char device file for WMT, BT, GPS, FM
# mknod /dev/wmtWifi_test c 194 0
chmod 0666 /dev/stpwmt
chmod 0666 /dev/stpgps
#chmod 0666 /dev/stpbt
chmod 0666 /dev/fm
chmod 0666 /dev/wmtWifi
chmod 0660 /dev/ttySAC0
chmod 0666 /dev/gps
# chmod 0660 /dev/wmtWifi_test
# chown system system /dev/wmtWifi_test
chown system system /dev/wmtWifi
chown system system /dev/fm
chown system system /dev/stpwmt
chown system system /dev/stpgps
chown system system /dev/ttySAC0
#chown system system /dev/stpbt
chown system system /dev/gps
mkdir /data/bluetooth 0711 bluetooth bluetooth
# wpa_supplicant control socket for android wifi.c
mkdir /data/misc/wifi 0770 wifi wifi
mkdir /data/misc/wifi/sockets 0770 wifi wifi
chmod 0770 /data/misc/wifi
chmod 0660 /data/misc/wifi/wpa_supplicant.conf
chmod 0660 /data/misc/wifi/p2p_supplicant.conf
chown wifi wifi /data/misc/wifi
chown wifi wifi /data/misc/wifi/wpa_supplicant.conf
chown wifi wifi /data/misc/wifi/p2p_supplicant.conf
# wpa_supplicant socket
mkdir /data/system 0771 system system
mkdir /data/system/wpa_supplicant 0771 wifi wifi
chmod 0771 /data/system/wpa_supplicant
chown wifi wifi /data/system/wpa_supplicant
mkdir /data/misc/p2p_supplicant 0771 wifi wifi
chmod 0771 /data/misc/p2p_supplicant
chown wifi wifi /data/misc/p2p_supplicant
# wpa_supplicant control socket for android wifi.c
mkdir /data/misc/wifi 0770 wifi wifi
mkdir /data/misc/dhcp 0771 dhcp dhcp
mkdir /data/wifi 0771 wifi wifi
chown dhcp dhcp /data/misc/dhcp
setprop wifi.interface "wlan0"
setprop wifi.direct.multicast 1
start 6620_launcher
#
# MT6620 related device nodes & modules & configuration (begin)
#
# Encrypt phone function
setprop vold.post_fs_data_done 1
on boot
# MT6620 related services (Begin)
service 6620_launcher /system/bin/6620_launcher -m 1 -b 921600 -n /system/etc/firmware/mt6620_patch_hdr.bin -d /dev/ttySAC0
user system
group system
class main
oneshot
# class mt6620_user_guard
service mnld /system/xbin/mnld
socket mnld stream 666 system system
disabled
#AGPS
#service agpsd /system/bin/mtk_agpsd
# class main
# socket agpsd stream 666 system system
chmod 770 /etc/agps_profiles_conf.xml
service hald /system/bin/hald
class main
socket hald stream 0660 root system
service wpa_supplicant /system/bin/wpa_supplicant -dd -Dwext -iwlan0 -c /data/misc/wifi/wpa_supplicant.conf
group wifi system inet
disabled
oneshot
service p2p_supplicant /system/bin/p2p_supplicant -dd -Dnl80211 -ip2p0 -c /data/misc/wifi/p2p_supplicant.conf
group wifi system inet
disabled
oneshot
service dhcpcd_wlan0 /system/bin/dhcpcd -A -B -dd
group system dhcp
disabled
oneshot
service dhcpcd_p2p /system/bin/dhcpcd -A -B -dd
class main
disabled
oneshot
service iprenew_wlan0 /system/bin/dhcpcd -n
class main
disabled
oneshot
service dhcpcd_bnep0 /system/bin/dhcpcd -A -B -dd
class main
disabled
oneshot
service hfag /system/bin/sdptool add --channel=10 HFAG
user bluetooth
group bluetooth net_bt_admin
disabled
oneshot
service hsag /system/bin/sdptool add --channel=11 HSAG
user bluetooth
group bluetooth net_bt_admin
disabled
oneshot
service opush /system/bin/sdptool add --channel=12 OPUSH
user bluetooth
group bluetooth net_bt_admin
disabled
oneshot
service pbap /system/bin/sdptool add --channel=19 PBAP
user bluetooth
group bluetooth net_bt_admin
disabled
oneshot
# MT6620 related services (End)
3 ubuntu启动