diff --git a/chromeos_startup.sh b/chromeos_startup.sh index 823f6f8..091162e 100644 --- a/chromeos_startup.sh +++ b/chromeos_startup.sh @@ -33,11 +33,8 @@ fi # this is because ssh-keygen was introduced somewhere around R80, where many shims are still stuck on R73 # filesystem unfuck can only be done before stateful is mounted, which is perfectly fine in a shim but not if you run it while booted # because mkfs is mean and refuses to let us format - # note that this will lead to confusing behaviour, since it will appear as if it crashed as a result of fakemurk -# startup plugins are also launched here, for low-level control over - # funny boot messages echo "Oh fuck - ChromeOS is trying to kill itself." >/usr/share/chromeos-assets/text/boot_messages/en/block_devmode_virtual.txt echo "ChromeOS detected developer mode and is trying to disable it to" >>/usr/share/chromeos-assets/text/boot_messages/en/block_devmode_virtual.txt diff --git a/cr50-update.conf b/cr50-update.conf index 1105a42..5250a3e 100644 --- a/cr50-update.conf +++ b/cr50-update.conf @@ -1,35 +1,10 @@ -# Copyright 2016 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# -# This script first determines if it needs to run at all: if the cr50 firmware -# image is not present in the local directory this must be happening on a -# board without a cr50 device, no need to do anything. -# -# If the firmware image is present, the script checks the number of previous -# runs saved in a state file. The file name is bound to the firmware image, if -# the firmware image changes, the name of the state file will also have to -# change. -# -# In most cases one firmware update run will be enough, but sometimes more -# than one step will be required (when updating from an old cr50 version or -# when rotating RW keys). The entire chromebook needs to be restarted between -# cr50 update runs, up to four update runs on a particular firmware image are -# allowed by this script. -# -# The gsctool utility exit status indicates if more runs are required. Exit -# status of 0 means update has succeeded. Other exit statuses are processed by -# the follow up startup script cr50-result.conf. -# +# Gutted so that there's zero chance of the cr50 accidentally getting updated description "Chromium OS startup file for cr50 firmware updater" author "chromium-os-dev@chromium.org" oom score -100 -# Starts on boot-services by exception, since it triggers a long chain of -# dependant tpm-related daemons that need to start early. Normally services -# should start on 'starting system-services'. start on started boot-services script diff --git a/docs/dev_reference.md b/docs/dev_reference.md index 991cf2b..0bba732 100644 --- a/docs/dev_reference.md +++ b/docs/dev_reference.md @@ -13,6 +13,8 @@ At the main menu, you have the option to enter a number corresponding to a menu - `112`: Purge extension processes - Kills all extension processes. - `113`: Prints a list of installed plugins and their individual metadata. - `114` and `115`: Legacy install/uninstall plugin - Readline-based plugin management for easier interface from the helper extension. +- `2**`: Interface for the JS plugin filesystem access API (see `class MurkmodFsAccess`) +- `30*`: Interface for the JS plugin stack API (see `class MurkmodStack`) The murkmod installation script (murkmod.sh, **not** the VT2 installer!) reads an environment variable called `MURKMOD_BRANCH` - it is normally set by option `26`, but it can be set by hand by using the following command: diff --git a/docs/js_plugins.md b/docs/js_plugins.md index 6b547d8..65661b3 100644 --- a/docs/js_plugins.md +++ b/docs/js_plugins.md @@ -75,3 +75,36 @@ Shit, that's a lot! Let's break it down a bit: - `finished`: If this string is present in the output from the terminal, the task is considered completed. 99% of the time this should be `> (1-`, but depending on your use case ift can differ. - `output_handler`: A function that takes a single string as a parameter, being the output from the terminal. Called every time output is received from the running task. - `once_done`: A callback that is executed once the task is completed. + +## Filesystem API + +In order to asynchronously access the filesystem from a JS plugin, you can use `MurkmodFsAccess`: + +```js +var fs = new MurkmodFsAccess(); +``` + +The methods available in `MurkmodFsAccess` are as follows: + +- `cd(string dir)`: Changes to a given directory. +- `ls()` or `ls(string dir)`: Lists contents of a directory as a string, delimited with spaces. +- `rm_dir(string dir)`: Deletes a directory recursively. +- `rm_file(string file)`: Deletes a single file. +- `mkdir(string dir)`: Creates a directory, recursively if neccesary. +- `touch(string file)`: Creates a file or updates its date last modified. +- `append(string file, string|array content)`: Appends a string or binary data to a given file. +- `write(string file, string|array content)`: Overwrites the contents of a file with the given string or binary data. +- `read(string file)`: Reads the contents of a given file. + +All of these functions return a `Promise` which resolves differently according to each function. + +For instance: + +```js +var fs = new MurkmodFsAccess(); +fs.cd("/").then(function(){ + fs.read("startup_log").then(log => { + console.log("Startup log:", log); + }); +}); +``` \ No newline at end of file diff --git a/docs/plugin_communication.md b/docs/plugin_communication.md new file mode 100644 index 0000000..3045664 --- /dev/null +++ b/docs/plugin_communication.md @@ -0,0 +1,49 @@ +# Plugin Communication + +Plugins sometimes need to communicate with each other - and to do so, there is a stack-based communication system that exists that allows developers to easily communicate between both JS and bash plugins. + +### In bash + +First, ensure your plugin sources from `plugin_common.sh`: + +```sh +. /usr/bin/murkmod_plugin_common.sh +``` + +Then, choose a name for your stack (for this guide, I'll go with `test_stack`): + +```sh +starts "test_stack" +``` + +And finally, push a message to the stack that the JS plugin will pick up later: + +```sh +pushs "Hello, world!" +``` + +### In JS + +Create a new `MurkmodStack` object and set it to the same stack name as before: + +```js +var stack = new MurkmodStack("test_stack"); +``` + +In order to log out the message saved to the stack earlier, we can call: + +```js +stack.pop().then(console.log); // Hello, world! +``` + +And we can push another message back: + +```js +stack.push("Hello, bash plugin!"); +``` + +And back in bash, we can read this again. + +```bash +pops # Hello, bash plugin! +``` \ No newline at end of file diff --git a/docs/plugin_dev.md b/docs/plugin_dev.md index 3f6a48f..54e6131 100644 --- a/docs/plugin_dev.md +++ b/docs/plugin_dev.md @@ -12,6 +12,7 @@ PLUGIN_FUNCTION="Print a hello world message" PLUGIN_DESCRIPTION="The friendliest murkmod plugin you'll ever see." PLUGIN_AUTHOR="rainestorme" PLUGIN_VERSION=1 +. /usr/bin/murkmod_plugin_common.sh echo "Hello, World!" ``` diff --git a/helper/html/index.html b/helper/html/index.html index 94909c1..ded954f 100644 --- a/helper/html/index.html +++ b/helper/html/index.html @@ -4,13 +4,13 @@