Skip to content

Commit

Permalink
synchronise doc with wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
HouzuoGuo committed Jan 30, 2018
1 parent d90ef6d commit e4ac0f4
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 49 deletions.
7 changes: 6 additions & 1 deletion doc/Component-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,19 @@ The following services are hosted by web server and enabled on your demand:
</tr>
<tr>
<td>Twilio telephone/SMS hook</td>
<td>Run toolbox commands on telephone, SMS, satellite terminals via Twilio platform (telephone and SMS programming).d>
<td>Run toolbox commands on telephone, SMS, satellite terminals via Twilio platform (telephone and SMS programming).</td>
<td><a href="https://github.com/HouzuoGuo/laitos/wiki/Web-service:-Twilio-telephone-SMS-hook" target="_blank">Link</a></td>
</tr>
<tr>
<td>Microsoft bot hook</td>
<td>Run toolbox commands on Skype and Cortana via Microsoft Bot Framework.</td>
<td><a href="https://github.com/HouzuoGuo/laitos/wiki/Web-service:-Microsoft-bot-hook" target="_blank">Link</a></td>
</tr>
<tr>
<td>Recurring commands</td>
<td>Run toolbox commands at regular interval, and retrieve result text.</td>
<td><a href="https://github.com/HouzuoGuo/laitos/wiki/Web-service:-recurring-commands" target="_blank">Link</a></td>
</tr>
</table>


Expand Down
5 changes: 3 additions & 2 deletions doc/Daemon:-mail-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@ Construct the following JSON object and place it under JSON key `MailDaemon` in
<br/>
The file may contain a certificate chain with server certificate on top and CA authority toward bottom.
</td>
><td>(Not enabled by default)</td>
<td>(Not enabled by default)</td>
</tr>
<tr>
<td>TLSKeyPath</td>
<td>string</td>
<td>(Not enabled by default) Absolute or relative path to PEM-encoded TLS certificate key.</td>
<td>Absolute or relative path to PEM-encoded TLS certificate key.</td>
<td>(Not enabled by default)</td>
</tr>
</table>

Expand Down
9 changes: 4 additions & 5 deletions doc/Daemon:-web-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Construct the following JSON object and place it under JSON key `HTTPDaemon` in
<td>ServeDirectories</td>
<td>{"/the/url/location": "/path/to/directory"...}</td>
<td>Serve the directories at the specified URL location. The prefix slash in URL location string is mandatory.</td>
<td>(Not used by default)</td>
</tr>
<tr>
<td>TLSCertPath</td>
Expand All @@ -52,12 +53,13 @@ Construct the following JSON object and place it under JSON key `HTTPDaemon` in
<br/>
The file may contain a certificate chain with server certificate on top and CA authority toward bottom.
</td>
><td>(Not enabled by default)</td>
<td>(Not enabled by default)</td>
</tr>
<tr>
<td>TLSKeyPath</td>
<td>string</td>
<td>(Not enabled by default) Absolute or relative path to PEM-encoded TLS certificate key.</td>
<td>Absolute or relative path to PEM-encoded TLS certificate key.</td>
<td>(Not enabled by default)</td>
</tr>
</table>

Expand Down Expand Up @@ -91,9 +93,6 @@ Here is an example setup that hosts a home page and media files:
...

