-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
5,134 additions
and
911 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,114 +1,77 @@ | ||
# configng | ||
This is a refactoring of [armbian-config](https://github.com/armbian/config) using [Bash Utility](https://labbots.github.io/bash-utility) | ||
embedded in this project. This allows for functional programming in Bash. Error handling and validation are also included. | ||
The idea is to provide an API in Bash that can be called from a Command line interface, Text User interface and others. | ||
Why Bash? Well, because it's going to be in every distribution. Striped down distributions | ||
may not include Python, C/C++, etc. build/runtime environments | ||
|
||
## Quick start | ||
* `sudo apt install git` | ||
* `cd ~/` | ||
* `git clone https://github.com/armbian/configng.git` | ||
* `bash ~/configng/config.sh` | ||
|
||
#### If all goes well you should see list or avalible commands | ||
``` | ||
Usage: config [ -h | foo ] | ||
Options: | ||
-h) Print this help. | ||
foo) Usage: config foo [ desk_setup::options ][ io::options ][ boardled::options ][ cpu::options ][ extra_drive::options ][ benchymark::options ]:: | ||
desk_setup::options | ||
see_desktops Display a list of avalible desktops to install. | ||
<p align="center"> | ||
<img src="https://raw.githubusercontent.com/armbian/build/main/.github/armbian-logo.png" alt="Armbian logo" width="144"> | ||
<br> | ||
Armbian ConfigNG | ||
<br> | ||
<a href="https://www.codefactor.io/repository/github/tearran/configng"><img src="https://www.codefactor.io/repository/github/tearran/configng/badge" alt="CodeFactor" /></a> | ||
</p> | ||
|
||
io::options | ||
set_ir_toggle [ enable ][ disable ] Infrared Remote Control. | ||
boardled::options | ||
see_sysled See a list of board led options. | ||
see_sysled_none Set board led options to none (off). | ||
see_sysled_cpu Set board led options to monitor CPU. | ||
see_sysled_beat Set board led options to heartbeat pulse. | ||
# User guide | ||
## Quick start | ||
Run the following commands: | ||
|
||
sudo apt install git | ||
cd ~/ | ||
git clone https://github.com/armbian/configng.git | ||
cd configng | ||
./bin/armbian-configng --dev | ||
|
||
If all goes well you should see the Text-Based User Inerface (TUI) | ||
|
||
### To see a list of all functions and their descriptions, run the following command: | ||
~~~ | ||
bash ~/configng/bin/armbian-configng -h | ||
~~~ | ||
## Coding Style | ||
follow the following coding style: | ||
~~~ | ||
# @description A short description of the function. | ||
# | ||
# @exitcode 0 If successful. | ||
# | ||
# @options A description if there are options. | ||
function group::string() {s | ||
echo "hello world" | ||
return 0 | ||
} | ||
~~~ | ||
## Codestyle can be used to auto generate | ||
- [Markdown](share/armbian-configng/readme.md) | ||
- [JSON](share/armbian-configng/data/armbian-configng.json) | ||
- [CSV](share/armbian-configng/data/armbian-configng.csv) | ||
- [HTML](share/armbian-configng/armbian-configng-table.html) | ||
- [github.io](//tearran/github.io/armbian-configng/index.html) | ||
## Functions list as of 2023-12-05 | ||
## network | ||
System and Security | ||
|
||
cpu::options | ||
see_policy Return policy as int based on original armbian-config logic. | ||
see_freqs Return CPU frequencies as string delimited by space. | ||
see_min_freq Return CPU minimum frequency as string. | ||
see_max_freq Return CPU maximum frequency as string. | ||
see_governor Return CPU governor as string. | ||
see_governors Return CPU avalible governors as string delimited by space. | ||
set_freq ** disabled ** Set min, max and CPU governor. | ||
### set_wifi.sh | ||
|
||
extra_drive::options | ||
set_spi_vflash Set up a simulated MTD spi flash for testing. | ||
rem_spi_vflash Remove tsting simulated MTD spi flash. | ||
- **Group Name:** network | ||
- **Action Name:** NMTUI | ||
- **Options:** none. | ||
- **Description:** Network Manager. | ||
|
||
benchymark::options | ||
see_monitor system boot-up performance statistics. | ||
see_boot_times system boot-up performance statistics. | ||
## system | ||
Network Wired wireless Bluetooth access point | ||
|
||
``` | ||
#### Change the systems led to pulse a hearbeat | ||
``` | ||
bash ~/configng/bin/config.sh foo boardled::see_sysled_beat | ||
``` | ||
#### Change the systems led to off show a result in whiptail or dialog if installed | ||
``` | ||
bash ~/configng/bin/config.sh foo boardled::see_sysled_none | bash ~/configng/bin/jampi-config.sh | ||
``` | ||
#### See avalible settings sytem led options and current setting in [] | ||
``` | ||
bash ~/configng/bin/config.sh foo boardled::see_sysled | ||
``` | ||
#### See avalible armbian monitor options | ||
``` | ||
bash ~/configng/bin/config.sh foo benchymark:see_monitor | ||
``` | ||
### hello_world.sh | ||
|
||
- **Group Name:** system | ||
- **Action Name:** Hello | ||
- **Options:** none | ||
- **Description:** Hello System. | ||
|
||
## Coding standards | ||
[Shell Style Guide](https://google.github.io/styleguide/shellguide.html) has some good ideas, | ||
but fundementally look at the code in lib: | ||
``` | ||
# @description Strip characters from the beginning of a string. | ||
# | ||
# @example | ||
# echo "$(string::lstrip "Hello World!" "He")" | ||
# #Output | ||
# llo World! | ||
# | ||
# @arg $1 string The input string. | ||
# @arg $2 string The characters you want to strip. | ||
# | ||
# @exitcode 0 If successful. | ||
# @exitcode 2 Function missing arguments. | ||
# | ||
# @stdout Returns the modified string. | ||
string::lstrip() { | ||
[[ $# -lt 2 ]] && printf "%s: Missing arguments\n" "${FUNCNAME[0]}" && return 2 | ||
printf '%s\n' "${1##$2}" | ||
} | ||
``` | ||
### see_monitor.sh | ||
|
||
Functions should follow ~~filename~~::func_name style. Then you can tell just from the name which | ||
file the function is located in. Return codes should also follow a similar pattern: | ||
* 0 Successful | ||
* 1 Not found | ||
* 2 Function missing arguments | ||
* 3-255 all other errors | ||
- **Group Name:** monitor | ||
- **Action Name:** Bencharking | ||
- **Options:** | ||
- **Description:** Armbian Monitor and Bencharking. | ||
|
||
Validate values: | ||
``` | ||
# Validate minimum frequency is <= maximum frequency | ||
[ "$min_freq" -gt "$max_freq" ] && printf "%s: Minimum frequency must be <= maximum frequency\n" "${FUNCNAME[0]}" && return 5 | ||
``` | ||
|
||
Return values should use stdout: | ||
``` | ||
# Return value | ||
printf '%s\n' "$(cat $file)" | ||
``` | ||
# Inclueded projects | ||
- [Bash Utility](https://labbots.github.io/bash-utility) | ||
- [Armbian config](https://github.com/armbian/config.git) | ||
|
||
Only use sudo when needed and never run as root! |
Oops, something went wrong.