This is an archived page. It's not actively maintained.

定制 脚本

在手机上,  b2g 应用程序 (它提供了 Firefox OS API 以及其他的东西)是通过 /system/bin/ 脚本启动的。你可以对这个脚本进行定制,以修改 Firefox OS 的行为,本文则是介绍了这些内容。


如果你仅仅是想要对单个运行的 B2G 设定环境变量,可以执行下面命令:

adb shell stop b2g
adb shell "export ENV_VAR=value && /system/bin/"

如果你想要在任何时候都使用相同的环境能够变量,可以向下节描述中对 进行编辑。


For debugging, you may want to set environment variables to get logging information or to otherwise affect how the b2g program runs. You can do this by editing the script. There aren't any tools included on the phone to edit the file in place, so you'll need to copy it to your computer first.

  1. Connect the phone to your computer, open a terminal window, and execute the following command to edit the script:
    adb pull /system/bin/
  2. Edit the script to make the changes you want. For example, suppose you'd like to see some logging output (which requires a debug build), then you might add something like:
    export NSPR_LOG_FILE=/data/local/tmp/mylog.txt
    export NSPR_LOG_MODULES=Layers:5
  3. Run the following commands to save your updated script to the phone and restart b2g:
    adb shell stop b2g
    adb remount
    adb push /system/bin
    adb shell chmod 0755 /system/bin/
    adb shell start b2g

Note: /data/local/tmp is the only place on the filesystem which is writable by content processes.