Detailed explanation of the android init. RC File Syntax

Source: Internet
Author: User

 

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 marks. The backslash at the end of a row is used to fold rows.

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)

----------

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 event that meets the action trigger condition occurs, the action is added to the end of the execution queue unless it is already in the queue.

Each action in the queue is extracted in sequence, and each command in the action is executed in sequence. During the execution of these commands, init also controls other activities (device node creation and cancellation, attribute setting, and process restart ).

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 and 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 must be "dgram" or "stream ". The default values of user and group are 0.

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 Linux capabilities (capability), you cannot use this command. Even if you are the root user, you must request capabilities in the program ). Then drop it to the uid you want.

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 (via setgroups () for the process ()). The default value is root. (??? If possible, it should be nobody by default ).

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, which may cause init to become stuck. (??? Do you need a timeout setting ?)

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

 

 

 

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 named path, which allows you to specify mode, owner, and group. If not specified, the default permission is 755 and belongs to the root user and root group.

Mount type and device and dir [mountoption] *

Try to mount the specified device in the directory dir. Device can specify an MTD block device in the form of MTD @ name. Mountoption includes "Ro", "RW", "remount", "noatime ",...

Setkey

To be completed... (temporarily unavailable)

Setprop name value

Set "name" as "value" of the system attribute.

Setrlimit resource cur Max

Set 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, and string. *

Open a file named 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/CPU/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 logwrapper program in the andoird system to execute your program. It redirects both standard output and standard errors to the android log system (accessed through logcat ).

For example:

Service akmd/system/bin/logwrapper/sbin/akmd

 

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.