Debugging notes --------------- By default, programs executed by init willdrop stdout and stderr into /dev/null. To help with debugging, you canexecute your program via the Andoird program logwrapper. This willredirect stdout/stderr into the Android logging system (accessed vialogcat). For example service akmd /system/bin/logwrapper/sbin/akmd
注2:讲述了一个新的命令
sysclktz Setthe system clock base (0 if system clock ticks in GMT)
注3:triggers
boot Thisis the first trigger that will occur when init starts (after /init.conf is loaded) = Triggers of this form occur when the property is set tothe specific value . device-added- device-removed- Triggers of these forms occur when a device node isadded orremoved. service-exited- Triggers of this form occur when the specified serviceexits.
disabledThis service will not automatically start with its class. Itmust be explicitly started by name.socket [ [ ] ]
Create a unix domain socket named /dev/socket/ andpass its fd to the launched process. Valid dgram andstream. user and groupdefault to 0.(type 实际中是放在name之后)
values includeuserChange to username before exec'ing this service. Currentlydefaults to root.group [ ]*Change to groupname before exec'ing this service. Additional groupnames beyondthe first, which is required, are used to set additional groups ofthe process (with setgroups()). Currently defaults toroot.capability [ ]+Set linux capability before exec'ing this serviceoneshotDo not restart the service when it exits.classSpecify a class name for the service. Allservices in a named class must start and stop together. A serviceis considered of class "default" if one is not specified via theclass option.
Triggers
Triggers are strings used to match certain kinds of events thatcause an action to occur.
Trigger
Description
bootThis is the first trigger that occurs when init starts (after/init.conf is loaded).=Triggers of this form occur when the property is set to thespecific value .device-added- device-removed-Triggers of these forms occur when a device node is added orremoved.service-exited-Triggers of this form occur when the specified serviceexits.
Commands
Command
Description
exec [ ]*Fork and execute a program (). This will block until theprogram completes execution. Try to avoid exec. Unlike thebuiltin commands, it runs the risk of getting init"stuck".export Set the environment variable equal to in the global environment(which will be inherited by all processes started after thiscommand is executed).ifupBring the network interface online.importParse an init config file, extending the currentconfiguration.hostnameSet the host name.class_startStart all services of the specified class if they are notalready running.class_stopStop all services of the specified class if they are currentlyrunning.domainnameSet the domain name.insmodInstall the module at .mkdirMake a directory at .mount
]*
Attempt to mount the named device at the directory
. This may be of the form mtd@name tospecify a mtd block device by name.
setkey- currenlty undefined -setprop Set system property to .setrlimit Set the rlimit for a resource.startStart a service running if it is not already running.stopStop a service from running if it is currently running.symlink Create a symbolic link at with the value .write [ ]*Open the file at and write one or more strings to it withwrite(2).
Properties
Init updates some system properties to provide some insightinto what it's doing:
Property
Description
init.actionEqual to the name of the action currently being executed or ""if none.init.commandEqual to the command being executed or "" if none.init.svc.State of a named service ("stopped", "running", or"restarting").
# create mountpoints and mount tmpfs on sqlite_stmt_journals mkdir/sdcard 0000 system system mkdir/system mkdir /data0771 system system mkdir /cache0770 system cache mkdir/config 0500 root root mkdir/sqlite_stmt_journals 01777 root root mount tmpfstmpfs /sqlite_stmt_journals size=4m
#{{ added by FriendlyARM mkdir/udisk 0000 system system mkdir /var0000 system system mount tmpfstmpfs /var size=2m mkdir/var/lock mkdir/var/run mkdir/var/log mount usbfsnone /proc/bus/usb -o devmode=0666 chmod 0666/dev/backlight-1wire #}}
# Create cgroup mount points for process groups mkdir/dev/cpuctl mount cgroupnone /dev/cpuctl cpu chown systemsystem /dev/cpuctl chown systemsystem /dev/cpuctl/tasks chmod 0777/dev/cpuctl/tasks write/dev/cpuctl/cpu.shares 1024
# mount mtd partitions # Mount/system rw first to give the filesystem a chance to save acheckpoint ## mountyaffs2 mtd@system /system ## mountyaffs2 mtd@system /system ro remount
# Wechown/chmod /data again so because mount is run as root +defaults ## mountyaffs2 mtd@userdata /data nosuid nodev chown systemsystem /data chmod 0771/data
# Createdump dir and collect dumps. # Do thisbefore we mount cache so eventually we can use cache for # storingdumps on platforms which do not have a dedicated dumppartition. mkdir/data/dontpanic chown rootlog /data/dontpanic chmod 0750/data/dontpanic