Android initialization language (init. *. rc, init. conf file format)

Source: Internet
Author: User

Android initialization language (init. *. rc, init. conf file format)

The Android initialization language contains four types of statements: Actions (Action), Commands (command), Services (service), and Options (Options ).

All of these are in the unit of action, and various marks are separated by spaces. The C-style backslash can be used to insert spaces between marks. Double quotation marks can also be used to prevent strings from being separated by spaces into multiple records.
The comment line starts with a pound sign (#) (it can start with a space ).
Actions and Services declare a new group. All commands or options belong to the recently stated group. Commands or options located before the first group will be ignored.
Actions and Services have a unique name. In case of duplicate names, the second statement will be ignored as an error. (??? Should we replace ignore with overwrite)

Actions (Action) www.2cto.com
----------
Actions is actually a series of Commands (Commands ). Actions has a trigger, which is used to determine the execution time of the action. When an action-compliant trigger entry
Each action in the queue is extracted in sequence, and each command in the action is executed in sequence. Init also controls other activities during the execution of these commands (

The form of Actions is as follows:

On <trigger>
<Command>
<Command>
<Command>

Services)
----------
A service is a program that is started during initialization and restarted upon exit (optional ). Services are as follows:

Service <name> <pathname> [<argument>] *
<Option>
<Option>
...

Options)
----------
Options is a modifier of Services. They influence when and how Services run.

Critical (key)
This is a key service for devices. If he exits more than four times in four minutes, the system will restart and enter the recovery mode.

Disabled (invalid)
This indicates that the service cannot be automatically started with the trigger. He must be explicitly started by name.

Setenv <name> <value> (set environment variables)
When the process starts, set the environment variable <name> to <value>.

Socket <name> <type> <perm> [<user> [<group>]
Create a socket named/dev/socket/<name> In the Uinx domain and pass its file descriptor to the started process. <Type> it must be "dgram" or"

User <username>
Change the User Name of the service before starting the service. The default value is root. (??? If possible, it should be nobody by default ). Currently, if your process requires L

Group <groupname> [<groupname>] *
Change the group name of the service before starting the service. Except (required) The first group name, the additional group name is usually used to set the supplemental group for the process (through setgroups ()

Oneshot
Do not restart when the service exits.

Class <name>
Specify a service class. All services of the same category can be started and stopped at the same time. If you do not use the class option to specify a class, the default class service is "default.

Onrestart
When the service is restarted, execute a command (for details below ).

Triggers)
----------
Triggers (trigger) is a string used to match a specific event type, used to make Actions (Action) occur.

Boot
This is the first Triggers triggered after init is executed ). (After/init. conf (start configuration file) is loaded)

<Name >=< value>
Triggers in this form will be triggered when the attribute <name> is set to the specified <value>.

Device-added-<path>
Device-removed-<path>

Triggers is triggered when a device node file is added or deleted.

Service-exited-<name>
Triggers in this form will be triggered when a specific service exits.

Commands (command)
----------
Exec <path> [<argument>] *
Create and execute a program (<path> ). Before the program is fully executed, init will be blocked. Because it is not a built-in command, try to avoid using exec, it may cause the init card

Export <name> <value>
In the global environment variable, set the environment variable <name> to <value>. (This will be inherited by all processes running after this command)

Ifup <interface>
Start Network interface <interface>

Import <filename>
Parse an init configuration file to extend the current configuration.

Hostname <name>
Set the host name.

Chmod <octal-mode> <path>
Change the file access permission.

Chown <owner> <group> <path>
Change the file owner and group.

Class_start <serviceclass>
Start all services not running under the specified service class.

Class_stop <serviceclass>
Stop all running services under the specified service class.

Domainname <name>
Set the domain name.

Insmod <path>
Load the module in <path>.

Mkdir <path> [mode] [owner] [group]
Create a directory <path> to select mode, owner, and group. If not specified, the default permission is 755 and belongs to the root user and root group.

Mount <type> <device> <dir> [<mountoption>] *
Try to mount the specified device in the directory <dir>. <Device> You can specify an mtd block device in the form of mtd @ name. <Mountoption> including "ro", "rw", and "re

Setkey
To be completed... (temporarily unavailable)

Setprop <name> <value>
Set the system attribute to the value of <value>.

Setrlimit <resource> <cur> <max>
Set <resource> rlimit (resource limit ).

Start <service>
Start the specified service (if the service is not running ).

Stop <service>
Stop the specified service (if the service is running ).

Symlink <target> <path>
Create a soft connection <target> pointing to <path>.

Sysclktz <mins_west_of_gmt>
Set the system clock benchmark (0 indicates that the clock tick is based on the Greenwich Mean Time (GMT)

Trigger <event>
Trigger an event. Used to sort one action and another action. (?????)

Write <path> <string> [<string>] *
Open a file with the path <path> and write one or more strings.

Properties)
----------
Init updates some system attributes to provide monitoring capabilities for ongoing events:

Init. action
This attribute value is the name of the action being executed. If not, it is "".

Init. command
This attribute value is the name of the command being executed. If not, it is "".

Init. svc. <name>
Status of the service named <name> ("stopped", "running", and "restarting ))

Init. conf instance
-----------------

# Not complete -- just providing some examples of usage
#
On boot
Export PATH/sbin:/system/bin
Export LD_LIBRARY_PATH/system/lib

Mkdir/dev
Mkdir/proc
Mkdir/sys

Mount tmpfs/dev
Mkdir/dev/pts
Mkdir/dev/socket
Mount devpts/dev/pts
Mount proc/proc
Mount sysfs/sys

Write/proc/cp/alignment 4

Ifup lo

Hostname localhost
Domainname localhost

Mount yaffs2 mtd @ system/system
Mount yaffs2 mtd @ userdata/data

Import/system/etc/init. conf

Class_start default

Service adbd/sbin/adbd
User adb
Group adb

Service usbd/system/bin/usbd-r
User usbd
Group usbd
Socket usbd 666

Service zygote/system/bin/app_process-Xzygote/system/bin -- zygote
Socket zygot 666

Service runtime/system/bin/runtime
User system
Group system

On device-added-/dev/compass
Start akmd

On device-removed-/dev/compass
Stop akmd

Service akmd/sbin/akmd
Disabled
User akmd
Group akmd

Debugging records
---------------
By default, the program will redirect both standard output and standard errors to/dev/null (discard) when it is executed by init ). If you want to obtain debugging information, you can use the logwrapp in the Andoird System

For example:
Service akmd/system/bin/logwrapper/sbin/akmd

Author: Red hunter

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.