Merge pull request #17 from peachcloud/update_readmes

Update software readmes
This commit is contained in:
glyph 2021-03-04 08:55:26 +00:00 committed by GitHub
commit b68e8791b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 372 additions and 57 deletions

View File

@ -1,6 +1,6 @@
# peach-devdocs
[![Build Status](https://travis-ci.com/peachcloud/peach-devdocs.svg?branch=master)](https://travis-ci.com/peachcloud/peach-devdocs) ![Generic badge](https://img.shields.io/badge/version-0.3.1-<COLOR>.svg)
[![Build Status](https://travis-ci.com/peachcloud/peach-devdocs.svg?branch=master)](https://travis-ci.com/peachcloud/peach-devdocs) ![Generic badge](https://img.shields.io/badge/version-0.3.2-<COLOR>.svg)
Developer documentation for [PeachCloud](https://github.com/peachcloud) in the form of a Markdown book.

View File

@ -21,6 +21,9 @@
- [peach-network](./software/microservices/peach-network.md)
- [peach-oled](./software/microservices/peach-oled.md)
- [peach-stats](./software/microservices/peach-stats.md)
- [Utilities](./software/utilities/index.md)
- [peach-probe](./software/utilities/peach-probe.md)
- [peach-version-checker](./software/utilities/peach-version-checker.md)
- [Web Interface](./software/web_interface.md)
- [Pattern Library](./software/pattern_library.md)
- [Compilation](./software/compilation.md)

View File

@ -1,14 +1,14 @@
# peach-buttons
[![GitHub logo](/assets/github_logo.png "peach-buttons GitHub repository")](https://github.com/peachcloud/peach-buttons) [![Build Status](https://travis-ci.com/peachcloud/peach-buttons.svg?branch=master)](https://travis-ci.com/peachcloud/peach-buttons) ![Version badge](https://img.shields.io/badge/version-0.1.0-<COLOR>.svg)
[![GitHub logo](/assets/github_logo.png "peach-buttons GitHub repository")](https://github.com/peachcloud/peach-buttons) [![Build Status](https://travis-ci.com/peachcloud/peach-buttons.svg?branch=master)](https://travis-ci.com/peachcloud/peach-buttons) ![Version badge](https://img.shields.io/badge/version-0.1.3-<COLOR>.svg)
GPIO microservice module for handling button presses. `peach-buttons` implements a JSON-RPC server with [Publish-Subscribe extension](https://docs.rs/jsonrpc-pubsub/11.0.0/jsonrpc_pubsub/). Each button press results in a JSON-RPC request being sent over websockets to any subscribers. A button code for the pressed button is sent with the request to subscribers, allowing state-specific actions to be taken by the subscriber.
In the case of PeachCloud, the `peach-menu` microservice subscribes to `peach-buttons` in order to update the state of the menu after each button press.
In the case of PeachCloud, the `peach-menu` microservice ([repo](https://github.com/peachcloud/peach-menu)) subscribes to `peach-buttons` in order to update the state of the menu after each button press.
_Note: This module is relatively stable but is still a work-in-progress._
### Directory Tree
## Directory Tree
```bash
.
@ -22,7 +22,7 @@ _Note: This module is relatively stable but is still a work-in-progress._
│ └── main.rs // init logger, call run() & catch application errors
```
### Pin to Button to Button Code Mappings
## Pin to Button to Button Code Mappings
```bash
4 => Center => 0,
@ -36,7 +36,21 @@ _Note: This module is relatively stable but is still a work-in-progress._
_Note: `peach-buttons` utilizes the GPIO character device ABI. This API, stabilized with Linux v4.4, deprecates the legacy sysfs interface to GPIOs that is planned to be removed from the upstream kernel after year 2020._
### Setup
## Environment
The JSON-RPC WS server address and port can be configured with the `PEACH_BUTTONS_SERVER` environment variable:
`export PEACH_BUTTONS_SERVER=127.0.0.1:5000`
When not set, the value defaults to `127.0.0.1:5111`.
Logging is made availabe with `env_logger`:
`export RUST_LOG=info`
Other logging levels include `debug`, `warn` and `error`.
## Setup
Clone this repo:
@ -51,16 +65,46 @@ Run the binary with sudo:
`sudo ./target/release/peach-buttons`
Logging is made availabe with `env_logger`:
## Debian Packaging
`sudo RUST_LOG=info ./target/release/peach-buttons`
A `systemd` service file and Debian maintainer scripts are included in the `debian` directory, allowing `peach-buttons` to be easily bundled as a Debian package (`.deb`). The `cargo-deb` [crate](https://crates.io/crates/cargo-deb) can be used to achieve this.
_Other logging levels include debug, warn and error._
Install `cargo-deb`:
### Testing Subscription
`cargo install cargo-deb`
Move into the repo:
`cd peach-buttons`
Build the package:
`cargo deb`
The output will be written to `target/debian/peach-buttons_0.1.0_arm64.deb` (or similar).
Build the package (aarch64):
`cargo deb --target aarch64-unknown-linux-gnu`
Install the package as follows:
`sudo dpkg -i target/debian/peach-buttons_0.1.0_arm64.deb`
The service will be automatically enabled and started.
Uninstall the service:
`sudo apt-get remove peach-buttons`
Remove configuration files (not removed with `apt-get remove`):
`sudo apt-get purge peach-buttons`
## Testing Subscription
Request:
`{"id":1,"jsonrpc":"2.0","method":"subscribe_buttons"}`
Response:
@ -71,6 +115,6 @@ Event:
`{"jsonrpc":"2.0","method":"button_press","params":[0]}`
### Licensing
## Licensing
AGPL-3.0

View File

@ -1,6 +1,6 @@
# peach-monitor
[![GitHub logo](/assets/github_logo.png "peach-monitor GitHub repository")](https://github.com/peachcloud/peach-monitor) [![Build Status](https://travis-ci.com/peachcloud/peach-web.svg?branch=master)](https://travis-ci.com/peachcloud/peach-web) ![Version badge](https://img.shields.io/badge/version-0.1.0-<COLOR>.svg)
[![GitHub logo](/assets/github_logo.png "peach-monitor GitHub repository")](https://github.com/peachcloud/peach-monitor) [![Build Status](https://travis-ci.com/peachcloud/peach-web.svg?branch=master)](https://travis-ci.com/peachcloud/peach-web) ![Version badge](https://img.shields.io/badge/version-0.1.1-<COLOR>.svg)
Monitor network data usage and set alert flags based on user-defined thresholds.
@ -14,7 +14,7 @@ The `--daemon` flag executes the `--update` functionality in a loop and is inten
The `--iface` argument is used to define the network interface from which to retrieve network traffic data. This defaults to `wlan0` if not defined.
### Usage
## Usage
`peach-monitor [FLAGS] [OPTIONS]`
@ -31,7 +31,7 @@ OPTIONS:
-t, --interval <interval> Define time interval for updating alert flags (seconds) [default: 60]
```
### Data Store
## Data Store
`~/.local/share/peachcloud`
@ -43,11 +43,11 @@ OPTIONS:
└── traffic.json // network transmission totals
```
### Alert Types
## Alert Types
`peach-monitor` defines warning and cutoff thresholds and corresponding alert flags for both received and transmitted network data. The cutoff thresholds are intended to allow data-intensive processes such as Scuttlebutt replication to be enabled and disabled dynamically.
### Debian Packaging
## Debian Packaging
A `systemd` service file and Debian maintainer scripts are included in the `debian` directory, allowing `peach-monitor` to be easily bundled as a Debian package (`.deb`). The `cargo-deb` [crate](https://crates.io/crates/cargo-deb) can be used to achieve this.
@ -79,10 +79,10 @@ Remove configuration files (not removed with `apt-get remove`):
`sudo apt-get purge peach-monitor`
### Roadmap
## Roadmap
- Add disk-usage tracking and alerts
- Add disk-usage tracking and alerts
### Licensing
## Licensing
AGPL-3.0

View File

@ -1,6 +1,6 @@
# peach-network
[![GitHub logo](/assets/github_logo.png "peach-network GitHub repository")](https://github.com/peachcloud/peach-network) [![Build Status](https://travis-ci.com/peachcloud/peach-network.svg?branch=master)](https://travis-ci.com/peachcloud/peach-network) ![Version badge](https://img.shields.io/badge/version-0.2.0-<COLOR>.svg)
[![GitHub logo](/assets/github_logo.png "peach-network GitHub repository")](https://github.com/peachcloud/peach-network) [![Build Status](https://travis-ci.com/peachcloud/peach-network.svg?branch=master)](https://travis-ci.com/peachcloud/peach-network) ![Version badge](https://img.shields.io/badge/version-0.2.9-<COLOR>.svg)
Networking microservice module for PeachCloud. Query and configure device interfaces using [JSON-RPC](https://www.jsonrpc.org/specification) over HTTP.
@ -8,7 +8,7 @@ Interaction with wireless interfaces occurs primarily through the [wpactrl crate
_Note: This module is a work-in-progress._
### JSON-RPC API
## JSON-RPC API
Methods for **retrieving data**:
@ -30,10 +30,10 @@ Methods for **modifying state**:
| Method | Parameters | Description |
| --- | --- | --- |
| `activate_ap` | | Activate WiFi access point (stop `wpa_supplicant` and start `hostapd` and `dnsmasq`) |
| `activate_client` | | Activate WiFi client connection (stop `hostapd` and `dnsmasq` and start `wpa_supplicant`) |
| `add` | `ssid`, `pass` | Add WiFi credentials to `wpa_supplicant.conf` |
| `check_iface` | | Run AP / client-mode configuration script |
| `activate_ap` | | Activate WiFi access point (start `wpa_supplicant@ap0.service`) |
| `activate_client` | | Activate WiFi client connection (start `wpa_supplicant@wlan0.service`) |
| `add` | `ssid`, `pass` | Add WiFi credentials to `wpa_supplicant-wlan0.conf` |
| `check_iface` | | Activate WiFi access point if client mode is active without a connection |
| `connect` | `id`, `iface` | Disable other networks and attempt connection with AP represented by given id |
| `delete` | `id`, `iface` | Remove WiFi credentials for given network id and interface |
| `disable` | `id`, `iface` | Disable connection with AP represented by given id |
@ -42,13 +42,13 @@ Methods for **modifying state**:
| `reassociate` | `iface` | Reassociate with current AP for given interface |
| `reconfigure` | | Force wpa_supplicant to re-read its configuration file |
| `reconnect` | `iface` | Disconnect and reconnect given interface |
| `save` | | Save configuration changes to `wpa_supplicant.conf` |
| `save` | | Save configuration changes to `wpa_supplicant-wlan0.conf` |
### API Documentation
## API Documentation
API documentation can be built and served with `cargo doc --no-deps --open`. This set of documentation is intended for developers who wish to work on the project or better understand the API of the `src/network.rs` module.
### Directory Tree
## Directory Tree
```bash
.
@ -62,7 +62,7 @@ API documentation can be built and served with `cargo doc --no-deps --open`. Thi
│ └── network.rs // logic for network methods exposed via RPC
```
### Setup
## Setup
Clone this repo:
@ -77,7 +77,7 @@ Run the binary (sudo needed to satisfy permission requirements):
`sudo ./target/release/peach-network`
### Environment
## Environment
The JSON-RPC HTTP server address and port can be configured with the `PEACH_NETWORK_SERVER` environment variable:
@ -91,13 +91,49 @@ Logging is made available with `env_logger`:
Other logging levels include `debug`, `warn` and `error`.
### Example Usage
## Debian Packaging
A `systemd` service file and Debian maintainer scripts are included in the `debian` directory, allowing `peach-network` to be easily bundled as a Debian package (`.deb`). The `cargo-deb` [crate](https://crates.io/crates/cargo-deb) can be used to achieve this.
Install `cargo-deb`:
`cargo install cargo-deb`
Move into the repo:
`cd peach-network`
Build the package:
`cargo deb`
The output will be written to `target/debian/peach-network_0.2.4_arm64.deb` (or similar).
Build the package (aarch64):
`cargo deb --target aarch64-unknown-linux-gnu`
Install the package as follows:
`sudo dpkg -i target/debian/peach-network_0.2.4_arm64.deb`
The service will be automatically enabled and started.
Uninstall the service:
`sudo apt-get remove peach-network`
Remove configuration files (not removed with `apt-get remove`):
`sudo apt-get purge peach-network`
## Example Usage
**Retrieve IP address for wlan0**
With microservice running, open a second terminal window and use `curl` to call server methods:
`curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "get_ip", "params" : {"iface": "wlan0" }, "id":1 }' 127.0.0.1:5000`
`curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "ip", "params" : {"iface": "wlan0" }, "id":1 }' 127.0.0.1:5000`
Server responds with:
@ -105,7 +141,7 @@ Server responds with:
**Retrieve SSID of connected access point for wlan1**
`curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "get_ssid", "params" : {"iface": "wlan1" }, "id":1 }' 127.0.0.1:5000`
`curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "ssid", "params" : {"iface": "wlan1" }, "id":1 }' 127.0.0.1:5000`
Server response when interface is connected:
@ -117,11 +153,11 @@ Server response when interface is not connected:
**Retrieve list of SSIDs for all networks in range of wlan0**
`curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "scan_networks", "params" : {"iface": "wlan0" }, "id":1 }' 127.0.0.1:5000`
`curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "available_networks", "params" : {"iface": "wlan0" }, "id":1 }' 127.0.0.1:5000`
Server response when interface is connected:
`{"jsonrpc":"2.0","result":"[\"Home\",\"TP-LINK_254700\"]","id":1}`
`{"jsonrpc":"2.0","result":"[{\"frequency\":\"2412\",\"signal_level\":\"-72\",\"ssid\":\"Home\",\"flags\":\"[WPA2-PSK-CCMP][ESS]\"},{\"frequency\":\"2472\",\"signal_level\":\"-56\",\"ssid\":\"podetium\",\"flags\":\"[WPA2-PSK-CCMP+TKIP][ESS]\"}]","id":1}`
Server response when interface is not connected:
@ -129,7 +165,7 @@ Server response when interface is not connected:
**Retrieve network traffic statistics for wlan1**
`curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "get_traffic", "params" : {"iface": "wlan1" }, "id":1 }' 127.0.0.1:5000`
`curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "traffic", "params" : {"iface": "wlan1" }, "id":1 }' 127.0.0.1:5000`
Server response if interface exists:
@ -139,6 +175,18 @@ Server response when interface is not found:
`{"jsonrpc":"2.0","error":{"code":-32004,"message":"Failed to retrieve network traffic for wlan3. Interface may not be connected"},"id":1}`
### Licensing
**Retrieve status information for wlan0**
`curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "status", "params" : {"iface": "wlan0" }, "id":1 }' 127.0.0.1:5110`
Server response if interface exists:
`{"jsonrpc":"2.0","result":"{\"address\":\"b8:27:eb:9b:5d:5f\",\"bssid\":\"f4:8c:eb:cd:31:81\",\"freq\":\"2412\",\"group_cipher\":\"CCMP\",\"id\":\"0\",\"ip_address\":\"192.168.0.162\",\"key_mgmt\":\"WPA2-PSK\",\"mode\":\"station\",\"pairwise_cipher\":\"CCMP\",\"ssid\":\"Home\",\"wpa_state\":\"COMPLETED\"}","id":1}`
Server response when interface is not found:
`{"jsonrpc":"2.0","error":{"code":-32013,"message":"Failed to open control interface for wpasupplicant: No such file or directory (os error 2)"},"id":1}`
## Licensing
AGPL-3.0

View File

@ -1,10 +1,10 @@
# peach-oled
[![GitHub logo](/assets/github_logo.png "peach-oled GitHub repository")](https://github.com/peachcloud/peach-oled) [![Build Status](https://travis-ci.com/peachcloud/peach-oled.svg?branch=master)](https://travis-ci.com/peachcloud/peach-oled) ![Version badge](https://img.shields.io/badge/version-0.1.0-<COLOR>.svg)
[![GitHub logo](/assets/github_logo.png "peach-oled GitHub repository")](https://github.com/peachcloud/peach-oled) [![Build Status](https://travis-ci.com/peachcloud/peach-oled.svg?branch=master)](https://travis-ci.com/peachcloud/peach-oled) ![Version badge](https://img.shields.io/badge/version-0.1.3-<COLOR>.svg)
OLED microservice module for PeachCloud. Write to a 128x64 OLED display with SDD1306 driver (I2C) using [JSON-RPC](https://www.jsonrpc.org/specification) over HTTP.
### JSON-RPC API
## JSON-RPC API
| Method | Parameters | Description |
| --- | --- | --- |
@ -12,6 +12,7 @@ OLED microservice module for PeachCloud. Write to a 128x64 OLED display with SDD
| `draw` | `bytes`, `width`, `height`, `x_coord`, `y_coord` | Draw graphic to display buffer for given byte array, dimensions and co-ordinates |
| `flush` | | Flush the display |
| `ping` | | Respond with `success` if microservice is running |
| `power` | `on` | Toggle the display (memory is retained while off) |
| `write` | `x_coord`, `y_coord`, `string`, `font_size` | Write message to display buffer for given co-ordinates using given font size |
`peach-oled` allows text to be written with the following font sizes:
@ -23,7 +24,7 @@ OLED microservice module for PeachCloud. Write to a 128x64 OLED display with SDD
| `8x16` |
| `12x16` |
### Directory Tree
## Directory Tree
```bash
.
@ -39,7 +40,7 @@ OLED microservice module for PeachCloud. Write to a 128x64 OLED display with SDD
│ └── main.rs // init logger, call run() & catch application errors
```
### Setup
## Setup
Clone this repo:
@ -54,7 +55,7 @@ Run the binary:
`./target/release/peach-oled`
### Environment
## Environment
The JSON-RPC HTTP server address and port can be configured with the `PEACH_OLED_SERVER` environment variable:
@ -68,7 +69,7 @@ Logging is made available with `env_logger`:
Other logging levels include `debug`, `warn` and `error`.
### Example Usage
## Example Usage
**Write Text to the OLED Display**
@ -139,6 +140,6 @@ Server responds with:
`{"jsonrpc":"2,0","result":"success","id":1}`
### Licensing
## Licensing
AGPL-3.0

View File

@ -1,10 +1,10 @@
# peach-stats
[![GitHub logo](/assets/github_logo.png "peach-stats GitHub repository")](https://github.com/peachcloud/peach-stats) [![Build Status](https://travis-ci.com/peachcloud/peach-stats.svg?branch=master)](https://travis-ci.com/peachcloud/peach-stats) ![Version badge](https://img.shields.io/badge/version-0.1.0-<COLOR>.svg)
[![GitHub logo](/assets/github_logo.png "peach-stats GitHub repository")](https://github.com/peachcloud/peach-stats) [![Build Status](https://travis-ci.com/peachcloud/peach-stats.svg?branch=master)](https://travis-ci.com/peachcloud/peach-stats) ![Version badge](https://img.shields.io/badge/version-0.1.3-<COLOR>.svg)
System statistics microservice module for PeachCloud. Provides a JSON-RPC wrapper around the [probes](https://crates.io/crates/probes) and [systemstat](https://crates.io/crates/systemstat) crates.
### JSON-API
## JSON-API
| Method | Description | Returns |
| --- | --- | --- |
@ -13,9 +13,10 @@ System statistics microservice module for PeachCloud. Provides a JSON-RPC wrappe
| `disk_usage` | Disk usage statistics (array of disks) | `filesystem`, `one_k_blocks`, `one_k_blocks_used`, `one_k_blocks_free`, `used_percentage`, `mountpoint` |
| `load_average` | Load average statistics | `one`, `five`, `fifteen` |
| `mem_stats` | Memory statistics | `total`, `free`, `used` |
| `ping` | Microservice status | `success` if running |
| `uptime` | System uptime | `secs`, `nanos` |
### Directory Tree
## Directory Tree
```bash
.
@ -30,7 +31,7 @@ System statistics microservice module for PeachCloud. Provides a JSON-RPC wrappe
└── structs.rs // data types for stats
```
### Setup
## Setup
Clone this repo:
@ -45,7 +46,7 @@ Run the binary:
`./target/release/peach-stats`
### Environment
## Environment
The JSON-RPC HTTP server address and port can be configured with the `PEACH_STATS_SERVER` environment variable:
@ -59,7 +60,43 @@ Logging is made available with `env_logger`:
Other logging levels include `debug`, `warn` and `error`.
### Example Usage
## Debian Packaging
A `systemd` service file and Debian maintainer scripts are included in the `debian` directory, allowing `peach-stats` to be easily bundled as a Debian package (`.deb`). The `cargo-deb` [crate](https://crates.io/crates/cargo-deb) can be used to achieve this.
Install `cargo-deb`:
`cargo install cargo-deb`
Move into the repo:
`cd peach-stats`
Build the package:
`cargo deb`
The output will be written to `target/debian/peach-stats_0.1.0_arm64.deb` (or similar).
Build the package (aarch64):
`cargo deb --target aarch64-unknown-linux-gnu`
Install the package as follows:
`sudo dpkg -i target/debian/peach-stats_0.1.0_arm64.deb`
The service will be automatically enabled and started.
Uninstall the service:
`sudo apt-get remove peach-stats`
Remove configuration files (not removed with `apt-get remove`):
`sudo apt-get purge peach-stats`
## Example Usage
**Get CPU Statistics**
@ -81,7 +118,7 @@ Server responds with:
`{"jsonrpc":"2.0","result":"{\"secs\":840968,\"nanos\":0}","id":1}`
### Licensing
## Licensing
AGPL-3.0

View File

@ -0,0 +1,3 @@
# Utilities
Simple tools and utilities for contract testing PeachCloud microservice APIs and ensuring version consistency.

View File

@ -0,0 +1,51 @@
# peach-probe
[![GitHub logo](/assets/github_logo.png "peach-probe GitHub repository")](https://github.com/peachcloud/peach-probe) ![Version badge](https://img.shields.io/badge/version-0.1.1-<COLOR>.svg)
Probe PeachCloud microservices to evaluate their state and ensure correct API responses.
`peach-probe` is a CLI tool for contract testing of the public API's exposed by PeachCloud microservices.
It is composed of JSON-RPC clients which make calls to the methods of their respective servers and
generates a report with the results.
`peach-probe` also makes use of `systemctl status` commands to test the status of all PeachCloud microservices.
This utility is intended to provide a rapid means of testing a deployed PeachCloud system and allow informed trouble-shooting in the case of errors.
## Installation
After adding releases.peachcloud.org to /etc/sources.list, as described [here](https://github.com/peachcloud/peach-vps/blob/main/README.md),
peach-probe can be installed by running:
`sudo apt-get install peach-probe`
## Usage
```bash
USAGE:
peach-probe [FLAGS] [services]...
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
-v, --verbose prints successful endpoint calls in addition to errors
ARGS:
<services>... [possible values: peach_oled, peach_Network, peach_stats, peach_menu, peach_web,
peach_Buttons, peach_monitor]
```
If no service arguments are provided, peach-probe will query all services.
## Custom Port Numbers
If peach-microservices are running on ports other than the default ports,
this can be specified using environmental variables as documented [here](https://github.com/peachcloud/peach-lib/blob/main/README.md).
## Todo
- On detecting certain errors, suggest possible fixes
- Finish querying of all peach-network endpoints
## Licensing
AGPL-3.0

View File

@ -0,0 +1,40 @@
# peach-version-checker
[![GitHub logo](/assets/github_logo.png "peach-version-checker GitHub repository")](https://github.com/peachcloud/peach-version-checker) ![Version badge](https://img.shields.io/badge/version-0.1.0-<COLOR>.svg)
A simple commandline tool which helps to ensure version consistency across software and documentation.
`peach-version-checker` compares version numbers in crate READMEs, manifests and developer documentation for each microservice and program in the PeachCloud ecosystem. Each program is given a passing or failing grade in the generated report. Project maintainers can then act accordingly if any version inconsistencies are found.
## Usage
```bash
git clone git@github.com:peachcloud/peach-version-checker.git
cd peach-version-checker
cargo build --release
./release/target/peach-version-checker
```
## Example Output
```bash
[ peach-buttons ]
Dev-docs: 0.1.3
Manifest: 0.1.3
Readme : 0.1.3
PASS
[ peach-oled ]
Dev-docs: 0.1.0
Manifest: 0.1.3
Readme : 0.1.3
FAIL
[ peach-probe ]
Dev-docs: No version number found
Manifest: 0.1.1
Readme : 0.1.1
FAIL
```
## Licensing
AGPL-3.0

View File

@ -1,16 +1,16 @@
# Web Interface
[![GitHub logo](/assets/github_logo.png "peach-buttons GitHub repository")](https://github.com/peachcloud/peach-buttons)
[![GitHub logo](/assets/github_logo.png "peach-buttons GitHub repository")](https://github.com/peachcloud/peach-buttons) [![Build Status](https://travis-ci.com/peachcloud/peach-web.svg?branch=master)](https://travis-ci.com/peachcloud/peach-web) ![Version badge](https://img.shields.io/badge/version-0.4.2-<COLOR>.svg)
[peach-web](https://github.com/peachcloud/peach-web) provides a web interface for monitoring and interacting with the PeachCloud device. This allows administration of the single-board computer (ie. Raspberry Pi) running PeachCloud, as well as the ssb-server and related plugins.
### Design
## Design
`peach-web` is written primarily in Rust and presents a web interface for interacting with the device. The stack currently consists of [Rocket](https://rocket.rs/) (Rust web framework), [Tera](https://tera.netlify.com/docs/installation/) (Rust template engine inspired by Jinja2 and the Django template language), HTML, CSS and JavaScript. Additional functionality is provided by JSON-RPC clients for the `peach-network` and `peach-stats` microservices.
HTML is rendered server-side. Request handlers call JSON-RPC microservices and serve HTML and assets. A JSON API is exposed for remote calls and dynamic client-side content updates via vanilla JavaScript following [unobstructive design principles](https://www.w3.org/wiki/The_principles_of_unobtrusive_JavaScript). A basic Websockets server is included, though is not currently utilised. Each Tera template is passed a context object. In the case of Rust, this object is a `struct` and must implement `Serialize`. The fields of the context object are available in the context of the template to be rendered.
### Directory Tree
## Directory Tree
```bash
.
@ -57,7 +57,61 @@ HTML is rendered server-side. Request handlers call JSON-RPC microservices and s
│   └── shutdown.html.tera
```
### Environment
## WEB ROUTES (`src/routes.rs`)
| Endpoint | Method | Parameters | Description |
| --- | --- | --- | --- |
| `/` | GET | | Home |
| `/device` | GET | | Device status overview |
| `/device/reboot` | GET | | Reboot device |
| `/device/shutdown` | GET | | Shutdown device |
| `/login` | GET | | Login form |
| `/network` | GET | | Network status overview |
| `/network/ap/activate` | GET | | Activate WiFi access point mode |
| `/network/wifi` | GET | | List of networks |
| `/network/wifi?<ssid>` | GET | `ssid` | Details of a single network |
| `/network/wifi/activate` | GET | | Activate WiFi client mode |
| `/network/wifi/add` | GET | `ssid` (optional - prepopulation value of SSID in form) | Add a WiFi network |
| `/network/wifi/add` | POST | `ssid` & `pass` | Submit form to add a WiFi network |
| `/network/wifi/connect` | POST | `ssid` | Connect to the given WiFi network |
| `/network/wifi/disconnect` | POST | `ssid` | Disconnect from currently associated WiFi network |
| `/network/wifi/forget` | POST | `ssid` | Submit form to forget a saved WiFi network |
| `/network/wifi/modify?<ssid>` | GET | `ssid` | Form for updating a WiFi network password |
| `/network/wifi/modify` | POST | `ssid` & `pass` | Submit form to update a WiFi network password |
| `/network/wifi/usage` | GET | | Network data usage values and a form to update alert thresholds |
| `/network/wifi/usage` | POST | `rx_warn`, `rx_cut`, `tx_warn`, `tx_cut`, `rx_warn_flag`, `rx_cut_flag`, `tx_warn_flag`, `tx_cut_flag` | Submit form to update alert thresholds & set flags |
| `/network/wifi/usage/reset` | GET | | Reset the stored network data usage total to zero |
| `/shutdown` | GET | | Shutdown menu |
## JSON API (`src/json_api.rs`)
All JSON API calls are prefixed by `/api/v1/`. This has been excluded from the table below to keep the table compact.
| Endpoint | Method | Parameters | Description |
| --- | --- | --- | --- |
| `device/reboot` | POST | | Reboot device |
| `device/shutdown` | POST | | Shutdown device |
| `network/activate_ap` | POST | | Activate WiFi access point mode |
| `network/activate_client` | POST | | Activate WiFi client mode |
| `network/ip` | GET | | Returns IP address values for wlan0 & ap0 interfaces |
| `network/rssi` | GET | | Returns RSSI for connected WiFi network |
| `network/ssid` | GET | | Returns SSID for connected WiFi network |
| `network/state` | GET | | Returns state of wlan0 & ap0 interfaces |
| `network/status` | GET | | Returns status object for connected WiFi network |
| `network/wifi` | GET | | Returns scan results for in-range access-points |
| `network/wifi` | POST | `ssid` & `pass` | Submit SSID & password to create new WiFi connection |
| `network/wifi/connect` | POST | `ssid` | Submit SSID to connect to a given WiFi network |
| `network/wifi/disconnect` | POST | `ssid` | Disconnect from the currently associated WiFi network |
| `network/wifi/forget` | POST | `ssid` | Submit SSID to delete credentials for given WiFi network |
| `network/wifi/modify` | POST | `ssid` & `pass` | Submit SSID & password to update the credentials for given WiFi network |
| `/network/wifi/usage` | POST | `rx_warn`, `rx_cut`, `tx_warn`, `tx_cut`, `rx_warn_flag`, `rx_cut_flag`, `tx_warn_flag`, `tx_cut_flag` | Submit form to update alert thresholds & set flags |
| `/network/wifi/usage/reset` | POST | | Reset network data usage total |
| `ping` | GET | | Returns `pong!` if `peach-web` is running |
| `ping/network` | GET | | Returns `pong!` if `peach-network` microservice is running |
| `ping/oled` | GET | | Returns `pong!` if `peach-oled` microservice is running |
| `ping/stats` | GET | | Returns `pong!` if `peach-stats` microservice is running |
## Environment
The web application deployment mode is configured with the `ROCKET_ENV` environment variable:
@ -77,7 +131,7 @@ Logging is made available with `env_logger`:
Other logging levels include `debug`, `warn` and `error`.
### Setup
## Setup
Clone this repo:
@ -98,4 +152,38 @@ Run the binary:
_Note: Networking functionality requires peach-network microservice to be running._
## Debian Packaging
A `systemd` service file and Debian maintainer scripts are included in the `debian` directory, allowing `peach-web` to be easily bundled as a Debian package (`.deb`). The `cargo-deb` [crate](https://crates.io/crates/cargo-deb) can be used to achieve this.
Install `cargo-deb`:
`cargo install cargo-deb`
Move into the repo:
`cd peach-web`
Build the package:
`cargo deb`
The output will be written to `target/debian/peach-web_0.3.0_arm64.deb` (or similar).
Install the package as follows:
`sudo dpkg -i target/debian/peach-web_0.3.0_arm64.deb`
The service will be automatically enabled and started.
Uninstall the service:
`sudo apt-get remove peach-web`
Remove configuration files (not removed with `apt-get remove`):
`sudo apt-get purge peach-web`
## Licensing
AGPL-3.0