"HTTPDaemon": {
"Address": "0.0.0.0",
"BaseRateLimit": 3,
"Port": 443,
"TLSCertPath": "howard-dot-net.crt",
"TLSKeyPath": "howard-dot-net.key",
"ServeDirectories": {
Expand Down
27 changes: 11 additions & 16 deletions doc/Toolbox-feature:-interactive-web-browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ following mandatory properties:
<td>integer</td>
<td>Stop the browser after this number of seconds elapse, regardless of whether the browser is in-use.</td>
</tr>
<tr>
<td>PhantomJSExecPath</td>
<td>string</td>
<td>
Absolute or relative path to PhantomJS executable. You may download it from PhantomJS website, or acquire a copy
from <a href="https://github.com/HouzuoGuo/laitos/tree/master/extra">laitos source tree</a>.
</td>
</tr>
</table>

Here is an example:
Expand Down Expand Up @@ -100,12 +92,15 @@ For example, to conduct a Google search:
8. Continue browsing.

## Tips
The web service relies on PhantomJS software that has several software dependencies:
- bzip2, expat, zlib, fontconfig.
- Various fonts.

You may install the software dependencies manually, or reply on [system maintenance](https://github.com/HouzuoGuo/laitos/wiki/Daemon:-system-maintenance)
- The instance port number from configuration is only for internal localhost use. They do not have to be open on your
network firewall.

- The web service relies on PhantomJS software that has several software dependencies:
* bzip2, expat, zlib, fontconfig.
* Various fonts.

You may install the software dependencies manually, or reply on [system maintenance](https://github.com/HouzuoGuo/laitos/wiki/Daemon:-system-maintenance)
to automatically install the dependencies.

The instance port number from configuration is only for internal localhost use. They do not have to be open on your
network firewall.
- laitos will find PhantomJS software by filename `phantomjs` or `phantomjs-2.1.1-x86_64` in the current working
directory, and copy it to `/tmp/laitos-util` for use. Therefore remember to download PhantomJS software for laitos
deployment, you may find a copy of PhantomJSin [laitos source tree](https://github.com/HouzuoGuo/laitos/blob/master/extra/phantomjs-2.1.1-x86_64).
13 changes: 9 additions & 4 deletions doc/Toolbox-feature:-run-system-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Configuration is generally not needed for this feature.

However, if you wish to override the automatic choice of shell interpreter:

Under JSON object `Features`, construct a JSON object called `Shell` that has the following mandatory properties:
Under JSON object `Features`, construct a JSON object called `Shell` that has the following properties:
<table>
<tr>
<th>Property</th>
Expand All @@ -20,6 +20,8 @@ Under JSON object `Features`, construct a JSON object called `Shell` that has th
<td>string</td>
<td>
Absolute path to shell interpreter program, such as /bin/bash
<br/>
If left empty, laitos will automatically find a working shell program already installed on the computer.
</td>
</tr>
</table>
Expand Down Expand Up @@ -56,7 +58,10 @@ find system users whose name contains "howard" and store them in an output file:
## Tips
- Shell commands will run on most Unix-like operating systems such as Linux, BSD, and MacOS. This feature does not yet
support Windows.
- laitos looks for shell interpreter among `/bin`, `/usr/bin`, `/usr/local/bin`, `/opt/bin`, in this order: `bash`,
`dash`, `zsh`, `ksh`, `ash`, `tcsh`, `csh`, `sh`
- If `InterpreterPath` is not specified, laitos will look for shell interpreter among `/bin`, `/usr/bin`,
`/usr/local/bin`, `/opt/bin`, in this order: `bash`, `dash`, `zsh`, `ksh`, `ash`, `tcsh`, `csh`, `sh`.
- When shell commands are run, the environment variable `PATH` is hard coded to
`/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/opt/sbin`
`/tmp/laitos-util:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/opt/sbin`
- `/tmp/laitos-util` is maintained by laitos internally to store non-essential components, such as a copy of PhantomJS
software, a copy of BusyBox software, and a copy of ToyBox software. If the components are available in laitos current
working directory when it starts up, the components will be copied into `/tmp/laitos-util`.
32 changes: 11 additions & 21 deletions doc/Web-service:-browser-in-browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ Construct the following properties under JSON key `HTTPHandlers`:
<td>integer</td>
<td>Stop a browser instance after this number of seconds elapse, regardless of whether the instance is in-use.</td>
</tr>
<tr>
<td>PhantomJSExecPath</td>
<td>string</td>
<td>
Absolute or relative path to PhantomJS executable. You may download it from PhantomJS website, or acquire a copy
from <a href="https://github.com/HouzuoGuo/laitos/tree/master/extra">laitos source tree</a>.
</td>
</tr>
</table>

Here is an example:
Expand Down Expand Up @@ -103,17 +95,15 @@ Additionally, "Backspace" button discards a character, and "Enter" button sends
While using the browser, you must regularly click "Redraw" button to view the latest rendered page.

## Tips
Make sure to choose a very secure URL for the endpoint, it is the only way to secure this web service!

The web service relies on PhantomJS software that has several software dependencies:
- bzip2, expat, zlib, fontconfig.
- Various fonts.

You may install the software dependencies manually, or reply on [system maintenance](https://github.com/HouzuoGuo/laitos/wiki/Daemon:-system-maintenance)
- The instance port number from configuration is only for internal localhost use. They do not have to be open on your
network firewall.

- The web service relies on PhantomJS software that has several software dependencies:
* bzip2, expat, zlib, fontconfig.
* Various fonts.

You may install the software dependencies manually, or reply on [system maintenance](https://github.com/HouzuoGuo/laitos/wiki/Daemon:-system-maintenance)
to automatically install the dependencies.

If you wish to use the web service on a legacy browser such as IE 5.5, then remember to start plain HTTP daemon
(i.e. `insecurehttpd`), because legacy browsers do not support modern TLS (HTTPS).

The instance port numbers from configuration are only for internal localhost use. They do not have to be open on your
network firewall.
- laitos will find PhantomJS software by filename `phantomjs` or `phantomjs-2.1.1-x86_64` in the current working
directory, and copy it to `/tmp/laitos-util` for use. Therefore remember to download PhantomJS software for laitos
deployment, you may find a copy of PhantomJSin [laitos source tree](https://github.com/HouzuoGuo/laitos/blob/master/extra/phantomjs-2.1.1-x86_64).
105 changes: 105 additions & 0 deletions doc/Web-service:-recurring-commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Web service: recurring commands

## Introduction
Hosted by laitos [web server](https://github.com/HouzuoGuo/laitos/wiki/Daemon:-web-server), the service hosts channels
of pre-configured toolbox commands that are run at regular interval, and let user retrieve the command results in JSON
array per channel.

While the service is online, user may add more toolbox commands and put text messages directly into command results via
an HTML form served by this service on the same HTTP endpoint. These transient commands are not memorised and will be
lost upon program restart.

An example use case of the service may be to build a utility web application that displays the latest system resource
usage for monitoring, or the latest list of mails in inbox.

## Configuration
- Under JSON key `HTTPHandlers`, write a string property called `RecurringCommandsEndpoint`, value being the URL
location that will serve the configuration form and retrieve command results (both under one endpoint). Keep the
location a secret to yourself and make it difficult to guess.
- Under JSON key `RecurringCommandsEndpointConfig`, create an inner object `RecurringCommands`, in which keys are
channel names (keep them difficult to guess) and each value is an object with the following mandatory properties:
<table>
<tr>
<th>Property</th>
<th>Type</th>
<th>Meaning</th>
</tr>
<tr>
<td>IntervalSec</td>
<td>integer</td>
<td>The interval (seconds) at which pre-configured and transient commands toolbox commands should be executed.</td>
</tr>
<tr>
<td>MaxResults</td>
<td>integer</td>
<td>The number of command results to keep. Older results are discarded.</td>
</tr>
<tr>
<td>PreConfiguredCommands</td>
<td>array of strings</td>
<td>
Full toolbox commands (with PIN/shortcut/PLT special directive) that will begin to run as soon as the service is
online.
<br/>
Leave empty if you do not plan for any command to run automatically, you can still add transient commands using
the HTML form.
</td>
</tr>
</table>

Here is an example setup:
<pre>
{
...

"HTTPHandlers": {
...

"RecurringCommandEndpoint": "/very-secret-recurring-commands",
"RecurringCommandEndpointConfig": {
"RecurringCommands": {
"my-secret-channel-alpha": {
"IntervalSec": 60,
"MaxResults": 10,
"PreConfiguredCommands": [
"VerySecretPassword.e info",
"VerySecretPassword.s date",
]
},
"my-secret-channel-zulu": {
"IntervalSec": 120,
"MaxResults": 10,
"PreConfiguredCommands": [
"VerySecretPassword.il MyEmailInbox",
]
}
}
},


...
},

...
}
</pre>

## Run
The form is hosted by web server, therefore remember to [run web server](https://github.com/HouzuoGuo/laitos/wiki/Daemon:-web-server#run).

## Usage
Pre-configured commands (if any) will begin to run automatically as soon as laitos starts up. To retrieve command
results, use an HTTP client (such as web browser) to access the endpoint URL (HTTP GET):

/very-secret-recurring-commands?retrieve=my-secret-channel-alpha

The historic command results will be returned in a JSON array and then immediately deleted.

To add transient toolbox commands, clear transient toolbox commands, and to push messages directly into command results,
access the endpoint URL without additional parameter and use the HTML form:

/very-secret-recurring-commands

## Tips
Make sure to choose a very secure URL for both the endpoint and channel names, and make sure they are only known by
designated users of this service!

0 comments on commit e4ac0f4

Please sign in to comment.