linux 操作系统启动脚本
1 QT启动脚本 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 022on_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" = "" ]
thenecho "Usage: $scriptname <runlevel>" >&2exit 1
fi
previous=$PREVLEVEL
[ "$previous" = "" ] && previous=Nexport runlevel previousif [ -f /etc/default/rcS ] ; then. /etc/default/rcS
fi
export VERBOSEif [ -f /lib/lsb/init-functions ] ; then. /lib/lsb/init-functions
elselog_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 ; thenCONCURRENCY="none"
fi
if ! test -e /proc/stat; then# startpar requires /proc/statif [ "$(uname)" = "GNU/kFreeBSD" ] ; thenmount -t linprocfs linprocfs /procelif [ "$(uname)" = "GNU" ] ; thenmount -t proc none /procfi
fi
if [ -x /lib/startpar/startpar ] ; thenSTARTPAR=/lib/startpar/startpar
elseSTARTPAR=startpar
fi
$STARTPAR -v > /dev/null 2>&1 || CONCURRENCY="none"#
# Start script or program.
#
case "$CONCURRENCY" inmakefile|startpar|shell) # startpar and shell are obsoleteCONCURRENCY=makefilelog_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" ]thenlog_failure_msg "startpar: service(s) returned failure: $failed_service"fiif [ -n "$skipped_service_not_installed" ]thenlog_warning_msg "startpar: service(s) skipped, program is not installed: $skipped_service_not_installed"fiif [ -n "$skipped_service_not_configured" ]thenlog_warning_msg "startpar: service(s) skipped, program is not configured: $skipped_service_not_configured"fiunset failed_service skipped_service_not_installed skipped_service_not_configured};;none|*)startup() {action=$1shiftscripts="$@"for script in $scripts ; do$debug "$script" $actiondone};;
esac# Is there an rc directory for this new runlevel?
if [ -d /etc/rc$runlevel.d ]
thencase "$runlevel" in0|6)ACTION=stop;;S)ACTION=start;;*)ACTION=start;;esac# First, run the KILL scripts.if [ makefile = "$CONCURRENCY" ]thenif [ "$ACTION" = "start" ] && [ "$previous" != N ]thenstartup stopfielif [ "$previous" != N ]then# Run all scripts with the same level in parallelCURLEVEL=""for s in /etc/rc$runlevel.d/K*do# Extract order value from symlinklevel=${s#/etc/rc$runlevel.d/K}level=${level%%[a-zA-Z]*}if [ "$level" = "$CURLEVEL" ]thencontinuefiCURLEVEL=$levelSCRIPTS=""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]$suffixprevious_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"donestartup stop $SCRIPTSdonefiif [ makefile = "$CONCURRENCY" ]thenif [ S = "$runlevel" ]thenstartup bootelsestartup $ACTIONfielse# Now run the START scripts for this runlevel.# Run all scripts with the same level in parallelCURLEVEL=""for s in /etc/rc$runlevel.d/S*do# Extract order value from symlinklevel=${s#/etc/rc$runlevel.d/S}level=${level%%[a-zA-Z]*}if [ "$level" = "$CURLEVEL" ]thencontinuefiCURLEVEL=$levelSCRIPTS=""for i in /etc/rc$runlevel.d/S$level*do[ ! -f $i ] && continuesuffix=${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]$suffixprevious_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 ] && continueelse# 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 ] && continuefifiSCRIPTS="$SCRIPTS $i"donestartup $ACTION $SCRIPTSdonefi
fitrap - EXIT # Disable emergency handlerexit 0
(1) rcS.d
S00psplash
#!/bin/sh
### BEGIN INIT INFO
# Provides: psplash
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop:
### END INIT INFOread CMDLINE < /proc/cmdline
for x in $CMDLINE; docase $x inpsplash=false)echo "Boot splashscreen disabled" exit 0;;;esac
doneexport TMPDIR=/mnt/.psplash
mount tmpfs -t tmpfs $TMPDIR -o,size=40krotation=0
if [ -e /etc/rotation ]; thenread rotation < /etc/rotation
fiarg=$(ps -aux | egrep "Q" | grep -v grep |awk '{print $2}')
if [ -n "$arg" ];thenkill -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 INFOif [ ! -e /dev/tty ]; then/bin/mknod -m 0666 /dev/tty c 5 0
fiif ( > /dev/tty0 ) 2>/dev/null; thenvtmaster=/dev/tty0
elif ( > /dev/vc/0 ) 2>/dev/null; thenvtmaster=/dev/vc/0
elif ( > /dev/console ) 2>/dev/null; thenvtmaster=/dev/console
elsevtmaster=/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 INFOif [ -e /proc ] && ! [ -e /proc/mounts ]; thenmount -t proc proc /proc
fiif [ -e /sys ] && grep -q sysfs /proc/filesystems && ! [ -e /sys/class ]; thenmount -t sysfs sysfs /sys
fiif [ -e /sys/kernel/debug ] && grep -q debugfs /proc/filesystems; thenmount -t debugfs debugfs /sys/kernel/debug
fiif ! [ -e /dev/zero ] && [ -e /dev ] && grep -q devtmpfs /proc/filesystems; thenmount -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
thenrm -f /dev/initctlmknod -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 INFOexport 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_LISTstat -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/rcSkill_udevd () {pid=`pidof -x udevd`[ -n "$pid" ] && kill $pid
}case "$1" instart)export ACTION=add# propagate /dev from /sysecho "Starting udev"# Check for requireed devtmpfs before trying to start udev and# mount a no-existant fs.if ! grep -q devtmpfs /proc/filesystemsthenecho "Missing devtmpfs, which is required for udev to run";echo "Halting..."haltfi# mount the devtmpfs on /dev, if not already doneLANG=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" != "" ]; thenif [ -e $DEVCACHE ]; thensysconf_cmd > "$SYSCONF_TMP"if cmp $SYSCONF_CACHED $SYSCONF_TMP >/dev/null; thentar xmf $DEVCACHE -C / -mnot_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 usedcat <<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
EOFtouch "$DEVCACHE_REGEN"fielseif [ "$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"fififi# make_extra_nodeskill_udevd > "/dev/null" 2>&1# trigger the sorted events[ -e /proc/sys/kernel/hotplug ] && echo -e '\000' >/proc/sys/kernel/hotplug/sbin/udevd -dudevadm control --env=STARTUP=1if [ "$not_first_boot" != "" ];thenif [ "$PROBE_PLATFORM_BUS" != "yes" ]; thenPLATFORM_BUS_NOMATCH="--subsystem-nomatch=platform"elsePLATFORM_BUS_NOMATCH=""fiudevadm 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=)&elseudevadm trigger --action=addudevadm settlefi;;stop)echo "Stopping udevd"start-stop-daemon --stop --name udevd --quiet;;restart)$0 stopsleep 1$0 start;;status)pid=`pidof -x udevd`if [ -n "$pid" ]; thenecho "udevd (pid $pid) is running ..."elseecho "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 INFOLOAD_MODULE=modprobe
[ -f /proc/modules ] || exit 0
[ -f /etc/modules ] || [ -d /etc/modules-load.d ] || exit 0
[ -e /sbin/modprobe ] || LOAD_MODULE=insmodif [ ! -f /lib/modules/`uname -r`/modules.dep ]; then[ "$VERBOSE" != no ] && echo "Calculating module dependencies ..."depmod -Ae
filoaded_modules=" "process_file() {file=$1(cat $file; echo; ) |while read module argsdocase "$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 0for f in /etc/modules-load.d/*.conf; doprocess_file $f
done
[ "$VERBOSE" != no ] && echoexit 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
docase "$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;;esactest "$type" = devfs && devfs="$fs"test "$mnt" != / && continuerootopts="$opts"test "$pass" = 0 -o "$pass" = "" && rootcheck=nocase "$opts" inro|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" ]; thenecho ""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
thentest $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 $? = 0thenif test -f /forcefsckthenforce="-f"elseforce=""fiif test "$FSCKFIX" = yesthenfix="-y"elsefix="-a"fispinner="-C"case "$TERM" indumb|network|unknown|"") spinner="" ;;esactest `uname -m` = s390 && spinner="" # This should go awaytest "$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 1then# Surprise! Re-directing from a HERE document (as in# "cat << EOF") won't work, because the root is read-only.echoecho "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:"echoecho " # mount -n -o remount,rw /"echoecho "CONTROL-D will exit from this shell and REBOOT the system."echo# Start a single user shell on the console/sbin/sulogin $CONSOLEreboot -ffielseecho "*** ERROR! Cannot fsck root fs because it is not mounted read-only!"echofi
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
thenln -sf /proc/mounts /dev/mtab
fiexit 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 INFOPATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/sbin/bootlogd
NAME=bootlogd
DESC="Bootlog daemon"# source function library
. /etc/init.d/functionstest -f $DAEMON || exit 0[ -r /etc/default/bootlogd ] && . /etc/default/bootlogd## set -e # not neededcase "$BOOTLOGD_ENABLE" in[Nn]*)exit 0;;
esacSTOPPER=
ACTION="$1"
case "$0" in*stop-bootlog*)STOPPER=Yif [ "$ACTION" = start ]thenACTION=stopfi;;
esaccase "$ACTION" instart)[ "${VERBOSE}" != "no" ] && echo -n "Starting $DESC: "if [ -d /proc/1/. ]thenumask 027start-stop-daemon --start --quiet \--exec $DAEMON -- -r -celse$DAEMON -r -cfi[ "${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 $DAEMONif [ "$STOPPER" ] && [ "$(which savelog 2>/dev/null)" ] && \[ -f /var/log/boot ] && [ -f /var/log/boot~ ]thencd /var/logchgrp adm bootsavelog -p -c 5 boot > /dev/null 2>&1mv boot.0 bootmv boot~ boot.0fi[ "${VERBOSE}" != "no" ] && echo "$NAME.";;restart|force-reload)echo -n "Restarting $DESC: "start-stop-daemon --stop --quiet --exec $DAEMONsleep 1start-stop-daemon --start --quiet --exec $DAEMONecho "$NAME.";;status)status $DAEMONexit $?;;*)N=${0##*/}N=${N#[SK]??}echo "Usage: $N {start|stop|status|restart|force-reload}" >&2exit 1;;
esacexit 0
S29read-only-rootfs-hook
#!/bin/sh. /etc/default/rcS[ "$ROOTFS_READ_ONLY" = "no" ] && exit 0is_on_read_only_partition () {DIRECTORY=$1dir=`readlink -f $DIRECTORY`while true; doif [ ! -d "$dir" ]; thenecho "ERROR: $dir is not a directory"exit 1elsefor 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; }doneif [ "$dir" = "/" -o -n "$partition" ]; thenbreakelsedir=`dirname $dir`fifidone[ "$partition" = "read-only" ] && echo "yes" || echo "no"
}if [ "$1" = "start" ] ; thenif [ `is_on_read_only_partition /var/lib` = "yes" ]; thengrep -q "tmpfs /var/volatile" /proc/mounts || mount /var/volatilemkdir -p /var/volatile/libcp -a /var/lib/* /var/volatile/libmount --bind /var/volatile/lib /var/libfi
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 INFOexport 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_LISTstat -c '%s %Y %n' -- $META_FILE_LIST | awk -F/ '{print $1 " " $NF;}'
}[ -f /etc/default/udev-cache ] && . /etc/default/udev-cacheif [ "$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-queuerm -f -- "$SYSCONF_TMP" "$DEVCACHE_TMP" "$DEVCACHE" "$SYSCONF_CACHED"
}(set -etrap 'err_cleanup' EXITudevadm control --stop-exec-queuesysconf_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-queuerm -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=noCFGDIR="${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" ]; theneval $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>&1fi}
}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" ]; theneval $EXECelse# For the same reason with create_file(), failures should# not be logged.eval $EXEC > /dev/null 2>&1fi}
}link_file() {EXEC="if [ -L \"$2\" ]; then[ \"\$(readlink -f \"$2\")\" != \"\$(readlink -f \"$1\")\" ] && { rm -f \"$2\"; ln -sf \"$1\" \"$2\"; };elif [ -d \"$2\" ]; thenif awk '\$2 == \"$2\" {exit 1}' /proc/mounts; thencp -a $2/* $1 2>/dev/null;cp -a $2/.[!.]* $1 2>/dev/null;rm -rf \"$2\";ln -sf \"$1\" \"$2\";fielseln -sf \"$1\" \"$2\";fi"test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >> /etc/volatile.cache.buildif [ -z "$ROOT_DIR" ]; theneval $EXEC &else# For the same reason with create_file(), failures should# not be logged.eval $EXEC > /dev/null 2>&1fi
}check_requirements() {cleanup() {rm "${TMP_INTERMED}"rm "${TMP_DEFINED}"rm "${TMP_COMBINED}"}CFGFILE="$1"[ `basename "${CFGFILE}"` = "${COREDEF}" ] && return 0TMP_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 "^>"cleanupreturn 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 "^>"cleanupreturn 1}# Add checks for required directories herecleanupreturn 0
}apply_cfgfile() {CFGFILE="$1"check_requirements "${CFGFILE}" || {echo "Skipping ${CFGFILE}"return 1}cat ${CFGFILE} | grep -v "^#" | \while read LINE; doeval `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.buildcontinue}[ -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;;esacdonereturn 0
}clearcache=0
exec 9</proc/cmdline
while read line <&9
docase "$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"
thensh ${ROOT_DIR}/etc/volatile.cache
elserm -f ${ROOT_DIR}/etc/volatile.cache ${ROOT_DIR}/etc/volatile.cache.buildfor file in `ls -1 "${CFGDIR}" | sort`; doapply_cfgfile "${CFGDIR}/${file}"done[ -e ${ROOT_DIR}/etc/volatile.cache.build ] && sync && mv ${ROOT_DIR}/etc/volatile.cache.build ${ROOT_DIR}/etc/volatile.cache
fiif [ -z "${ROOT_DIR}" ] && [ -f /etc/ld.so.cache ] && [ ! -f /var/run/ld.so.cache ]
thenln -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/devptsif 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/mountsthenmkdir -p /dev/ptsmount -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 INFOif [ -f /var/log/dmesg ]; thenif [ -f /usr/sbin/logrotate ]; thenlogrotate -f /etc/logrotate-dmesg.confelsemv -f /var/log/dmesg /var/log/dmesg.oldfi
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 INFOtest -c /dev/urandom || exit 0RANDOM_SEED_FILE=/var/lib/urandom/random-seed. /etc/default/rcS
[ -f /etc/default/urandom ] && . /etc/default/urandomcase "$1" instart|"")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/urandomrm -f "$RANDOM_SEED_FILE"umask 077dd 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.ctest "$VERBOSE" != no && echo "Saving random seed..."umask 077dd if=/dev/urandom of=$RANDOM_SEED_FILE count=1 \>/dev/null 2>&1 || echo "urandom stop: failed.";;*)echo "Usage: urandom {start|stop}" >&2exit 1;;
esacexit 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/functionsasound_restore(){echo "ALSA: Restoring mixer settings..."if test -x /usr/sbin/alsactl -a -e /var/lib/alsa/asound.statethen/usr/sbin/alsactl -f /var/lib/alsa/asound.state restore &fi
}asound_store(){echo "ALSA: Storing mixer settings..."if test -x /usr/sbin/alsactlthen/usr/sbin/alsactl -f /var/lib/alsa/asound.state storefi
}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 ]; thenexit
fi# Busybox hostname doesn't support -b so we need implement it on our own
if [ -f /etc/hostname ];thenhostname `cat /etc/hostname`
elif [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" -o ! -z "`echo $HOSTNAME | sed -n '/^[0-9]*\.[0-9].*/p'`" ] ; thenhostname 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
thenecho "System bootup in progress - please wait" > /etc/nologincp /etc/nologin /etc/nologin.boot
fi#
# Set pseudo-terminal access permissions.
#
if test -c /dev/ttyp0
thenchmod 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}" ]
thenif [ -x "/sbin/sysctl" ]then# busybox sysctl does not support -qVERBOSE_REDIR="1>/dev/null"if [ "${VERBOSE}" != "no" ]; thenVERBOSE_REDIR="1>&1"fieval /sbin/sysctl -p "${SYSCTL_CONF}" $VERBOSE_REDIRelseecho "To have ${SYSCTL_CONF} applied during boot, install package <procps>."fi
fi#
# Update /etc/motd.
#
if test "$EDITMOTD" != no
thenuname -a > /etc/motd.tmpsed 1d /etc/motd >> /etc/motd.tmpmv /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
thenSYSTEMDATE=`date -u +%4Y%2m%2d%2H%2M%2S`read TIMESTAMP < /etc/timestampif [ ${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 stopfi
fi
exit 0
(2) 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 INFOPATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"[ -x /sbin/ifup ] || exit 0check_network_file_systems() {[ -e /proc/mounts ] || return 0if [ -e /etc/iscsi/iscsi.initramfs ]; thenecho "not deconfiguring network interfaces: iSCSI root is mounted."exit 0fiexec 9<&0 < /proc/mountswhile read DEV MTPT FSTYPE REST; docase $DEV in/dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)echo "not deconfiguring network interfaces: network devices still mounted."exit 0;;esaccase $FSTYPE innfs|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;;esacdoneexec 0<&9 9<&-
}check_network_swap() {[ -e /proc/swaps ] || return 0exec 9<&0 < /proc/swapswhile read DEV MTPT FSTYPE REST; docase $DEV in/dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)echo "not deconfiguring network interfaces: network swap still mounted."exit 0;;esacdoneexec 0<&9 9<&-
}case "$1" in
start)echo -n "Configuring network interfaces... "sysctl -e -p /etc/sysctl.conf >/dev/null 2>&1ifup -aecho "done.";;stop)check_network_file_systemscheck_network_swapecho -n "Deconfiguring network interfaces... "ifdown -aecho "done.";;force-reload|restart)echo "Running $0 $1 is deprecated because it may not enable again some interfaces"echo "Reconfiguring network interfaces... "ifdown -a || trueifup -aecho "done.";;*)echo "Usage: /etc/init.d/networking {start|stop}"exit 1;;
esacexit 0
S01rsyslogd
#!/bin/shDAEMON="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 splittingstart-stop-daemon -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \-- $RSYSLOGD_ARGSstatus=$?if [ "$status" -eq 0 ]; thenecho "OK"elseecho "FAIL"fireturn "$status"
}stop() {printf 'Stopping %s: ' "$DAEMON"start-stop-daemon -K -q -p "$PIDFILE"status=$?if [ "$status" -eq 0 ]; thenecho "OK"elseecho "FAIL"fireturn "$status"
}restart() {stopsleep 1start
}case "$1" instart|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-nodmhawkbot@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/functionsfor x in $(cat /proc/cmdline); docase $x inx11=false)echo "X Server disabled" exit 0;;;esac
donecase "$1" instart)# We don't want this script to block the rest of the boot processif [ "$2" != "background" ]; then$0 $1 background &else# work around from /etc/X11/Xinitexport USER=rootexport HOME=/home/rootif [ ! -d $HOME ] && [ -d /root ]; thenHOME=/rootfi. /etc/profileecho "Starting Xserver". /etc/X11/xserver-common#xinit /etc/X11/Xsession -- `which $XSERVER` $ARGS >/var/log/Xsession.log 2>&1fi ;;stop)echo "Stopping XServer"killproc xinit;;restart)$0 stopsleep 1$0 start;;*)echo "usage: $0 { start | stop | restart }";;
esacexit 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/functionsDAEMON=/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.dtest -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
fitest "$ENABLED" != "0" || exit 0start_it_up()
{mkdir -p "`dirname $PIDFILE`"if [ -e $PIDFILE ]; thenPIDDIR=/proc/$(cat $PIDFILE)if [ -d ${PIDDIR} -a "$(readlink -f ${PIDDIR}/exe)" = "${DAEMON}" ]; then echo "$DESC already started; not starting."elseecho "Removing stale PID file $PIDFILE."rm -f $PIDFILEfifiif [ ! -d $UUIDDIR ]; thenmkdir -p $UUIDDIRchown $DAEMONUSER $UUIDDIRchgrp $DAEMONUSER $UUIDDIRfidbus-uuidgen --ensure echo -n "Starting $DESC: "start-stop-daemon -o --start --quiet --pidfile $PIDFILE \--user $DAEMONUSER --exec $DAEMON -- --system $PARAMSecho "$NAME."if [ -d $EVENTDIR ]; thenrun-parts --arg=start $EVENTDIRfi
}shut_it_down()
{if [ -d $EVENTDIR ]; then# TODO: --reverse when busybox supports itrun-parts --arg=stop $EVENTDIRfiecho -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 $PARAMSecho "$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" instart)start_it_up;;stop)shut_it_down;;status)status $DAEMONexit $?;;reload|force-reload)reload_it;;restart)shut_it_downsleep 1start_it_up;;*)echo "Usage: /etc/init.d/$NAME {start|stop|status|restart|reload|force-reload}" >&2exit 1;;
esacexit 0
S05connman
#!/bin/shDAEMON=/usr/sbin/connmand
PIDFILE=/var/run/connmand.pid
DESC="Connection Manager"if [ -f /etc/default/connman ] ; then. /etc/default/connman
fiset -enfsroot=0exec 9<&0 < /proc/mounts
while read dev mtpt fstype rest; doif test $mtpt = "/" ; thencase $fstype innfs | nfs4)nfsroot=1break;;*);;esacfi
donedo_start() {EXTRA_PARAM=""if test $nfsroot -eq 1 ; thenNET_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" ]; thenNET_ADDR=`cat /proc/cmdline | sed -ne 's/^.*eth[0-9]:\([^ :]*\).*$/\1/p'`fiif [ ! -z "$NET_ADDR" ]; thenif [ "$NET_ADDR" = dhcp ]; thenethn=`dmesg | grep "device=eth" | sed -e "s/^.*\(eth[0-9]\)\(.*\)/\1/"`if [ ! -z "$ethn" ]; thenEXTRA_PARAM="-I $ethn"fielsefor i in $NET_DEVS; doADDR=`ifconfig $i | sed 's/addr://g' | sed -ne 's/^.*inet \([0-9.]*\) .*$/\1/p'`if [ "$NET_ADDR" = "$ADDR" ]; thenEXTRA_PARAM="-I $i"breakfidonefififiif [ -f /usr/share/connman/wired-setup ] ; then. /usr/share/connman/wired-setupfi$DAEMON $EXTRA_PARAM
}do_stop() {start-stop-daemon --stop --name connmand --quiet
}case "$1" instart)echo "Starting $DESC"do_start;;stop)echo "Stopping $DESC"do_stop;;restart|force-reload)echo "Restarting $DESC"do_stopsleep 1do_start;;*)echo "Usage: $0 {start|stop|restart|force-reload}" >&2exit 1;;
esacexit 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.pidDROPBEAR_PORT=22
DROPBEAR_EXTRA_ARGS=
NO_START=0set -etest ! -r /etc/default/dropbear || . /etc/default/dropbear
test "$NO_START" = "0" || exit 0
test -x "$DAEMON" || exit 0
test ! -h /var/service/dropbear || exit 0readonly_rootfs=0
for flag in `awk '{ if ($2 == "/") { split($4,FLAGS,",") } }; END { for (f in FLAGS) print FLAGS[f] }' </proc/mounts`; docase $flag inro)readonly_rootfs=1;;esac
doneif [ $readonly_rootfs = "1" ]; thenmkdir -p /var/lib/dropbearDROPBEAR_RSAKEY_DEFAULT="/var/lib/dropbear/dropbear_rsa_host_key"DROPBEAR_DSSKEY_DEFAULT="/var/lib/dropbear/dropbear_dss_host_key"
elseDROPBEAR_RSAKEY_DEFAULT="/etc/dropbear/dropbear_rsa_host_key"DROPBEAR_DSSKEY_DEFAULT="/etc/dropbear/dropbear_dss_host_key"
fitest -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; docase $t inrsa)if [ -f "$DROPBEAR_RSAKEY" -a ! -s "$DROPBEAR_RSAKEY" ]; thenrm $DROPBEAR_RSAKEY || truefitest -f $DROPBEAR_RSAKEY || dropbearkey -t rsa -f $DROPBEAR_RSAKEY;;dsa)if [ -f "$DROPBEAR_DSSKEY" -a ! -s "$DROPBEAR_DSSKEY" ]; thenrm $DROPBEAR_DSSKEY || truefitest -f $DROPBEAR_DSSKEY || dropbearkey -t dss -f $DROPBEAR_DSSKEY;;esac
done
}case "$1" instart)echo -n "Starting $DESC: "gen_keysKEY_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_ARGSecho "$NAME.";;stop)echo -n "Stopping $DESC: "start-stop-daemon -K -x "$DAEMON" -p $PIDFILEecho "$NAME.";;restart|force-reload)echo -n "Restarting $DESC: "start-stop-daemon -K -x "$DAEMON" -p $PIDFILEsleep 1KEY_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_ARGSecho "$NAME.";;*)N=/etc/init.d/$NAMEecho "Usage: $N {start|stop|restart|force-reload}" >&2exit 1;;
esacexit 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/functionstest -f /usr/sbin/rpcbind || exit 0OPTIONS=""
if [ -f /etc/default/rpcbind ]
then. /etc/default/rpcbind
elif [ -f /etc/rpcbind.conf ]
then. /etc/rpcbind.conf
fistart ()
{echo -n "Starting rpcbind daemon..."if pidof /usr/sbin/rpcbind >/dev/null; thenecho "already running."exit 0fistart-stop-daemon --start --quiet --exec /usr/sbin/rpcbind -- "$@"if [ $? -eq 0 ]; thenecho "done."elseecho "failed."fi
}stop ()
{echo "Stopping rpcbind daemon..."if ! pidof /usr/sbin/rpcbind >/dev/null; thenecho "not running."return 0fistart-stop-daemon --stop --quiet --exec /usr/sbin/rpcbindif [ $? -eq 0 ]; thenecho "done."elseecho "failed."fi
}case "$1" instart)start $OPTIONS;;stop)stop;;force-reload)stopstart $OPTIONS;;restart)stopstart $OPTIONS;;status)status /usr/sbin/rpcbind;;*)echo "Usage: /etc/init.d/rpcbind {start|stop|force-reload|restart|status}"exit 1;;
esacexit $?
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
docase "$device" in""|\#*)continue;;esaccase "$options" in*noauto*)continue;;esacif test "$fstype" = nfsthenmount_nfs=yescase "$options" in*nolock*);;*)rpcbind=yes;;esacfiif test "$fstype" = smbfsthenmount_smb=yesfiif test "$fstype" = ncpfsthenmount_ncp=yesfiif test "$fstype" = cifsthenmount_cifs=yesfi
doneexec 0>&1if test "$rpcbind" = yes
thenif test -x /usr/sbin/rpcbindthenecho -n "Starting rpcbind... "start-stop-daemon --start --quiet --exec /usr/sbin/rpcbindsleep 2fi
fiif test "$mount_nfs" = yes || test "$mount_smb" = yes || test "$mount_ncp" = yes || test "$mount_cifs" = yes
thenecho "Mounting remote filesystems..."test "$mount_nfs" = yes && mount -a -t nfstest "$mount_smb" = yes && mount -a -t smbfstest "$mount_ncp" = yes && mount -a -t ncpfstest "$mount_cifs" = yes && mount -a -t cifs
fi) < /etc/fstabexit 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/functionstest -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" instart)start_statd;;stop)stop_statd;;status)status $NFS_STATDexit $?;;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/functionsPATH=/bin:/usr/bin:/sbin:/usr/sbin[ -f /etc/default/rcS ] && . /etc/default/rcS
[ -f /etc/default/apmd ] && . /etc/default/apmdcase "$1" instart)echo -n "Starting advanced power management daemon: "start-stop-daemon -S -x /usr/sbin/apmd -- \-P /etc/apm/apmd_proxy $APMDif [ $? = 0 ]; thenecho "apmd."elseecho "(failed.)"fi;;stop)echo -n "Stopping advanced power management daemon: "start-stop-daemon -K \-x /usr/sbin/apmdecho "apmd.";;status)status /usr/sbin/apmd;exit $?;;restart|force-reload) $0 stop$0 startexit;;*)echo "Usage: /etc/init.d/apmd {start|stop|status|restart|force-reload}"exit 1;;
esacexit 0
S20atd
#!/bin/sh
#
# Starts at daemon
#umask 077# Source function library.
. /etc/init.d/functionsstart() {echo -n "Starting atd: "start-stop-daemon --start --quiet --pidfile /var/run/atd.pid --background --exec /usr/sbin/atd -- -fecho "OK"
}
stop() {echo -n "Stopping atd: "start-stop-daemon --stop --quiet --pidfile /var/run/atd.pidecho "OK"
}
restart() {stopstart
}case "$1" instart)start;;stop)stop;;restart|reload)restart;;status)status /usr/sbin/atd;;*)echo $"Usage: $0 {start|stop|restart|status}"exit 1
esacexit $?
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" instart)if [ "$VERBOSE" != no ]thenecho "System time was `date`."echo "Setting the System Clock using the Hardware Clock as reference..."fiif [ "$HWCLOCKACCESS" != no ]thenif [ -z "$TZ" ]thenhwclock $tz --hctosyselseTZ="$TZ" hwclock $tz --hctosysfifiif [ "$VERBOSE" != no ]thenecho "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 ]thenecho "Saving the System Clock time to the Hardware Clock..."fiif [ "$HWCLOCKACCESS" != no ]thenhwclock $tz --systohcfiif [ "$VERBOSE" != no ]thenecho "Hardware Clock updated to `date`."fiexit 0;;show)if [ "$HWCLOCKACCESS" != no ]thenhwclock $tz --showfi;;*)echo "Usage: hwclock.sh {start|stop|show|reload|restart}" >&2echo " start sets kernel (system) clock from hardware (RTC) clock" >&2echo " stop and reload set hardware (RTC) clock from kernel (system) clock" >&2exit 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 nfsdgrep -q nfsd /proc/filesystems || {echo NFS daemon support not enabled in kernelexit 1}grep -q nfsd /proc/mounts || mount -t nfsd nfsd /proc/fs/nfsdgrep -q nfsd /proc/mounts || {echo nfsd filesystem could not be mounted at /proc/fs/nfsdexit 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 doif pidof nfsd >/dev/nullthenecho -n .sleep 1elsereturn 0fidonereturn 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 nfsdif delay_nfsd || {echo failedecho ' using signal 9: 'start-stop-daemon --stop --quiet --signal 9 --name nfsddelay_nfsd}thenecho doneelseecho failedfi
}#----------------------------------------------------------------------
#
# 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" instart)exportfs -rstart_nfsd "$NFS_SERVERS"start_mountdtest -r /etc/exports && exportfs -a;;stop) exportfs -uastop_mountdstop_nfsd;;status)status /usr/sbin/rpc.mountdRETVAL=$?status nfsdrval=$?[ $RETVAL -eq 0 ] && exit $rvalexit $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" ]; thenreturn 1fiecho " * $@"}# 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 mountedTPUT=/usr/bin/tputEXPR=/usr/bin/exprif [ -x $TPUT ] && [ -x $EXPR ] && $TPUT hpa 60 >/dev/null 2>&1; thenCOLS=`$TPUT cols`if [ -n "$COLS" ]; thenCOL=`$EXPR $COLS - 7`elseCOL=73fiUP=`$TPUT cuu1`END=`$TPUT hpa $COL`START=`$TPUT hpa 0`RED=`$TPUT setaf 1`NORMAL=`$TPUT op`if [ $1 -eq 0 ]; thenecho "$UP$END[ ok ]"elseecho -e "$UP$START $RED*$NORMAL$END[${RED}fail${NORMAL}]"fielseif [ $1 -eq 0 ]; thenecho " ...done."elseecho " ...fail!"fifireturn $1}log_warning_msg () {if log_use_fancy_output; thenYELLOW=`$TPUT setaf 3`NORMAL=`$TPUT op`echo "$YELLOW*$NORMAL $@"elseecho "$@"fi}fi#set -ePATH=/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-daemonif [ "$AVAHI_DAEMON_START" != "1" -a "$1" != "stop" ]; thenlog_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 0if [ -s /etc/localtime ]; thenif [ ! -d /etc/avahi/etc ]; thenmkdir -p /etc/avahi/etc >/dev/null 2>&1ficp -fp /etc/localtime /etc/avahi/etc >/dev/null 2>&1fi;$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 -cstatus=$?if [ $status = 0 ]; thenecho "$DESC is running"return 0elseecho "$DESC is not running"return 3fi
}case "$1" instart)log_begin_msg "Starting $DESC: $NAME"d_startlog_end_msg $?;;stop)log_begin_msg "Stopping $DESC: $NAME"d_stoplog_end_msg $?;;reload)log_begin_msg "Reloading services for $DESC: $NAME"d_reloadlog_end_msg $?;;restart|force-reload)log_begin_msg "Restarting $DESC: $NAME"$DAEMON -c && d_stopd_startlog_end_msg $?;;status)d_status;;*)echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|reload|status}" >&2exit 1;;
esacexit $?
S22ofono
#!/bin/shDAEMON=/usr/sbin/ofonod
PIDFILE=/var/run/ofonod.pid
DESC="Telephony daemon"if [ -f /etc/default/ofono ] ; then. /etc/default/ofono
fiset -edo_start() {$DAEMON
}do_stop() {start-stop-daemon --stop --name ofonod --quiet
}case "$1" instart)echo "Starting $DESC"do_start;;stop)echo "Stopping $DESC"do_stop;;restart|force-reload)echo "Restarting $DESC"do_stopsleep 1do_start;;*)echo "Usage: $0 {start|stop|restart|force-reload}" >&2exit 1;;
esacexit 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 INFODAEMON=/usr/libexec/nfc/neard
PIDFILE=/var/run/neard.pid
DESC="Linux NFC daemon"if [ -f /etc/default/neard ] ; then. /etc/default/neard
fiset -edo_start() {$DAEMON
}do_stop() {start-stop-daemon --stop --name neard --quiet
}case "$1" instart)echo "Starting $DESC"do_start;;stop)echo "Stopping $DESC"do_stop;;restart|force-reload)echo "Restarting $DESC"do_stopsleep 1do_start;;*)echo "Usage: $0 {start|stop|restart|force-reload}" >&2exit 1;;
esacexit 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 INFOCROND=/usr/sbin/crond
CONFIG=/etc/sysconfig/crond[ -f $CONFIG ] || exit 1
[ -x $CROND ] || exit 1. $CONFIG# Source function library.
. /etc/init.d/functionscase "$1" instart)echo -n "Starting crond: "start-stop-daemon --start --quiet --exec $CROND -- $CRONDARGSRETVAL=$?if [ $RETVAL -eq 0 ] ; thenecho "OK"elseecho "FAIL"fi;;stop)echo -n "Stopping crond: "start-stop-daemon --stop --quiet --pidfile /var/run/crond.pidRETVAL=$?if [ $RETVAL -eq 0 ] ; thenecho "OK"elseecho "FAIL"fi;;status)status crondexit $?;;restart)$0 stop && sleep 1 && $0 start;;*)echo "Usage: /etc/init.d/crond {start|stop|status|restart}"exit 1
esacexit 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 INFOPATH=/sbin:/usr/sbin:/bin:/usr/bindo_start() {if [ -x /etc/rc.local ]; thenecho -n "Running local boot scripts (/etc/rc.local)"/etc/rc.local[ $? = 0 ] && echo "." || echo "error"return $ESfi
}case "$1" instart)do_start;;restart|reload|force-reload)echo "Error: argument '$1' not supported" >&2exit 3;;stop);;*)echo "Usage: $0 start|stop" >&2exit 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 INFOif test -f /etc/nologin.boot
thenrm -f /etc/nologin /etc/nologin.boot
fiexit 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 INFOPATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/sbin/bootlogd
NAME=bootlogd
DESC="Bootlog daemon"# source function library
. /etc/init.d/functionstest -f $DAEMON || exit 0[ -r /etc/default/bootlogd ] && . /etc/default/bootlogd## set -e # not neededcase "$BOOTLOGD_ENABLE" in[Nn]*)exit 0;;
esacSTOPPER=
ACTION="$1"
case "$0" in*stop-bootlog*)STOPPER=Yif [ "$ACTION" = start ]thenACTION=stopfi;;
esaccase "$ACTION" instart)[ "${VERBOSE}" != "no" ] && echo -n "Starting $DESC: "if [ -d /proc/1/. ]thenumask 027start-stop-daemon --start --quiet \--exec $DAEMON -- -r -celse$DAEMON -r -cfi[ "${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 $DAEMONif [ "$STOPPER" ] && [ "$(which savelog 2>/dev/null)" ] && \[ -f /var/log/boot ] && [ -f /var/log/boot~ ]thencd /var/logchgrp adm bootsavelog -p -c 5 boot > /dev/null 2>&1mv boot.0 bootmv boot~ boot.0fi[ "${VERBOSE}" != "no" ] && echo "$NAME.";;restart|force-reload)echo -n "Restarting $DESC: "start-stop-daemon --stop --quiet --exec $DAEMONsleep 1start-stop-daemon --start --quiet --exec $DAEMONecho "$NAME.";;status)status $DAEMONexit $?;;*)N=${0##*/}echo "Usage: $N {start|stop|status|restart|force-reload}" >&2exit 1;;
esacexit 0
2 安卓启动脚本
init.rc
on early-init# Set init and its forked children's oom_adj.write /proc/1/oom_adj -16start ueventd# create mountpointsmkdir /mnt 0775 root systemon initsysclktz 0loglevel 3# setup the global environmentexport PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbinexport LD_LIBRARY_PATH /vendor/lib:/system/libexport ANDROID_BOOTLOGO 1export ANDROID_ROOT /systemexport ANDROID_ASSETS /system/appexport ANDROID_DATA /dataexport ASEC_MOUNTPOINT /mnt/asecexport LOOP_MOUNTPOINT /mnt/obbexport 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 compatibilitysymlink /system/etc /etcsymlink /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 accountingmkdir /acctmount cgroup none /acct cpuacctmkdir /acct/uidmkdir /systemmkdir /data 0771 system systemmkdir /cache 0770 system cachemkdir /config 0500 root root# Directory for putting things only root should see.mkdir /mnt/secure 0700 root root# Directory for staging bindmountsmkdir /mnt/secure/staging 0700 root root# Directory-target for where the secure container# imagefile directory will be bind-mountedmkdir /mnt/secure/asec 0700 root root# Secure container public mount points.mkdir /mnt/asec 0700 root systemmount tmpfs tmpfs /mnt/asec mode=0755,gid=1000# Filesystem image public mount points.mkdir /mnt/obb 0700 root systemmount tmpfs tmpfs /mnt/obb mode=0755,gid=1000write /proc/sys/kernel/panic_on_oops 1write /proc/sys/kernel/hung_task_timeout_secs 0write /proc/cpu/alignment 4write /proc/sys/kernel/sched_latency_ns 10000000write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000write /proc/sys/kernel/sched_compat_yield 1write /proc/sys/kernel/sched_child_runs_first 0write /proc/sys/kernel/randomize_va_space 2# Create cgroup mount points for process groupsmkdir /dev/cpuctlmount cgroup none /dev/cpuctl cpuchown system system /dev/cpuctlchown system system /dev/cpuctl/taskschmod 0777 /dev/cpuctl/taskswrite /dev/cpuctl/cpu.shares 1024mkdir /dev/cpuctl/fg_boostchown system system /dev/cpuctl/fg_boost/taskschmod 0777 /dev/cpuctl/fg_boost/taskswrite /dev/cpuctl/fg_boost/cpu.shares 1024mkdir /dev/cpuctl/bg_non_interactivechown system system /dev/cpuctl/bg_non_interactive/taskschmod 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_qtaguidon fs
# mount mtd partitions# Mount /system rw first to give the filesystem a chance to save a checkpointmount yaffs2 mtd@system /systemmount yaffs2 mtd@system /system rw remountmount yaffs2 mtd@userdata /data nosuid nodevmount yaffs2 mtd@cache /cache nosuid nodevon 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 + defaultschown system cache /cachechmod 0770 /cache# This may have been created by the recovery system with odd permissionschown system cache /cache/recoverychmod 0770 /cache/recovery#change permissions on vmallocinfo so we can grab it from bugreportschown root log /proc/vmallocinfochmod 0440 /proc/vmallocinfo#change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stackschown root system /proc/kmsgchmod 0440 /proc/kmsgchown root system /proc/sysrq-triggerchmod 0220 /proc/sysrq-trigger# create the lost+found directories, so as to enforce our permissionsmkdir /cache/lost+found 0770 root rooton post-fs-data# We chown/chmod /data again so because mount is run as root + defaultschown system system /datachmod 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 triggercopy /proc/apanic_console /data/dontpanic/apanic_consolechown root log /data/dontpanic/apanic_consolechmod 0640 /data/dontpanic/apanic_consolecopy /proc/apanic_threads /data/dontpanic/apanic_threadschown root log /data/dontpanic/apanic_threadschmod 0640 /data/dontpanic/apanic_threadswrite /proc/apanic_console 1# create basic filesystem structuremkdir /data/misc 01771 system misc###cym mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth###cym mkdir /data/misc/bluetooth 0770 system systemmkdir /data/misc/keystore 0700 keystore keystoremkdir /data/misc/keychain 0771 system systemmkdir /data/misc/vpn 0770 system vpnmkdir /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 wifichown bluetooth bluetooth /dev/ttySAC0chmod 0660 /dev/ttySAC0mkdir /data/local 0771 shell shellmkdir /data/local/tmp 0771 shell shellmkdir /data/data 0771 system systemmkdir /data/app-private 0771 system systemmkdir /data/app 0771 system systemmkdir /data/property 0700 root root# create dalvik-cache, so as to enforce our permissionsmkdir /data/dalvik-cache 0771 system system# create resource-cache and double-check the permsmkdir /data/resource-cache 0771 system systemchown system system /data/resource-cachechmod 0771 /data/resource-cache# create the lost+found directories, so as to enforce our permissionsmkdir /data/lost+found 0770 root root# create directory for DRM plug-insmkdir /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 1chown system system /sys/class/android_usb/android0/f_mass_storage/lun/filechmod 0660 /sys/class/android_usb/android0/f_mass_storage/lun/filechown system system /sys/class/android_usb/android0/f_rndis/ethaddrchmod 0660 /sys/class/android_usb/android0/f_rndis/ethaddron boot
# basic network initifup lohostname localhostdomainname localdomain# set RLIMIT_NICE to allow priorities from 19 to -20setrlimit 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 1write /proc/sys/vm/min_free_order_shift 4chown root system /sys/module/lowmemorykiller/parameters/adjchmod 0664 /sys/module/lowmemorykiller/parameters/adjchown root system /sys/module/lowmemorykiller/parameters/minfreechmod 0664 /sys/module/lowmemorykiller/parameters/minfree# Tweak background writeoutwrite /proc/sys/vm/dirty_expire_centisecs 200write /proc/sys/vm/dirty_background_ratio 5# Permissions for System Server and daemons.chown radio system /sys/android_power/statechown radio system /sys/android_power/request_statechown radio system /sys/android_power/acquire_full_wake_lockchown radio system /sys/android_power/acquire_partial_wake_lockchown radio system /sys/android_power/release_wake_lockchown radio system /sys/power/statechown radio system /sys/power/wake_lockchown radio system /sys/power/wake_unlockchmod 0660 /sys/power/statechmod 0660 /sys/power/wake_lockchmod 0660 /sys/power/wake_unlock#chy add for reset modemchown root radio /sys/devices/platform/smm_modem/controlchmod 0666 /sys/devices/platform/smm_modem/controlchmod 0777 /dev/modemctlchown system system /sys/class/timed_output/vibrator/enablechown system system /sys/class/leds/keyboard-backlight/brightnesschown system system /sys/class/leds/lcd-backlight/brightnesschown system system /sys/class/leds/button-backlight/brightnesschown system system /sys/class/leds/jogball-backlight/brightnesschown system system /sys/class/leds/red/brightnesschown system system /sys/class/leds/green/brightnesschown system system /sys/class/leds/blue/brightnesschown system system /sys/class/leds/red/device/grpfreqchown system system /sys/class/leds/red/device/grppwmchown system system /sys/class/leds/red/device/blinkchown system system /sys/class/leds/red/brightnesschown system system /sys/class/leds/green/brightnesschown system system /sys/class/leds/blue/brightnesschown system system /sys/class/leds/red/device/grpfreqchown system system /sys/class/leds/red/device/grppwmchown system system /sys/class/leds/red/device/blinkchown system system /sys/class/timed_output/vibrator/enablechown system system /sys/module/sco/parameters/disable_escochown system system /sys/kernel/ipv4/tcp_wmem_minchown system system /sys/kernel/ipv4/tcp_wmem_defchown system system /sys/kernel/ipv4/tcp_wmem_maxchown system system /sys/kernel/ipv4/tcp_rmem_minchown system system /sys/kernel/ipv4/tcp_rmem_defchown system system /sys/kernel/ipv4/tcp_rmem_maxchown 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,110208setprop net.tcp.buffersize.wifi 524288,1048576,2097152,262144,524288,1048576setprop net.tcp.buffersize.lte 524288,1048576,2097152,262144,524288,1048576setprop net.tcp.buffersize.umts 4094,87380,110208,4096,16384,110208setprop net.tcp.buffersize.hspa 4094,87380,262144,4096,16384,262144setprop net.tcp.buffersize.edge 4093,26280,35040,4096,16384,35040setprop net.tcp.buffersize.gprs 4092,8760,11680,4096,8760,11680setprop ro.nfc.port "I2C"chmod 0666 /dev/snfc-n2# Set this property so surfaceflinger is not started by system_initsetprop system_init.startsurfaceflinger 0class_start coreclass_start mainon nonencryptedclass_start late_starton chargerclass_start chargeron property:vold.decrypt=trigger_reset_mainclass_reset mainon property:vold.decrypt=trigger_load_persist_propsload_persist_propson property:vold.decrypt=trigger_post_fs_datatrigger post-fs-dataon property:vold.decrypt=trigger_restart_min_frameworkclass_start mainon property:vold.decrypt=trigger_restart_frameworkclass_start mainclass_start late_starton property:vold.decrypt=trigger_shutdown_frameworkclass_reset late_startclass_reset main# Used to disable USB when switching states
on property:sys.usb.config=nonestop adbdwrite /sys/class/android_usb/android0/enable 0write /sys/class/android_usb/android0/bDeviceClass 0setprop 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=adbwrite /sys/class/android_usb/android0/enable 0write /sys/class/android_usb/android0/idVendor 18d1write /sys/class/android_usb/android0/idProduct D002write /sys/class/android_usb/android0/functions $sys.usb.configwrite /sys/class/android_usb/android0/enable 1start adbdsetprop sys.usb.state $sys.usb.config# USB accessory configuration
on property:sys.usb.config=accessorywrite /sys/class/android_usb/android0/enable 0write /sys/class/android_usb/android0/idVendor 18d1write /sys/class/android_usb/android0/idProduct 2d00write /sys/class/android_usb/android0/functions $sys.usb.configwrite /sys/class/android_usb/android0/enable 1setprop sys.usb.state $sys.usb.config# USB accessory configuration, with adb
on property:sys.usb.config=accessory,adbwrite /sys/class/android_usb/android0/enable 0write /sys/class/android_usb/android0/idVendor 18d1write /sys/class/android_usb/android0/idProduct 2d01write /sys/class/android_usb/android0/functions $sys.usb.configwrite /sys/class/android_usb/android0/enable 1start adbdsetprop 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/ueventdclass corecriticalservice console /system/bin/shclass coreconsoledisabled# user shellgroup logon property:ro.debuggable=1start console# adbd is controlled via property triggers in init.<platform>.usb.rc
service adbd /sbin/adbdclass coredisabled# adbd on at boot in emulator
on property:ro.kernel.qemu=1start 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=1write /sys/class/android_usb/android0/enable 0restart adbdwrite /sys/class/android_usb/android0/enable 1service servicemanager /system/bin/servicemanagerclass coreuser systemgroup systemcriticalonrestart restart zygoteonrestart restart mediaonrestart restart surfaceflingeronrestart restart drmservice vold /system/bin/voldclass coresocket vold stream 0660 root mountioprio be 2service netd /system/bin/netdclass mainsocket netd stream 0660 root systemsocket dnsproxyd stream 0660 root inetservice debuggerd /system/bin/debuggerdclass 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/ttyUSB1class mainsocket rild stream 660 root radiosocket rild-debug stream 660 radio systemuser rootgroup radio cache inet misc audio sdcard_rw log
service pppd_gprs /system/bin/logwrapper /etc/ppp/call-pppdclass mainuser rootgroup radio cache inet miscdisabledoneshot
service dhcpd_start /system/bin/logwrapper /etc/ppp/dhcpd_startclass mainuser rootgroup radio dhcpdisabledoneshotservice dhcp_stop /system/bin/logwrapper /etc/ppp/dhcpd_stopclass mainuser rootgroup radio dhcpdisabledoneshot#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 addservice surfaceflinger /system/bin/surfaceflingerclass mainuser systemgroup graphicsonrestart restart zygoteservice zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-serverclass mainsocket zygote stream 666onrestart write /sys/android_power/request_state wakeonrestart write /sys/power/state ononrestart restart mediaonrestart restart netdservice drm /system/bin/drmserverclass mainuser drmgroup system inet drmrpcservice media /system/bin/mediaserverclass mainuser mediagroup audio camera inet net_bt net_bt_admin net_bw_acct drmrpcioprio rt 4service bootanim /system/bin/bootanimationclass mainuser graphicsgroup graphicsdisabledoneshotservice dbus /system/bin/dbus-daemon --system --noforkclass mainsocket dbus stream 660 bluetooth bluetoothuser bluetoothgroup bluetooth net_bt_adminservice bluetoothd /system/bin/bluetoothd -nclass mainsocket bluetooth stream 660 bluetooth bluetoothsocket 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 capabilitiesgroup bluetooth net_bt_admin miscdisabledservice hfag /system/bin/sdptool add --channel=10 HFAGclass mainuser bluetoothgroup bluetooth net_bt_admindisabledoneshotservice hsag /system/bin/sdptool add --channel=11 HSAGclass mainuser bluetoothgroup bluetooth net_bt_admindisabledoneshotservice opush /system/bin/sdptool add --channel=12 OPUSHclass mainuser bluetoothgroup bluetooth net_bt_admindisabledoneshotservice pbap /system/bin/sdptool add --channel=19 PBAPclass mainuser bluetoothgroup bluetooth net_bt_admindisabledoneshotservice installd /system/bin/installdclass mainsocket installd stream 600 system systemservice flash_recovery /system/etc/install-recovery.shclass mainoneshotservice abtfilt /system/bin/wlan_tool abtfiltclass mainuser bluetoothgroup system bluetooth net_bt_admin inetdisabledoneshot
service racoon /system/bin/racoonclass mainsocket racoon stream 600 system system# IKE uses UDP port 500. Racoon will setuid to vpn after binding the port.group vpn net_admin inetdisabledoneshotservice mtpd /system/bin/mtpdclass mainsocket mtpd stream 600 system systemuser vpngroup vpn net_admin inet net_rawdisabledoneshotservice keystore /system/bin/keystore /data/misc/keystoreclass mainuser keystoregroup keystoresocket keystore stream 666service dumpstate /system/bin/dumpstate -sclass mainsocket dumpstate stream 0660 shell logdisabledoneshot#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-initexport EXTERNAL_STORAGE /mnt/sdcardmkdir /mnt/sdcard 0000 system systemmkdir /mnt/sdcard2 0775 system systemmkdir /mnt/udisk 0775 system systemmkdir /mnt/udisk1 0775 system systemsymlink /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/shclass coreconsolegroup log#add by cym 20130622
service cfg_audio /system/bin/cfg_audiouser systemgroup systemclass mainoneshot
#end addon bootsetprop ro.build.product smdk4x12setprop ro.product.device smdk4x12setprop ro.radio.noril yeson fsmount ext4 /dev/block/mmcblk0p2 /system ro wait
# mount ext4 /dev/block/mmcblk0p3 /data wait nosuid nodev noatime nomblk_io_submitmount ext4 /dev/block/mmcblk0p3 /data nosuid nodev noatime wait usedm discard,noauto_da_alloc,nodelallocmount ext4 /dev/block/mmcblk0p4 /cache wait nosuid nodev noatime nomblk_io_submit
# jmq.disable
# setprop ro.crypto.fuse_sdcard true# Permissions for backlightchmod 0665 /sys/class/backlight/pwm-backlight.0/brightnesschown system system /sys/class/backlight/pwm-backlight.0/brightness
# Permissions for btpowerchown 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 GPSchmod 0777 /dev/ttySAC3chmod 0777 /dev/AGPSchown root root /datachmod 0771 /data#add by cym support for RFIDchmod 0777 /dev/ttySAC1chown root root /datachmod 0771 /data#yyd- 111206, add sensorchmod 0777 /dev/mpuchmod 0777 /dev/mpuirq
# chmod 0777 /dev/accelirqchmod 0777 /dev/timerirq#add by cym 20130305chmod 0777 /linuxrcchmod 0777 /dev/adcchmod 0777 /dev/buzzer_ctlchmod 0777 /dev/max485_ctl_pinchmod 0777 /dev/ledschmod 0777 /dev/rc522chmod 0777 /dev/ttySAC0chmod 0777 /dev/ttySAC2chmod 0777 /dev/relay_ctl
init.smdk4x12.usb.rc
on bootwrite /sys/class/android_usb/android0/iManufacturer $ro.product.manufacturerwrite /sys/class/android_usb/android0/iProduct $ro.product.modelwrite /sys/class/android_usb/android0/iSerial $ro.serialnowrite /sys/class/android_usb/android0/f_mass_storage/inquiry_string "Google Nexus S 0100"write /sys/class/android_usb/android0/f_rndis/manufacturer Samsungwrite /sys/class/android_usb/android0/f_rndis/vendorID 18d1write /sys/class/android_usb/android0/f_rndis/wceis 1on property:sys.usb.config=mass_storagewrite /sys/class/android_usb/android0/enable 0write /sys/class/android_usb/android0/idVendor 18d1write /sys/class/android_usb/android0/idProduct 4e21write /sys/class/android_usb/android0/functions $sys.usb.configwrite /sys/class/android_usb/android0/enable 1setprop sys.usb.state $sys.usb.configon property:sys.usb.config=mass_storage,adbwrite /sys/class/android_usb/android0/enable 0write /sys/class/android_usb/android0/idVendor 18d1write /sys/class/android_usb/android0/idProduct 4e22write /sys/class/android_usb/android0/functions $sys.usb.configwrite /sys/class/android_usb/android0/enable 1start adbdsetprop sys.usb.state $sys.usb.configon property:sys.usb.config=rndiswrite /sys/class/android_usb/android0/enable 0write /sys/class/android_usb/android0/idVendor 18d1write /sys/class/android_usb/android0/idProduct 4e23write /sys/class/android_usb/android0/functions $sys.usb.configwrite /sys/class/android_usb/android0/bDeviceClass 224write /sys/class/android_usb/android0/enable 1setprop sys.usb.state $sys.usb.configon property:sys.usb.config=rndis,adbwrite /sys/class/android_usb/android0/enable 0write /sys/class/android_usb/android0/idVendor 18d1write /sys/class/android_usb/android0/idProduct 4e24write /sys/class/android_usb/android0/functions $sys.usb.configwrite /sys/class/android_usb/android0/bDeviceClass 224write /sys/class/android_usb/android0/enable 1start adbdsetprop sys.usb.state $sys.usb.configon property:sys.usb.config=mtp,adbwrite /sys/class/android_usb/android0/enable 0write /sys/class/android_usb/android0/idVendor 18d1write /sys/class/android_usb/android0/idProduct 4e26write /sys/class/android_usb/android0/functions $sys.usb.configwrite /sys/class/android_usb/android0/enable 1start adbdsetprop sys.usb.state $sys.usb.configon property:sys.usb.config=ptp,adbwrite /sys/class/android_usb/android0/enable 0write /sys/class/android_usb/android0/idVendor 18d1write /sys/class/android_usb/android0/idProduct 4e27write /sys/class/android_usb/android0/functions $sys.usb.configwrite /sys/class/android_usb/android0/enable 1start adbdsetprop 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 pathmkdir /data/bluetooth 0711 bluetooth bluetooth# wpa_supplicant control socket for android wifi.cmkdir /data/misc/wifi 0770 wifi wifimkdir /data/misc/wifi/sockets 0770 wifi wifichmod 0770 /data/misc/wifichmod 0660 /data/misc/wifi/wpa_supplicant.confchmod 0660 /data/misc/wifi/p2p_supplicant.confchown wifi wifi /data/misc/wifichown wifi wifi /data/misc/wifi/wpa_supplicant.confchown wifi wifi /data/misc/wifi/p2p_supplicant.conf# wpa_supplicant socketmkdir /data/system 0771 system systemmkdir /data/system/wpa_supplicant 0771 wifi wifichmod 0771 /data/system/wpa_supplicantchown wifi wifi /data/system/wpa_supplicantmkdir /data/misc/p2p_supplicant 0771 wifi wifichmod 0771 /data/misc/p2p_supplicantchown wifi wifi /data/misc/p2p_supplicant# wpa_supplicant control socket for android wifi.cmkdir /data/misc/wifi 0770 wifi wifimkdir /data/misc/dhcp 0771 dhcp dhcpmkdir /data/wifi 0771 wifi wifichown dhcp dhcp /data/misc/dhcpsetprop wifi.interface "wlan0"setprop wifi.direct.multicast 1# Load common part modulesinsmod /system/lib/modules/mtk_hif_sdio.koinsmod /system/lib/modules/mtk_stp_wmt.koinsmod /system/lib/modules/mtk_stp_uart.ko# Load GPS moduleinsmod /system/lib/modules/mtk_stp_gps.ko# Load BlueZ moduleinsmod /system/lib/modules/hci_stp.ko# Load FM modulesinsmod /system/lib/modules/mt6620_fm_drv.koinsmod /system/lib/modules/mtk_fm_priv.ko# Load wifi modulesinsmod /system/lib/modules/mtk_wmt_wifi.ko WIFI_major=194insmod /system/lib/modules/wlan.ko#Create char device file for WMT, BT, GPS, FM
# mknod /dev/wmtWifi_test c 194 0chmod 0666 /dev/stpwmtchmod 0666 /dev/stpgps#chmod 0666 /dev/stpbtchmod 0666 /dev/fmchmod 0666 /dev/wmtWifichmod 0660 /dev/ttySAC0chmod 0666 /dev/gps# chmod 0660 /dev/wmtWifi_test
# chown system system /dev/wmtWifi_testchown system system /dev/wmtWifichown system system /dev/fmchown system system /dev/stpwmtchown system system /dev/stpgpschown system system /dev/ttySAC0#chown system system /dev/stpbtchown system system /dev/gpsmkdir /data/bluetooth 0711 bluetooth bluetooth# wpa_supplicant control socket for android wifi.cmkdir /data/misc/wifi 0770 wifi wifimkdir /data/misc/wifi/sockets 0770 wifi wifichmod 0770 /data/misc/wifichmod 0660 /data/misc/wifi/wpa_supplicant.confchmod 0660 /data/misc/wifi/p2p_supplicant.confchown wifi wifi /data/misc/wifichown wifi wifi /data/misc/wifi/wpa_supplicant.confchown wifi wifi /data/misc/wifi/p2p_supplicant.conf# wpa_supplicant socketmkdir /data/system 0771 system systemmkdir /data/system/wpa_supplicant 0771 wifi wifichmod 0771 /data/system/wpa_supplicantchown wifi wifi /data/system/wpa_supplicantmkdir /data/misc/p2p_supplicant 0771 wifi wifichmod 0771 /data/misc/p2p_supplicantchown wifi wifi /data/misc/p2p_supplicant# wpa_supplicant control socket for android wifi.cmkdir /data/misc/wifi 0770 wifi wifimkdir /data/misc/dhcp 0771 dhcp dhcpmkdir /data/wifi 0771 wifi wifichown dhcp dhcp /data/misc/dhcpsetprop wifi.interface "wlan0"setprop wifi.direct.multicast 1start 6620_launcher#
# MT6620 related device nodes & modules & configuration (begin)
## Encrypt phone functionsetprop vold.post_fs_data_done 1on 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/ttySAC0user systemgroup systemclass mainoneshot
# class mt6620_user_guardservice mnld /system/xbin/mnldsocket mnld stream 666 system systemdisabled#AGPS
#service agpsd /system/bin/mtk_agpsd
# class main
# socket agpsd stream 666 system systemchmod 770 /etc/agps_profiles_conf.xmlservice hald /system/bin/haldclass mainsocket hald stream 0660 root systemservice wpa_supplicant /system/bin/wpa_supplicant -dd -Dwext -iwlan0 -c /data/misc/wifi/wpa_supplicant.confgroup wifi system inetdisabledoneshotservice p2p_supplicant /system/bin/p2p_supplicant -dd -Dnl80211 -ip2p0 -c /data/misc/wifi/p2p_supplicant.confgroup wifi system inetdisabledoneshotservice dhcpcd_wlan0 /system/bin/dhcpcd -A -B -ddgroup system dhcpdisabledoneshotservice dhcpcd_p2p /system/bin/dhcpcd -A -B -ddclass maindisabledoneshotservice iprenew_wlan0 /system/bin/dhcpcd -nclass maindisabledoneshotservice dhcpcd_bnep0 /system/bin/dhcpcd -A -B -ddclass maindisabledoneshotservice hfag /system/bin/sdptool add --channel=10 HFAGuser bluetoothgroup bluetooth net_bt_admindisabledoneshotservice hsag /system/bin/sdptool add --channel=11 HSAGuser bluetoothgroup bluetooth net_bt_admindisabledoneshotservice opush /system/bin/sdptool add --channel=12 OPUSHuser bluetoothgroup bluetooth net_bt_admindisabledoneshotservice pbap /system/bin/sdptool add --channel=19 PBAPuser bluetoothgroup bluetooth net_bt_admindisabledoneshot# MT6620 related services (End)
3 ubuntu启动
linux 操作系统启动脚本相关推荐
- 浅谈-LINUX 操作系统启动过程
LINUX 操作系统启动过程 通过一段时间的学习已经对linux有了一定的了解,接下来就开始研究一下linux 操作系统的启动过程吧.当然这是为了让大家比较容易发现linux启动过程中容易发生问题的地 ...
- linux操作系统启动流程与kickstart文件制作
文章目录 一.Linux操作系统启动流程 1.1.简单回顾linux系统组成以及内核作用 1.2.简单了解一下磁盘构成以及相关基础知识 二.CentOS 启动流程(只适用于MBR类型的PC架构主机) ...
- Linux操作系统启动流程简单介绍
Linux 系统的启动,从计算机开机通电自检开始,一直到登陆系统,需要经历多个过程.了解 Linux操作系统的启动过程,对Linux操作系统更深入认识和日常的运维工作非常有帮助,感兴趣的朋友可以了解一 ...
- Linux 操作系统启动流程以及trouble shooting
2019独角兽企业重金招聘Python工程师标准>>> 最近在某个版块看到有人讨论GRUB的问题,这里是我个人的一些理解. 我想大部分还是正确的,但肯定也有理解错误的地方,在这里抛砖 ...
- 学Linux操作之前不得不了解的知识!!!
一.Linux命令基础 1.1 Shell 概述 在计算机科学中,Shell俗称壳(用来区别于核),是指"为使用者提供操作界面"的软件(命令解析器).它类似于DOS下的comman ...
- Linux操作指导专题
第1章命令行操作及常用命令使用 1.1命令行操作 1.1.1Shell简介 shell是用户和Linux操作系统之间的接口Linux中有多种shell其中缺省使用的是bash. Linux系统的she ...
- 2020-12-26 工作常用 Linux 操作:磁盘卸载、 自动化挂盘脚本 、磁盘分区合并、ansible、git 设置相关
[工作常用 Linux 操作:磁盘卸载. 自动化挂盘脚本 .磁盘多个分区合并.ansible .git 设置相关] 1.查看 欧拉系统 的版本号:rpm -q --provides euler0rel ...
- Linux实现开机900s后执行操作或脚本
1.将需要执行的操作写入脚本 # cat /opt/run.sh sleep 900 && echo $(date) >> /opt/test.txt # chmod +x ...
- linux内核cpu初始化,浅谈操作系统启动与内核初始化
迷茫的时候,就朝着热情的方向走. BIOS 的引导 当按下开机键,你的主板开始加电,在刚加电的时候电脑会做一些初始化寄存器的工作,比如将 CS代码段寄存器 设置为 0xFFFF ,将 IP指令寄存器 ...
最新文章
- vue修改代码同步页面_vue修改数组中对象属性值页面不同步更新渲染问题处理
- qt widget 窗口拉伸_QTDesigner的QVBoxLayout自动随窗口拉伸
- SeetaFace2 测试
- 工控设备 如何将数据发送到串口_AB PLC和西门子PLC之间需要交换数据
- 数据库学习建议之提高数据库速度的十条建议
- 奇妙的曲线--希尔伯特曲线
- 隐秘的角落里数亿场AI战争正在发生
- 应用优化前心路历程~
- 数据库sql创建标量值函数_使用JSON_VALUE()从JSON数据中提取标量值
- SQL Server 2012新增的内置函数尝试
- oracle附加数据库拒绝访问,Windows 添加任务计划报“0x80070005: 拒绝访问”的解决...
- 计算机组成原理——第七章
- axure文本框添加水印_Axure教程:限制输入框输入字数
- spring定时器时间表达式
- 代理服务器基本知识普及代理IP使用方法!
- hutool对称加密
- 谷歌个性化地图瓦片_对Google广告个性化的调查
- 关于IT程序员一些面试技巧
- 用python画蟒蛇
- lucene【转载】