• Skip to main content
  • Select language
  • Skip to search
MDN Web Docs
  • Technologies
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs / DOM
    • WebExtensions
    • MathML
  • References & Guides
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
B2G OS
  1. MDN
  2. Archive of obsolete content
  3. B2G OS
  4. Developing Firefox OS
  5. Customizing the b2g.sh script

Customizing the b2g.sh script

In This Article
  1. Set environment variables
  2. Editing b2g.sh
  3. See also

On the phone, the b2g application (which provides the Firefox OS APIs among other things) is started through the /system/bin/b2g.sh script. You can customize this script to change the behavior of Firefox OS, and this article explains how.

Set environment variables

If you just want to set an environment variable for a single run of B2G, then you can do the following:

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

If you want to use the same environment variables all of the time, then you can edit b2g.sh, as described in the next section.

Editing b2g.sh

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 b2g.sh 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/b2g.sh
  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 b2g.sh script to the phone and restart b2g:
    adb shell stop b2g
    adb remount
    adb push b2g.sh /system/bin
    adb shell chmod 0755 /system/bin/b2g.sh
    adb shell start b2g
    

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

See also

  • Building and installing Firefox OS
  • Firefox OS architecture overview
  • Debugging on Firefox OS

 

Document Tags and Contributors

Tags: 
  • Debugging
  • Firefox OS
  • Hacking
 Contributors to this page: chrisdavidmills, staktrace, Sheppy, dhylands@mozilla.com
 Last updated by: chrisdavidmills, Feb 27, 2017, 2:58:46 AM
See also
  1. Build and install
    1. Build and install overview
    2. B2G OS build process summary
    3. Build prerequisites
    4. Preparing for your first build
    5. Building B2G OS
    6. B2G installer add-on
    7. Building B2G OS for Flame on Mac OS X
    8. Choosing how to run Gaia or B2G OS
    9. Compatible Devices
    10. Installing B2G OS on a mobile device
    11. Creating and applying B2G OS update packages
    12. Building and installing FOTA community builds
    13. B2G build variables reference sheet
  2. Porting B2G OS
    1. Porting overview
    2. Porting basics
    3. Porting on CyanogenMod
  3. Developing Gaia
    1. Developing Gaia overview
    2. Running the Gaia codebase
    3. Run Gaia on desktop using Mulet
    4. Understanding the Gaia codebase
    5. Making Gaia code changes
    6. Testing Gaia code changes
    7. Submitting a Gaia patch
    8. Gaia build system primer
    9. Different ways to run Gaia
    10. Make options reference
    11. Gaia tools reference
  4. B2G OS APIs