diff --git a/.github/workflows/ftp-deploy.yml.hold b/.github/workflows/ftp-deploy.yml.hold new file mode 100644 index 000000000..1a956dcdd --- /dev/null +++ b/.github/workflows/ftp-deploy.yml.hold @@ -0,0 +1,34 @@ +on: push +name: 🚀 Deploy website on push + +jobs: + web-deploy: + name: 🎉 Deploy + runs-on: ubuntu-latest + if: ${{ github.repository_owner == 'Tearran' }} + steps: + - name: 🚚 Get latest code + uses: actions/checkout@v3 + + - name: Install ShellCheck + run: sudo apt-get install pandoc git shellcheck + - name: Run ShellCheck + run: | + ret=0 + for file in $(find . -type f -name "*.sh"); do + shellcheck --severity=error $file || ret=$? + done + exit $ret + + - name: Generate website + run: ./bin/armbian-configng --dev --web + + - name: 📂 Sync files + uses: SamKirkland/FTP-Deploy-Action@v4.3.4 + with: + server: ${{ secrets.SERVER_HOST}} # replace with your server + username: ${{ secrets.SERVER_USERNAME }} + password: ${{ secrets.SERVER_PASSWORD }} + server-dir: / # replace with your server directory + local-dir: share/armbian-configng/web/ # replace with your local directory + diff --git a/README.md b/README.md old mode 100755 new mode 100644 index b3e4cb1d5..413391cff --- a/README.md +++ b/README.md @@ -1,83 +1,100 @@ -

- Armbian logo -
- Armbian ConfigNG -
- CodeFactor -

- -# User guide +# Armbian configuration utility +Utility for configuring your board, divided into four main sections: + +- System - system and security settings, +- Network - wired, wireless, Bluetooth, access point, +- Personal - timezone, language, hostname, +- Software - system and 3rd party software install. + + + +To Configure and change global sytem settings, run the following command: `./armbian-configng` + +*** +## Screenshots +![edit-boot-env-2024-04-03 10-06-58](https://github.com/armbian/configng/assets/2831630/448f0515-0854-4a8a-8421-53c8b72bb5c5) +![BT-connect-2024-04-03 10-06-58](https://github.com/armbian/configng/assets/2831630/fef037ce-346d-4d70-9025-90f69fbdf5d3) +Following was updated on: +Fri Apr 12 01:33:08 AM MST 2024. + +*** +- ## **System** + - **S01** - Description: Enable Armbina kernal upgrades + - Status: [WIP](https://github.com/armbian/configng/wiki/Menu#s01) + - **S02** - Description: Disable Armbina kernal upgrades + - Status: [WIP](https://github.com/armbian/configng/wiki/Menu#s02) + - **S03** - Description: Edit the boot enviroment (WIP) + - Status: [WIP](https://github.com/armbian/configng/wiki/Menu#s03) + + +- ## **Network** + - **BT0** - Description: Install Bluetooth support + - Status: [review](https://github.com/armbian/configng/wiki/Menu#bt0) + - **BT1** - Description: Remove Bluetooth support + - Status: [review](https://github.com/armbian/configng/wiki/Menu#bt1) + - **BT3** - Description: Bluetooth Discover + - Status: [review](https://github.com/armbian/configng/wiki/Menu#bt3) + - **IR0** - Description: Install Infrared support + - Status: [review](https://github.com/armbian/configng/wiki/Menu#ir0) + - **IR1** - Description: Uninstall Infrared support + - Status: [review](https://github.com/armbian/configng/wiki/Menu#ir1) + - **N00** - Description: Manage wifi network connections + - Status: [review](https://github.com/armbian/configng/wiki/Menu#n00) + - **N01** - Description: Advanced Edit /etc/network/interface + - Status: [review](https://github.com/armbian/configng/wiki/Menu#n01) + - **N02** - Description: Disconect and forget all wifi connections (Advanced) + - Status: [review](https://github.com/armbian/configng/wiki/Menu#n02) + - **N03** - Description: Toggle system IPv6/IPv4 internet protical + - Status: [review](https://github.com/armbian/configng/wiki/Menu#n03) + + +- ## **Localisation** + - **L00** - Description: Change Globla timezone (WIP) + - Status: [review](https://github.com/armbian/configng/wiki/Menu#l00) + - **L01** - Description: Change Locales reconfigure the language and charitorset + - Status: [review](https://github.com/armbian/configng/wiki/Menu#l01) + - **L02** - Description: Change Keyboard layout + - Status: [review](https://github.com/armbian/configng/wiki/Menu#l02) + - **L03** - Description: Change APT mirrors + - Status: [review](https://github.com/armbian/configng/wiki/Menu#l03) + + +- ## **Software** + - **I00** - Description: Update Application Repository + - Status: [review](https://github.com/armbian/configng/wiki/Menu#i00) + - **I01** - Description: CLI System Monitor + - Status: [review](https://github.com/armbian/configng/wiki/Menu#i01) + + +- ## **Help** + - **H00** - Description: About This systme. (WIP) + - Status: [review](https://github.com/armbian/configng/wiki/Menu#h00) + - **H02** - Description: List of Config function(WIP) + - Status: [review](https://github.com/armbian/configng/wiki/Menu#h02) + + +*** ## Quick start Run the following commands: - echo "deb [signed-by=/usr/share/keyrings/armbian.gpg] https://armbian.github.io/configng stable main" \ - | sudo tee /etc/apt/sources.list.d/armbian-development.list > /dev/null + echo "deb [signed-by=/usr/share/keyrings/armbian.gpg] https://armbian.github.io/configng stable main" | sudo tee /etc/apt/sources.list.d/armbian-development.list > /dev/null 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: -~~~ -armbian-configng -h -~~~ -## Coding Style -follow the following coding style: +## Development +Development test brances are available for testing. To clone the development branch, run the following commands: + ~~~ -# @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 -} +git clone https://github.com/armbian/configng.git +cd configng ~~~ -## 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-06 -## network -System and Security - -### set_wifi.sh - - - **Group Name:** network - - **Action Name:** NMTUI - - **Options:** none. - - **Description:** Network Manager. - -## system -Network Wired wireless Bluetooth access point - -### armbian_install.sh - - - **Group Name:** system - - **Action Name:** Install - - **Options:** none - - **Description:** Armbian installer. - -### hello_world.sh - - - **Group Name:** system - - **Action Name:** Hello - - **Options:** none - - **Description:** Hello System. - -### see_monitor.sh - - - **Group Name:** monitor - - **Action Name:** Benchmarking - - **Options:** - - **Description:** Armbian Monitor and Benchmarking. -# Included projects -- [Bash Utility](https://labbots.github.io/bash-utility) -- [Armbian config](https://github.com/armbian/config.git) +## Note: +> +> The Bash procedures embedded within the JSON structure are meticulously designed with a focus on clear naming conventions and the simplicity of key pairs. These procedures serve multiple purposes, including facilitating the generation of content in various formats, such as Whiptail, Markdown, json out and others. Moreover, they are utilized for evaluation and execution of commands outlined in the JSON structure. +> diff --git a/bin/README.md b/bin/README.md new file mode 100644 index 000000000..413391cff --- /dev/null +++ b/bin/README.md @@ -0,0 +1,100 @@ + +# Armbian configuration utility +Utility for configuring your board, divided into four main sections: + +- System - system and security settings, +- Network - wired, wireless, Bluetooth, access point, +- Personal - timezone, language, hostname, +- Software - system and 3rd party software install. + + + +To Configure and change global sytem settings, run the following command: `./armbian-configng` + +*** +## Screenshots +![edit-boot-env-2024-04-03 10-06-58](https://github.com/armbian/configng/assets/2831630/448f0515-0854-4a8a-8421-53c8b72bb5c5) +![BT-connect-2024-04-03 10-06-58](https://github.com/armbian/configng/assets/2831630/fef037ce-346d-4d70-9025-90f69fbdf5d3) +Following was updated on: +Fri Apr 12 01:33:08 AM MST 2024. + +*** +- ## **System** + - **S01** - Description: Enable Armbina kernal upgrades + - Status: [WIP](https://github.com/armbian/configng/wiki/Menu#s01) + - **S02** - Description: Disable Armbina kernal upgrades + - Status: [WIP](https://github.com/armbian/configng/wiki/Menu#s02) + - **S03** - Description: Edit the boot enviroment (WIP) + - Status: [WIP](https://github.com/armbian/configng/wiki/Menu#s03) + + +- ## **Network** + - **BT0** - Description: Install Bluetooth support + - Status: [review](https://github.com/armbian/configng/wiki/Menu#bt0) + - **BT1** - Description: Remove Bluetooth support + - Status: [review](https://github.com/armbian/configng/wiki/Menu#bt1) + - **BT3** - Description: Bluetooth Discover + - Status: [review](https://github.com/armbian/configng/wiki/Menu#bt3) + - **IR0** - Description: Install Infrared support + - Status: [review](https://github.com/armbian/configng/wiki/Menu#ir0) + - **IR1** - Description: Uninstall Infrared support + - Status: [review](https://github.com/armbian/configng/wiki/Menu#ir1) + - **N00** - Description: Manage wifi network connections + - Status: [review](https://github.com/armbian/configng/wiki/Menu#n00) + - **N01** - Description: Advanced Edit /etc/network/interface + - Status: [review](https://github.com/armbian/configng/wiki/Menu#n01) + - **N02** - Description: Disconect and forget all wifi connections (Advanced) + - Status: [review](https://github.com/armbian/configng/wiki/Menu#n02) + - **N03** - Description: Toggle system IPv6/IPv4 internet protical + - Status: [review](https://github.com/armbian/configng/wiki/Menu#n03) + + +- ## **Localisation** + - **L00** - Description: Change Globla timezone (WIP) + - Status: [review](https://github.com/armbian/configng/wiki/Menu#l00) + - **L01** - Description: Change Locales reconfigure the language and charitorset + - Status: [review](https://github.com/armbian/configng/wiki/Menu#l01) + - **L02** - Description: Change Keyboard layout + - Status: [review](https://github.com/armbian/configng/wiki/Menu#l02) + - **L03** - Description: Change APT mirrors + - Status: [review](https://github.com/armbian/configng/wiki/Menu#l03) + + +- ## **Software** + - **I00** - Description: Update Application Repository + - Status: [review](https://github.com/armbian/configng/wiki/Menu#i00) + - **I01** - Description: CLI System Monitor + - Status: [review](https://github.com/armbian/configng/wiki/Menu#i01) + + +- ## **Help** + - **H00** - Description: About This systme. (WIP) + - Status: [review](https://github.com/armbian/configng/wiki/Menu#h00) + - **H02** - Description: List of Config function(WIP) + - Status: [review](https://github.com/armbian/configng/wiki/Menu#h02) + + +*** +## Quick start +Run the following commands: + + echo "deb [signed-by=/usr/share/keyrings/armbian.gpg] https://armbian.github.io/configng stable main" | sudo tee /etc/apt/sources.list.d/armbian-development.list > /dev/null + + armbian-configng --dev + +If all goes well you should see the Text-Based User Inerface (TUI) + +## Development +Development test brances are available for testing. To clone the development branch, run the following commands: + +~~~ +git clone https://github.com/armbian/configng.git +cd configng +~~~ + + + +## Note: +> +> The Bash procedures embedded within the JSON structure are meticulously designed with a focus on clear naming conventions and the simplicity of key pairs. These procedures serve multiple purposes, including facilitating the generation of content in various formats, such as Whiptail, Markdown, json out and others. Moreover, they are utilized for evaluation and execution of commands outlined in the JSON structure. +> diff --git a/bin/armbian-configng b/bin/armbian-configng old mode 100755 new mode 100644 index 2a6c89774..c6d040f14 --- a/bin/armbian-configng +++ b/bin/armbian-configng @@ -1,222 +1,87 @@ #!/bin/bash -# This script provides a command-line interface for managing Armbian configuration. -# It loads libraries of functions from the lib directory and displays them in a menu. -# The user can select a function to run, or use a text-based user interface (TUI) to navigate the menus. -# The script also provides a help option and a debug option for developers. -# The script requires sudo privileges to run some functions. -# The script uses whiptail or dialog for the TUI, depending on which is available. - -#set -x -#set -e +tput init # -# Enable Dynamic directory root use home ~/ , /bin , /usr/sbin etc.. -bin="$(dirname "${BASH_SOURCE[0]}")" -directory="$(cd "$bin/../" && pwd )" -file_name="$(basename "${BASH_SOURCE[0]}")" -filename="${file_name%.*}" -libpath=$(cd "$directory/lib/$filename/" && pwd) -#sharepath=$(cd "$directory/share/${filename%-dev}/" && pwd) +# Language-based variable assignment for script directory path +# This serves as a Rosetta Stone for developers, +# allowing them to use the variable name they are most comfortable with. +# allows CTRL c to exit +trap "exit" INT TERM -# -# Consept Distribution Compatibility checks -check_distro() { +if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then +# TODO : Add help message + echo -e "\nComming soon:\nsimple help meassage\n" + exit 0 ; +fi - [[ -f "/usr/bin/${filename%%-*}-config" ]] && distro_config="${filename%%-*}" - [[ -f "/etc/${filename%%-*}-release" ]] && distro_release="${filename%%-*}" - # if both true then we are good to go - [[ -z "$distro_config" ]] || [[ -z "$distro_release" ]] && echo "W: Costum build, Tech support links are missing." - [[ -n "$distro_config" ]] && [[ -n "$distro_release" ]] && echo "I: This build seems to be community supported" | ./armbian-interface -o - [[ -f "/usr/sbin/${filename%%-*}-config" ]] && distro_config="${filename%%-*}" - [[ -f "/etc/${filename%%-*}-release" ]] && distro_release="${filename%%-*}" -} +# Get the script directory +script_dir="$(dirname "$0")" -[[ "$1" == "--dev" ]] && dev=1 && shift 1 +# Define the lib directory one level up from the script directory +lib_dir="$script_dir/../lib/armbian-configng" +doc_dir="$script_dir/../share/doc/armbian-configng" +# Check for the existence of the config.ng.jobs.json file in the lib directory +json_file="$lib_dir/config.ng.jobs.json" # -# Check if the script is dev version. -suffix="${file_name##*-}" +# Load The Bash procedure Objects +json_data=$(cat "$json_file") -if [[ "$suffix" == dev ]]; then - dev=1 - check_distro #| armbian-interface -o -fi - -if [[ "$(id -u)" != "0" ]] && [[ "$dev" == "1" ]] ; then -cat << EOF #| ./armbian-interface -o -I: Running in UX development mode -W: Admin functions will not work as expected +# +# 'whiptail' is a simple dialog box utility that works well with Bash. It doesn't have all the features of some other dialog box utilities, but it does everything we need for this script. +[[ -x "$(command -v whiptail)" ]] && DIALOG="whiptail" -EOF -elif [[ "$(id -u)" == "0" ]] && [[ "$dev" == "1" ]] ; then -cat << EOF | ./armbian-interface -o -I: Running in UX development mode -W: Document files may need Admin privleges to edit/remove -EOF +# +# Prepare the module options array +declare -A module_options -fi # -# Check if the script is being run as root -# UX Development mode bypasses root check, many functions will not work as expected +# Load configng core functions and module options array -if [[ "$(id -u)" != "0" ]] && [[ "$dev" != "1" ]]; then - echo -e "E: This tool requires root privileges. Try: \"sudo $filename\"" >&2 - exit 1 -fi -declare -A dialogue +source "$lib_dir/config.ng.functions.sh" +set_runtime_variables +echo "Loaded Runtime variables..." | show_infobox ; +set_newt_colors 2 +echo "Loaded Dialog..." | show_infobox ; +source "$lib_dir/config.ng.docs.sh" +echo "Loaded Docs..." | show_infobox ; +source "$lib_dir/config.ng.network.sh" +echo "Loaded Network helpers..." | show_infobox ; -# -# Check if whiptail or dialog is installed and set the variable 'dialogue' accordingly. -# todo add a fallback TUI and GUI -if command -v whiptail &> /dev/null; then - dialogue="whiptail" -elif command -v dialog &> /dev/null; then - dialogue="dialog" -else - echo "TUI not found" - echo "Warning: Using fallback TUI" - sleep 1 - clear && generate_read -fi - -source "$libpath/functions.sh" -source "$libpath/documents.sh" -for file in "$libpath"/*/*.sh; do - source "$file" -done # -# mapfile -t categories < <(ls -d "$libpath"/* ) -mapfile -t categories < <(find "$libpath"/* -type d) -declare -A functions - -for category in "${categories[@]}"; do - category_name="${category##*/}" - - category_file="$category/readme.md" - if [[ -f "$category_file" ]]; then - category_description=$(grep -oP "(?<=# @description ).*" "$category_file") - fi - - for file in "$category"/*.sh; do - description="" - while IFS= read -r line; do - if [[ $line =~ ^#\ @description\ (.*)$ ]]; then - description="${BASH_REMATCH[1]}" - elif [[ $line =~ ^function\ (.*::.*)\(\)\{$ ]]; then - # END: be15d9bcejpp - function_name="${BASH_REMATCH[1]}" - key="$category_name:${file##*/}:${function_name}" - functions["$key,function_name"]=$(echo "$function_name" | sed 's/.*:://') - functions["$key,group_name"]=$(echo "$function_name" | sed 's/::.*//') - functions["$key,description"]=$description - elif [[ $line =~ ^#\ @options\ (.*)$ ]]; then - functions["$key,options"]="${BASH_REMATCH[1]}" - fi - done < "$file" - functions["$key,category"]=$category_name - functions["$key,category_description"]=$category_description - done -done +# Loads the varibles from beta armbian-config for runtime handeling +source "$lib_dir/config.ng.runtime.sh" ; +echo "Loaded Runtime conditions..." | show_infobox ; # -# WIP: Check arguments for no flag options -# armbian-config --help -# Change to BASH: /usr/sbin/armbian-config main=System selection=BASH -handle_no_flag(){ -if [[ "$1" == *"="* ]]; then - IFS='=' read -r key value <<< "$1" - function_name=$(parse_action "$key" "$value") - # Call the function using variable indirection - ${function_name} -elif [[ "$1" == "help"* ]]; then - generate_list_cli +# if not sudo +# Runtime "include this script" for USER and development setup condistion +if [[ $EUID != 0 ]]; then + source "$lib_dir/config.ng.runtime.dev.sh" ; + echo "Loaded Develoment +Runtime conditions..." | show_infobox ; + fi -} + + + + +tput clear # -# Check arguments for long flag options -# Help message related to the functions the back end -handle_long_flag(){ - if [[ "$1" == "--help" ]]; then - generate_list_run - exit 0 ; - elif [[ "$1" == "--doc" ]]; then - generate_doc - exit 0 ; - fi -# WIP: - if [ "$1" == "--run" ]; then - shift # Shifts the arguments to the left, excluding the first argument ("-r") - group_name="$1" # Takes the first argument as the group name - shift 1 # Shifts the arguments again to exclude the group name - - function_name=$(parse_action "$group_name" "$1") - if [ $? -eq 0 ]; then - # Call the function using variable indirection - ${function_name} - fi - elif [ "$1" == "--help" ]; then - generate_list_run - exit - elif [ "$1" == "--test" ]; then - check_distro | armbian-interface -o && $1 > /dev/null - fi - -} -# -# Check arguments for short flag options -# THe interface help message -handle_short_flag(){ -if [ "$1" == "-h" ]; then - generate_help - exit 0 ; -# Generate a text-based user interface -elif [ "$1" == "-t" ] ; then - generate_read ; exit 0 ; -# Generate all doc files -elif [ "$1" == "-d" ] ; then - generate_doc ; exit 0 ; -elif [ "$1" == "-j" ] ; then - generate_json ; exit 0 ; -fi +# Generate the top menu with the modified Object data +while generate_top_menu "$json_data"; do tput clear ; done -} - -case "$1" in - *"="*) - # Handle the case where $1 contains "=" - handle_no_flag "$@" - ;; - *"--"*) - # Handle the case where $1 starts with "--" - handle_long_flag "$@" - ;; - *"-"*) - # Handle the case where $1 starts with "-" - handle_short_flag "$1" - ;; - *) - handle_no_flag "$@" - # Handle the case where $1 does not match any of the above patterns - # You can add your code here - ;; -esac - -if [[ -z "$1" ]] ; then - while true; do - generate_tui ; - if [[ "$?" == "0" ]]; then - exit 0 - fi - done - -fi \ No newline at end of file + +# +# Exit the script with a success status code +exit 0 diff --git a/bin/configng-cli b/bin/configng-cli new file mode 100755 index 000000000..2a6c89774 --- /dev/null +++ b/bin/configng-cli @@ -0,0 +1,222 @@ +#!/bin/bash + +# This script provides a command-line interface for managing Armbian configuration. +# It loads libraries of functions from the lib directory and displays them in a menu. +# The user can select a function to run, or use a text-based user interface (TUI) to navigate the menus. +# The script also provides a help option and a debug option for developers. +# The script requires sudo privileges to run some functions. +# The script uses whiptail or dialog for the TUI, depending on which is available. + +#set -x +#set -e + +# +# Enable Dynamic directory root use home ~/ , /bin , /usr/sbin etc.. +bin="$(dirname "${BASH_SOURCE[0]}")" +directory="$(cd "$bin/../" && pwd )" +file_name="$(basename "${BASH_SOURCE[0]}")" +filename="${file_name%.*}" +libpath=$(cd "$directory/lib/$filename/" && pwd) +#sharepath=$(cd "$directory/share/${filename%-dev}/" && pwd) + + +# +# Consept Distribution Compatibility checks +check_distro() { + + [[ -f "/usr/bin/${filename%%-*}-config" ]] && distro_config="${filename%%-*}" + [[ -f "/etc/${filename%%-*}-release" ]] && distro_release="${filename%%-*}" + # if both true then we are good to go + [[ -z "$distro_config" ]] || [[ -z "$distro_release" ]] && echo "W: Costum build, Tech support links are missing." + [[ -n "$distro_config" ]] && [[ -n "$distro_release" ]] && echo "I: This build seems to be community supported" | ./armbian-interface -o + [[ -f "/usr/sbin/${filename%%-*}-config" ]] && distro_config="${filename%%-*}" + [[ -f "/etc/${filename%%-*}-release" ]] && distro_release="${filename%%-*}" + +} + +[[ "$1" == "--dev" ]] && dev=1 && shift 1 + +# +# Check if the script is dev version. +suffix="${file_name##*-}" + +if [[ "$suffix" == dev ]]; then + dev=1 + check_distro #| armbian-interface -o +fi + +if [[ "$(id -u)" != "0" ]] && [[ "$dev" == "1" ]] ; then + +cat << EOF #| ./armbian-interface -o +I: Running in UX development mode +W: Admin functions will not work as expected + +EOF +elif [[ "$(id -u)" == "0" ]] && [[ "$dev" == "1" ]] ; then +cat << EOF | ./armbian-interface -o +I: Running in UX development mode +W: Document files may need Admin privleges to edit/remove + +EOF + +fi + +# +# Check if the script is being run as root +# UX Development mode bypasses root check, many functions will not work as expected + +if [[ "$(id -u)" != "0" ]] && [[ "$dev" != "1" ]]; then + echo -e "E: This tool requires root privileges. Try: \"sudo $filename\"" >&2 + exit 1 +fi + +declare -A dialogue + +# +# Check if whiptail or dialog is installed and set the variable 'dialogue' accordingly. +# todo add a fallback TUI and GUI +if command -v whiptail &> /dev/null; then + dialogue="whiptail" +elif command -v dialog &> /dev/null; then + dialogue="dialog" +else + echo "TUI not found" + echo "Warning: Using fallback TUI" + sleep 1 + clear && generate_read +fi + +source "$libpath/functions.sh" +source "$libpath/documents.sh" +for file in "$libpath"/*/*.sh; do + source "$file" +done + +# +# mapfile -t categories < <(ls -d "$libpath"/* ) +mapfile -t categories < <(find "$libpath"/* -type d) +declare -A functions + +for category in "${categories[@]}"; do + category_name="${category##*/}" + + category_file="$category/readme.md" + if [[ -f "$category_file" ]]; then + category_description=$(grep -oP "(?<=# @description ).*" "$category_file") + fi + + for file in "$category"/*.sh; do + description="" + while IFS= read -r line; do + if [[ $line =~ ^#\ @description\ (.*)$ ]]; then + description="${BASH_REMATCH[1]}" + elif [[ $line =~ ^function\ (.*::.*)\(\)\{$ ]]; then + # END: be15d9bcejpp + function_name="${BASH_REMATCH[1]}" + key="$category_name:${file##*/}:${function_name}" + functions["$key,function_name"]=$(echo "$function_name" | sed 's/.*:://') + functions["$key,group_name"]=$(echo "$function_name" | sed 's/::.*//') + functions["$key,description"]=$description + elif [[ $line =~ ^#\ @options\ (.*)$ ]]; then + functions["$key,options"]="${BASH_REMATCH[1]}" + fi + done < "$file" + functions["$key,category"]=$category_name + functions["$key,category_description"]=$category_description + done +done + + +# +# WIP: Check arguments for no flag options +# armbian-config --help +# Change to BASH: /usr/sbin/armbian-config main=System selection=BASH +handle_no_flag(){ +if [[ "$1" == *"="* ]]; then + IFS='=' read -r key value <<< "$1" + function_name=$(parse_action "$key" "$value") + # Call the function using variable indirection + ${function_name} +elif [[ "$1" == "help"* ]]; then + generate_list_cli +fi +} + +# +# Check arguments for long flag options +# Help message related to the functions the back end +handle_long_flag(){ + if [[ "$1" == "--help" ]]; then + generate_list_run + exit 0 ; + elif [[ "$1" == "--doc" ]]; then + generate_doc + exit 0 ; + fi +# WIP: + if [ "$1" == "--run" ]; then + shift # Shifts the arguments to the left, excluding the first argument ("-r") + group_name="$1" # Takes the first argument as the group name + shift 1 # Shifts the arguments again to exclude the group name + + function_name=$(parse_action "$group_name" "$1") + if [ $? -eq 0 ]; then + # Call the function using variable indirection + ${function_name} + fi + elif [ "$1" == "--help" ]; then + generate_list_run + exit + elif [ "$1" == "--test" ]; then + check_distro | armbian-interface -o && $1 > /dev/null + fi + +} +# +# Check arguments for short flag options +# THe interface help message +handle_short_flag(){ +if [ "$1" == "-h" ]; then + generate_help + exit 0 ; +# Generate a text-based user interface +elif [ "$1" == "-t" ] ; then + generate_read ; exit 0 ; +# Generate all doc files +elif [ "$1" == "-d" ] ; then + generate_doc ; exit 0 ; +elif [ "$1" == "-j" ] ; then + generate_json ; exit 0 ; +fi + +} + +case "$1" in + *"="*) + # Handle the case where $1 contains "=" + handle_no_flag "$@" + ;; + *"--"*) + # Handle the case where $1 starts with "--" + handle_long_flag "$@" + ;; + *"-"*) + # Handle the case where $1 starts with "-" + handle_short_flag "$1" + ;; + *) + handle_no_flag "$@" + # Handle the case where $1 does not match any of the above patterns + # You can add your code here + ;; +esac + +if [[ -z "$1" ]] ; then + while true; do + generate_tui ; + if [[ "$?" == "0" ]]; then + exit 0 + fi + done + +fi \ No newline at end of file diff --git a/bin/armbian-interface b/bin/configng-tui similarity index 100% rename from bin/armbian-interface rename to bin/configng-tui diff --git a/lib/armbian-configng/config.ng.docs.sh b/lib/armbian-configng/config.ng.docs.sh new file mode 100644 index 000000000..791ba27e8 --- /dev/null +++ b/lib/armbian-configng/config.ng.docs.sh @@ -0,0 +1,422 @@ +#!/bin/bash + +# This file is part of Armbian configuration utility. + +module_options+=( + ["generate_readme,author"]="Joey Turner" + ["generate_readme,ref_link"]="https://github.com/armbian/configng/blob/main/lib/armbian-configng/documents.sh#L18" + ["generate_readme,feature"]="generate_readme" + ["generate_readme,desc"]="Generate Document files." + ["generate_readme,example"]="generate_readme" + ["generate_readme,status"]="review" + ["generate_readme,doc_link"]="" +) +# +# Function to generate the README.md file +# +function generate_readme() { + + # Get the current date + local current_date=$(date) + +# [[ ! -d "$script_dir/images" ]] && mkdir -p "$script_dir/images" && generate_svg > "$script_dir/images/logo.svg" ; +# [[ ! -f "$script_dir/images/logo.svg" ]] && generate_svg > "$script_dir/images/logo.svg" ; + + +echo "Sorting data\nUpdating documentation" | show_infobox ; + +###################################### +# Generate the README.md file +echo "$(see_jobs_list)" > "$script_dir/README.md" +echo "Updating Readme.md" | show_infobox + + +###################################### + + +cp "$script_dir/README.md" "$doc_dir/Home.md" +cd "$script_dir" && cp ./README.md "../README.md" +echo "README.md has been updated." | show_infobox + +###################################### + +echo "Updating WIKI Functions" | show_infobox +cat << EOF > "$doc_dir/Functions.md" + +# Helper functions +A list of the heper function ie bash prosedures used in Jobs file. + +$(see_function_table_md) + +EOF + +###################################### + +echo "Updating WIKI HowTo" | show_infobox +cat << EOF > "$doc_dir/Menu.md" + +# Armbian-config Menu list. +armbian-config jobs list. + +$(see_jq_menu_list) + +EOF + +###################################### + +# show_infobox <<< $( echo "$(generate_json_options)" > "$script_dir/docs/config-helpers.json" ) +# Print a message indicating that README.md has been updated +# echo "Documents have been updated." | show_infobox + +} + + +module_options+=( + ["serve_doc,author"]="Tearran" + ["serve_doc,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L89" + ["serve_doc,feature"]="serve_doc" + ["serve_doc,desc"]="Serve the edit and debug server." + ["serve_doc,example"]="serve_doc" + ["serve_doc,status"]="review" + ["serve_doc,doc_link"]="" +) +# +# Function to serve the edit and debug server +# +function serve_doc() { + if [[ "$(id -u)" == "0" ]] ; then + echo "Red alert! not for sude user" + exit 1 + fi + if [[ -z $CODESPACES ]]; then + # Start the Python server in the background + python3 -m http.server > /tmp/config.log 2>&1 & + local server_pid=$! + local input=(" + Starting server... + Server PID: $server_pid + + Press [Enter] to exit" + ) + + $DIALOG --title "Message Box" --msgbox "$input" 0 0 + + # Stop the server + kill "$server_pid" + else + echo "Info:GitHub Codespace" + exit 0 + fi +} + + +module_options+=( + ["see_use,author"]="Tearran" + ["see_use,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L126" + ["see_use,feature"]="see_use" + ["see_use,desc"]="Show the usage of the functions." + ["see_use,example"]="see_use" + ["see_use,status"]="review" + ["see_use,doc_link"]="" +) +# +# Function to parse the key-pairs (WIP) +# +function see_use() { + mod_message="Usage: \n\n" + # Iterate over the options + for key in "${!module_options[@]}"; do + # Split the key into function_name and type + IFS=',' read -r function_name type <<< "$key" + # If the type is 'long', append the option to the help message + if [[ "$type" == "feature" ]]; then + mod_message+="${module_options["$function_name,feature"]} - ${module_options["$function_name,desc"]}\n" + mod_message+=" ${module_options["$function_name,example"]}\n\n" + fi + done + + echo -e "$mod_message" +} + + +module_options+=( + ["generate_json_options,author"]="Tearran" + ["generate_json_options,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L149" + ["generate_json_options,feature"]="generate_json" + ["generate_json_options,desc"]="Generate JSON-like object file." + ["generate_json_options,example"]="generate_json" + ["generate_json_options,status"]="review" + ["generate_json_options,doc_link"]="" +) +# +# Function to generate a JSON-like object file +# +function generate_json_options() { + echo -e "{\n\"configng-helpers\" : [" +features=() +for key in "${!module_options[@]}"; do + if [[ $key == *",feature" ]]; then + features+=("${module_options[$key]}") + fi +done + +for index in "${!features[@]}"; do + feature=${features[$index]} + desc_key="${feature},desc" + example_key="${feature},example" + author_key="${feature},author" + ref_key="${feature},ref_link" + status_key="${feature},status" + doc_key="${feature},doc_link" + author="${module_options[$author_key]}" + ref_link="${module_options[$ref_key]}" + status="${module_options[$status_key]}" + doc_link="${module_options[$doc_key]}" + desc="${module_options[$desc_key]}" + example="${module_options[$example_key]}" + echo " {" + echo " \"id\": \"$feature\"," + echo " \"Author\": \"$author\"," + echo " \"src_reference\": \"$ref_link\"," + echo " \"description\": \"$desc\"," + echo " \"command\": [ \"$example\" ]", + echo " \"status\": \"$status\"," + echo " \"doc_link\": \"$doc_link\"" + if [ $index -ne $(( ${#features[@]}-1 )) ]; then + echo " }," + else + echo " }" + fi +done +echo "]" +echo "}" +} + + +module_options+=( + ["generate_svg,author"]="Tearran" + ["generate_svg,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#201" + ["generate_svg,feature"]="generate_svg" + ["generate_svg,desc"]="Generate 'Armbian CPU logo' SVG for docunment file." + ["generate_svg,example"]="generate_svg" + ["generate_svg,status"]="review" + ["generate_svg,doc_link"]="" +) +# +# This function is used to generate a armbian CPU logo +# +function generate_svg(){ + +cat << EOF + + + + + + +EOF +} + + +module_options+=( + ["generate_jobs_from_json,author"]="Tearran" + ["generate_jobs_from_json,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L223" + ["generate_jobs_from_json,feature"]="generate_jobs_from_json" + ["generate_jobs_from_json,desc"]="Generate jobs from JSON file." + ["generate_jobs_from_json,example"]="generate_jobs_from_json" + ["generate_jobs_from_json,status"]="review" + ["generate_jobs_from_json,doc_link"]="" +) +# +# This function is used to generate jobs links Table from JSON file. +# +function see_jobs_from_json_md() { + +echo -e "\n" + +# Use jq to parse the JSON +menu_items=$(jq -r '.menu | length' "$json_file") + +for (( i=0; i<$menu_items; i++ )) +do + cat=$(jq -r ".menu[$i].id" "$json_file") + description=$(jq -r ".menu[$i].description" "$json_file") + #echo -e "## $cat\n" + #echo -e "$description\n" + echo -e "| "$cat" | ID | Description | Documents | Status |" + echo -e "|:------ | :-- | :---------- | --------: | ------:|" + + sub_items=$(jq -r ".menu[$i].sub | length" "$json_file") + + for (( j=0; j<$sub_items; j++ )) + do + id=$(jq -r ".menu[$i].sub[$j].id" "$json_file") + id_link=$(jq -r ".menu[$i].sub[$j].id" "$json_file"| tr '[:upper:]' '[:lower:]') + description=$(jq -r ".menu[$i].sub[$j].description" "$json_file") + command=$(jq -r ".menu[$i].sub[$j].command" "$json_file") + status=$(jq -r ".menu[$i].sub[$j].status" "$json_file") + doc_link=$(jq -r ".menu[$i].sub[$j].doc_link" "$json_file") + + # Check if src_reference and doc_link are null + if [ "$doc_link" == "" ]; then doc_link="https://github.com/armbian/configng/wiki/Menu#$id_link"; else doc_link="[Document]($doc_link)"; fi + + echo -e "| | $id | $description | $doc_link | $status |" + + done + echo -e "\n" +done + +} + +function see_jobs_list() { + + cat << EOF + +# Armbian configuration utility +Utility for configuring your board, divided into four main sections: + +- System - system and security settings, +- Network - wired, wireless, Bluetooth, access point, +- Personal - timezone, language, hostname, +- Software - system and 3rd party software install. + + + +To Configure and change global sytem settings, run the following command: \`./armbian-configng\` + +*** +## Screenshots +![edit-boot-env-2024-04-03 10-06-58](https://github.com/armbian/configng/assets/2831630/448f0515-0854-4a8a-8421-53c8b72bb5c5) +![BT-connect-2024-04-03 10-06-58](https://github.com/armbian/configng/assets/2831630/fef037ce-346d-4d70-9025-90f69fbdf5d3) +Following was updated on: +$current_date. + +*** +EOF + + # Use jq to parse the JSON + menu_items=$(jq -r '.menu | length' "$json_file") + + for (( i=0; i<$menu_items; i++ )) + do + cat=$(jq -r ".menu[$i].id" "$json_file") + description=$(jq -r ".menu[$i].description" "$json_file") + + echo -e "- ## **$cat** " + #echo "$description" + + sub_items=$(jq -r ".menu[$i].sub | length" "$json_file") + + for (( j=0; j<$sub_items; j++ )) + do + id=$(jq -r ".menu[$i].sub[$j].id" "$json_file") + id_link=$(jq -r ".menu[$i].sub[$j].id" "$json_file"| tr '[:upper:]' '[:lower:]') + description=$(jq -r ".menu[$i].sub[$j].description" "$json_file") + command=$(jq -r ".menu[$i].sub[$j].command" "$json_file") + status=$(jq -r ".menu[$i].sub[$j].status" "$json_file") + doc_link=$(jq -r ".menu[$i].sub[$j].doc_link" "$json_file") + + # Check if src_reference and doc_link are null + if [ "$doc_link" == "" ]; then + doc_link="https://github.com/armbian/configng/wiki/Menu#$id_link"; + else doc_link="$doc_link"; + fi + + echo -e " - **$id** - Description: $description" + echo -e " - Status: [$status]($doc_link)" + + done + echo -e "\n" + done + +cat << EOF +*** +## Quick start +Run the following commands: + + echo "deb [signed-by=/usr/share/keyrings/armbian.gpg] https://armbian.github.io/configng stable main" \ + | sudo tee /etc/apt/sources.list.d/armbian-development.list > /dev/null + + armbian-configng --dev + +If all goes well you should see the Text-Based User Inerface (TUI) + +## Development +Development test brances are available for testing. To clone the development branch, run the following commands: + +~~~ +git clone https://github.com/armbian/configng.git +cd configng +~~~ + + + +## Note: +> +> The Bash procedures embedded within the JSON structure are meticulously designed with a focus on clear naming conventions and the simplicity of key pairs. These procedures serve multiple purposes, including facilitating the generation of content in various formats, such as Whiptail, Markdown, json out and others. Moreover, they are utilized for evaluation and execution of commands outlined in the JSON structure. +> + +EOF + +} + + +module_options+=( + ["see_function_table_md,author"]="Tearran" + ["see_function_table_md,ref_link"]="" + ["see_function_table_md,feature"]="see_function_table_md" + ["see_function_table_md,desc"]="Generate this markdown table of all module_options" + ["see_function_table_md,example"]="see_function_table_md" + ["see_function_table_md,status"]="review" + ["see_function_table_md,doc_link"]="" +) +# +# This function is used to generate a markdown table from the module_options array +# +function see_function_table_md() { + mod_message="| Feature | Description | Credit | Reference | Documents | Status |\n" + mod_message+="|:------- | ----------- | ----------- |:---------:|:---------:|:------:|\n" + # Iterate over the options + for key in "${!module_options[@]}"; do + # Split the key into function_name and type + IFS=',' read -r function_name type <<< "$key" + # If the type is 'feature', append the option to the help message + if [[ "$type" == "feature" ]]; then + status=${module_options["$function_name,status"]} + ref_link=${module_options["$function_name,ref_link"]} + doc_link=${module_options["$function_name,doc_link"]} + ref_link_md=$([[ -n "$ref_link" ]] && echo "[Source]($ref_link)" || echo "X") + doc_link_md=$([[ -n "$doc_link" ]] && echo "[Document]($doc_link)" || echo "X") + status_md=$([[ -z "$ref_link" ]] && echo "source link Needed" || ([[ ( -n "$ref_link" && -n "$doc_link") ]] && echo "Review" || echo "$status" ) ) + mod_message+="| ${module_options["$function_name,feature"]} | ${module_options["$function_name,desc"]} | ${module_options["$function_name,author"]} | $ref_link_md | $doc_link_md | $status_md | \n" + fi + done + + echo -e "$mod_message" +} + + +module_options+=( + ["see_jq_menu_list,author"]="Tearran" + ["see_jq_menu_list,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L304" + ["see_jq_menu_list,feature"]="see_jq_menu_list" + ["see_jq_menu_list,desc"]="Generate a markdown list json objects using jq." + ["see_jq_menu_list,example"]="see_jq_menu_list" + ["see_jq_menu_list,status"]="review" + ["see_jq_menu_list,doc_link"]="" +) +# +# This function is used to generate a markdown list from the json object using jq. +# +function see_jq_menu_list() { + +jq -r ' + .menu[] | + .sub[] | + "### " + .id + "\n\n" + + .description + "\n\nJobs:\n\n~~~\n" + + (.command | join("\n")) + + "\n~~~\n" +' $json_file +} + diff --git a/lib/armbian-configng/config.ng.functions.sh b/lib/armbian-configng/config.ng.functions.sh new file mode 100644 index 000000000..9fe363d4b --- /dev/null +++ b/lib/armbian-configng/config.ng.functions.sh @@ -0,0 +1,739 @@ +#!/bin/bash + + + + + +module_options+=( +["check_desktop,author"]="Igor Pecovnik" +["check_desktop,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L16" +["check_desktop,feature"]="check_desktop" +["check_desktop,desc"]="Migrated procedures from Armbian config." +["check_desktop,example"]="check_desktop" +["check_desktop,status"]="review" +["check_desktop,doc_link"]="" +) +# +# read desktop parameters +# +function check_desktop() { + + DISPLAY_MANAGER=""; DESKTOP_INSTALLED="" + check_if_installed nodm && DESKTOP_INSTALLED="nodm"; + check_if_installed lightdm && DESKTOP_INSTALLED="lightdm"; + check_if_installed lightdm && DESKTOP_INSTALLED="gnome"; + [[ -n $(service lightdm status 2> /dev/null | grep -w active) ]] && DISPLAY_MANAGER="lightdm" + [[ -n $(service nodm status 2> /dev/null | grep -w active) ]] && DISPLAY_MANAGER="nodm" + [[ -n $(service gdm status 2> /dev/null | grep -w active) ]] && DISPLAY_MANAGER="gdm" + +} + + + +menu_options+=( +["get_headers_kernel,author"]="Igor Pecovnik" +["get_headers_kernel,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L39" +["get_headers_kernel,feature"]="get_headers_kernel" +["get_headers_kernel,desc"]="Migrated procedures from Armbian config." +["get_headers_kernel,example"]="get_headers_kernel" +["get_headers_kernel,status"]="review" +["get_headers_kernel,doc_link"]="" +) +# +# install kernel headers +# +function get_headers_install() { + + if [[ -f /etc/armbian-release ]]; then + INSTALL_PKG="linux-headers-${BRANCH}-${LINUXFAMILY}"; + else + INSTALL_PKG="linux-headers-$(uname -r | sed 's/'-$(dpkg --print-architecture)'//')"; + fi + + debconf-apt-progress -- apt-get -y install ${INSTALL_PKG} || exit 1 + +} + +module_options+=( +["set_header_remove,author"]="Igor Pecovnik" +["set_header_remove,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L64" +["set_header_remove,feature"]="set_header_remove" +["set_header_remove,desc"]="Migrated procedures from Armbian config." +["set_header_remove,example"]="set_header_remove" +["set_header_remove,doc_link"]="" +["set_header_remove,status"]="review" +["set_header_remove,doc_ink"]="" +) +# +# remove kernel headers +# +function set_header_remove() { + + REMOVE_PKG="linux-headers-*" + if [[ -n $(dpkg -l | grep linux-headers) ]]; then + debconf-apt-progress -- apt-get -y purge ${REMOVE_PKG} + rm -rf /usr/src/linux-headers* + else + debconf-apt-progress -- apt-get -y install ${INSTALL_PKG} + fi + # cleanup + apt clean + debconf-apt-progress -- apt -y autoremove + +} + + +module_options+=( +["check_if_installed,author"]="Igor Pecovnik" +["check_if_installed,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L88" +["check_if_installed,feature"]="check_if_installed" +["check_if_installed,desc"]="Migrated procedures from Armbian config." +["check_if_installed,example"]="check_if_installed nano" +["check_if_installed,status"]="review" +) +# +# check dpkg status of $1 -- currently only 'not installed at all' case caught +# +function check_if_installed (){ + + local DPKG_Status="$(dpkg -s "$1" 2>/dev/null | awk -F": " '/^Status/ {print $2}')" + if [[ "X${DPKG_Status}" = "X" || "${DPKG_Status}" = *deinstall* ]]; then + return 1 + else + return 0 + fi + +} + + +module_options+=( +["is_package_manager_running,author"]="Igor Pecovnik" +["is_package_manager_running,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L111" +["is_package_manager_running,feature"]="is_package_manager_running" +["is_package_manager_running,desc"]="Migrated procedures from Armbian config." +["is_package_manager_running,example"]="is_package_manager_running" +["is_package_manager_running,status"]="review" +) +# +# check if package manager is doing something +# +function is_package_manager_running() { + + if ps -C apt-get,apt,dpkg >/dev/null ; then + [[ -z $scripted ]] && echo -e "\nPackage manager is running in the background. \n\nCan't install dependencies. Try again later." | show_infobox + return 0 + else + return 1 + fi + +} + + +module_options+=( +["set_runtime_variables,author"]="Igor Pecovnik" +["set_runtime_variables,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L136" +["set_runtime_variables,feature"]="set_runtime_variables" +["set_runtime_variables,desc"]="Run time varibales Migrated procedures from Armbian config." +["set_runtime_variables,example"]="set_runtime_variables" +["set_runtime_variables,status"]="review" +) +# +# gather info about the board and start with loading menu variables +# +function set_runtime_variables(){ + + [[ -z "$DIALOG" ]] && echo "Please install whiptail" && exit 1 ; + + DIALOG_CANCEL=1 + DIALOG_ESC=255 + + # we have our own lsb_release which does not use Python. Others shell install it here + if [[ ! -f /usr/bin/lsb_release ]]; then + if is_package_manager_running; then + sleep 3 + fi + debconf-apt-progress -- apt-get update + debconf-apt-progress -- apt -y -qq --allow-downgrades --no-install-recommends install lsb-release + fi + + + + [[ -f /etc/armbian-release ]] && source /etc/armbian-release && ARMBIAN="Armbian $VERSION $IMAGE_TYPE"; + DISTRO=$(lsb_release -is) + DISTROID=$(lsb_release -sc) + KERNELID=$(uname -r) + [[ -z "${ARMBIAN// }" ]] && ARMBIAN="$DISTRO $DISTROID" + DEFAULT_ADAPTER=$(ip -4 route ls | grep default | tail -1 | grep -Po '(?<=dev )(\S+)') + LOCALIPADD=$(ip -4 addr show dev $DEFAULT_ADAPTER | awk '/inet/ {print $2}' | cut -d'/' -f1) + BACKTITLE="Configuration utility, $ARMBIAN" + [[ -n "$LOCALIPADD" ]] && BACKTITLE=$BACKTITLE", "$LOCALIPADD + TITLE="$BOARD_NAME " + [[ -z "${DEFAULT_ADAPTER// }" ]] && DEFAULT_ADAPTER="lo" + OVERLAYDIR="/boot/dtb/overlay"; + [[ "$LINUXFAMILY" == "sunxi64" ]] && OVERLAYDIR="/boot/dtb/allwinner/overlay"; + [[ "$LINUXFAMILY" == "meson64" ]] && OVERLAYDIR="/boot/dtb/amlogic/overlay"; + [[ "$LINUXFAMILY" == "rockchip64" || "$LINUXFAMILY" == "rk3399" || "$LINUXFAMILY" == "rockchip-rk3588" || "$LINUXFAMILY" == "rk35xx" ]] && OVERLAYDIR="/boot/dtb/rockchip/overlay"; + # detect desktop + check_desktop + +} + + +module_options+=( +["set_safe_boot,author"]="Igor Pecovnik" +["set_safe_boot,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L188" +["set_safe_boot,feature"]="set_safe_boot" +["set_safe_boot,desc"]="Freeze/unhold Migrated procedures from Armbian config." +["set_safe_boot,example"]="set_safe_boot unhold or set_safe_boot freeze" +["set_safe_boot,status"]="review" +) +# +# freeze/unhold packages +# +set_safe_boot() { + + check_if_installed linux-u-boot-${BOARD}-${BRANCH} && PACKAGE_LIST+=" linux-u-boot-${BOARD}-${BRANCH}" + check_if_installed linux-image-${BRANCH}-${LINUXFAMILY} && PACKAGE_LIST+=" linux-image-${BRANCH}-${LINUXFAMILY}" + check_if_installed linux-dtb-${BRANCH}-${LINUXFAMILY} && PACKAGE_LIST+=" linux-dtb-${BRANCH}-${LINUXFAMILY}" + check_if_installed linux-headers-${BRANCH}-${LINUXFAMILY} && PACKAGE_LIST+=" linux-headers-${BRANCH}-${LINUXFAMILY}" + + # new BSP + check_if_installed armbian-${LINUXFAMILY} && PACKAGE_LIST+=" armbian-${LINUXFAMILY}" + check_if_installed armbian-${BOARD} && PACKAGE_LIST+=" armbian-${BOARD}" + check_if_installed armbian-${DISTROID} && PACKAGE_LIST+=" armbian-${DISTROID}" + check_if_installed armbian-bsp-cli-${BOARD} && PACKAGE_LIST+=" armbian-bsp-cli-${BOARD}" + check_if_installed armbian-${DISTROID}-desktop-xfce && PACKAGE_LIST+=" armbian-${DISTROID}-desktop-xfce" + check_if_installed armbian-firmware && PACKAGE_LIST+=" armbian-firmware" + check_if_installed armbian-firmware-full && PACKAGE_LIST+=" armbian-firmware-full" + IFS=" " + [[ "$1" == "unhold" ]] && local command="apt-mark unhold" && for word in $PACKAGE_LIST; do $command $word; done | show_infobox + + [[ "$1" == "freeze" ]] && local command="apt-mark hold" && for word in $PACKAGE_LIST; do $command $word; done | show_infobox + +} + + + +module_options+=( +["connect_bt_interface,author"]="Igor Pecovnik" +["connect_bt_interface,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L221" +["connect_bt_interface,feature"]="connect_bt_interface" +["connect_bt_interface,desc"]="Migrated procedures from Armbian config." +["connect_bt_interface,example"]="connect_bt_interface" +["connect_bt_interface,status"]="review" +) +# +# connect to bluetooth device +# +function connect_bt_interface(){ + + IFS=$'\r\n' + GLOBIGNORE='*' + show_infobox <<< "\nDiscovering Bluetooth devices ... " + BT_INTERFACES=($(hcitool scan | sed '1d')) + + local LIST=() + for i in "${BT_INTERFACES[@]}" + do + local a=$(echo ${i[0]//[[:blank:]]/} | sed -e 's/^\(.\{17\}\).*/\1/') + local b=${i[0]//$a/} + local b=$(echo $b | sed -e 's/^[ \t]*//') + LIST+=( "$a" "$b") + done + + LIST_LENGTH=$((${#LIST[@]}/2)); + if [ "$LIST_LENGTH" -eq 0 ]; then + BT_ADAPTER=${WLAN_INTERFACES[0]} + show_message <<< "\nNo nearby Bluetooth devices were found!" + else + exec 3>&1 + BT_ADAPTER=$(whiptail --title "Select interface" \ + --clear --menu "" $((6+${LIST_LENGTH})) 50 $LIST_LENGTH "${LIST[@]}" 2>&1 1>&3) + exec 3>&- + if [[ $BT_ADAPTER != "" ]]; then + show_infobox <<< "\nConnecting to $BT_ADAPTER " + BT_EXEC=$( + expect -c 'set prompt "#";set address '$BT_ADAPTER';spawn bluetoothctl;expect -re $prompt;send "disconnect $address\r"; + sleep 1;send "remove $address\r";sleep 1;expect -re $prompt;send "scan on\r";sleep 8;send "scan off\r"; + expect "Controller";send "trust $address\r";sleep 2;send "pair $address\r";sleep 2;send "connect $address\r"; + send_user "\nShould be paired now.\r";sleep 2;send "quit\r";expect eof') + echo "$BT_EXEC" > /tmp/bt-connect-debug.log + if [[ $(echo "$BT_EXEC" | grep "Connection successful" ) != "" ]]; then + show_message <<< "\nYour device is ready to use!" + else + show_message <<< "\nError connecting. Try again!" + fi + fi + fi + +} + + +# Start of config ng + +module_options+=( +["set_colors,author"]="Joey Turner" +["set_colors,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L287" +["set_colors,feature"]="set_colors" +["set_colors,desc"]="Change the background color of the terminal or dialoge box" +["set_colors,example"]="set_colors 0-7" +["set_colors,doc_link"]="" +["set_colors,status"]="review" +) +# +# Function to set the tui colors +# +[[ -x "$(command -v whiptail)" ]] && DIALOG="whiptail" || exit 1 ; + +function set_colors() { + local color_code=$1 + + if [ "$DIALOG" = "whiptail" ]; then + set_newt_colors "$color_code" + #echo "color code: $color_code" | show_infobox ; + elif [ "$DIALOG" = "dialog" ]; then + set_term_colors "$color_code" + else + echo "Invalid dialog type" + return 1 + fi +} + + +# +# Function to set the colors for newt +# +function set_newt_colors() { + local color_code=$1 + case $color_code in + 0) color="black" ;; + 1) color="red" ;; + 2) color="green" ;; + 3) color="yellow" ;; + 4) color="blue" ;; + 5) color="magenta" ;; + 6) color="cyan" ;; + 7) color="white" ;; + 8) color="black" ;; + 9) color="red" ;; + *) return ;; + esac + export NEWT_COLORS="root=,$color" +} + + +# +# Function to set the colors for terminal +# +function set_term_colors() { + local color_code=$1 + case $color_code in + 0) color="\e[40m" ;; # black + 1) color="\e[41m" ;; # red + 2) color="\e[42m" ;; # green + 3) color="\e[43m" ;; # yellow + 4) color="\e[44m" ;; # blue + 5) color="\e[45m" ;; # magenta + 6) color="\e[46m" ;; # cyan + 7) color="\e[47m" ;; # white + *) echo "Invalid color code"; return 1 ;; + esac + echo -e "$color" +} + + +# +# Function to reset the colors +# +function reset_colors() { + echo -e "\e[0m" +} + + +module_options+=( +["generate_top_menu,author"]="Joey Turner" +["generate_top_menu,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L370" +["generate_top_menu,feature"]="generate_top_menu" +["generate_top_menu,desc"]="Build the main menu from a object" +["generate_top_menu,example"]="generate_top_menu 'json_data'" +["generate_top_menu,doc_link"]="" +["generate_top_menu,status"]="review" +) +# +# Function to generate the main menu from a JSON object +# +generate_top_menu() { + local json_data=$1 + local menu_options=() + while IFS= read -r id + do + IFS= read -r description + IFS= read -r requirements + # If the condition field is not empty and not null, run the function specified in the condition + if [[ -n $requirements && $requirements != "null" ]]; then + local condition_result=$(eval $requirements) + # If the function returns a truthy value, add the menu item to the menu + if [[ $condition_result ]]; then + menu_options+=("$id" " - $description ($something)") + fi + else + # If the condition field is empty or null, add the menu item to the menu + menu_options+=("$id" " - $description ") + fi + done < <(echo "$json_data" | jq -r '.menu[] | select(.show==true) | "\(.id)\n\(.description)\n\(.condition)"' || exit 1 ) + + set_colors 4 + + local OPTION=$($DIALOG --title "$TITLE" --menu "$BACKTITLE" 0 80 9 "${menu_options[@]}" 3>&1 1>&2 2>&3) + local exitstatus=$? + + if [ $exitstatus = 0 ]; then + if [ "$OPTION" == "" ]; then + exit 0 + fi + [[ -n "$debug" ]] && echo "$OPTION" + generate_menu "$OPTION" + fi + +# echo "Menu options: ${menu_options[@]}" + +} + + +module_options+=( +["generate_menu,author"]="Joey Turner" +["generate_menu,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L416" +["generate_menu,feature"]="generate_menu" +["generate_menu,desc"]="Generate a submenu from a parent_id" +["generate_menu,example"]="generate_menu 'parent_id'" +["generate_menu,doc_link"]="" +["generate_menu,status"]="review" +) +# +# Function to generate the submenu +# +function generate_menu() { + local parent_id=$1 + + # Get the submenu options for the current parent_id + local submenu_options=() + while IFS= read -r id + do + IFS= read -r description + submenu_options+=("$id" " - $description") + done < <(jq -r --arg parent_id "$parent_id" '.menu[] | select(.id==$parent_id) | .sub[]? | select(.show==true) | "\(.id)\n\(.description)"' <<< "$json_data") + + + local OPTION=$($DIALOG --title "$TITLE" --menu "$BACKTITLE" 0 80 9 "${submenu_options[@]}" \ + --ok-button Select --cancel-button Back 3>&1 1>&2 2>&3) + + local exitstatus=$? + + if [ $exitstatus = 0 ]; then + if [ "$OPTION" == "" ]; then + generate_top_menu + fi + # Check if the selected option has a submenu + local submenu_count=$(jq -r --arg id "$OPTION" '.menu[] | .. | objects | select(.id==$id) | .sub[]? | length' "$json_file") + submenu_count=${submenu_count:-0} # If submenu_count is null or empty, set it to 0 + if [ "$submenu_count" -gt 0 ]; then + # If it does, generate a new menu for the submenu + set_colors 2 # "$?" + [[ -n "$debug" ]] && echo "$OPTION" + generate_menu "$OPTION" + else + # If it doesn't, execute the command + [[ -n "$debug" ]] && echo "$OPTION" + execute_command "$OPTION" + fi + fi + + # echo "Submenu options: ${submenu_options[@]}" + +} + + +module_options+=( +["execute_command,author"]="Joey Turner" +["execute_command,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L464" +["execute_command,feature"]="execute_command" +["execute_command,desc"]="Needed by generate_menu" +["execute_command,example"]="" +["execute_command,doc_link"]="" +["execute_command,status"]="review" +) +# +# Function to execute the command +# +function execute_command() { + local id=$1 + local commands=$(jq -r --arg id "$id" '.menu[] | .. | objects | select(.id==$id) | .command[]' "$json_file") + for command in "${commands[@]}"; do + # Check if the command is not in the list of restricted commands + [[ -n "$debug" ]] && echo "$command" + eval "$command" + done + +} + + +module_options+=( +["show_message,author"]="Joey Turner" +["show_message,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#486" +["show_message,feature"]="show_message" +["show_message,desc"]="Display a message box" +["show_message,example"]="show_message <<< 'hello world' " +["show_message,doc_link"]="https://github.com/armbian/configng/wiki/interface" +["show_message,status"]="review" +) +# +# Function to display a message box +# +function show_message() { + # Read the input from the pipe + input=$(cat) + + # Display the "OK" message box with the input data + if [[ $DIALOG != "bash" ]]; then + $DIALOG --title "$BACKTITLE" --msgbox "$input" 0 0 + else + echo -e "$input" + read -p -r "Press [Enter] to continue..." + fi +} + + +module_options+=( +["show_infobox,author"]="Joey Turner" +["show_infobox,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#512" +["show_infobox,feature"]="show_infobox" +["show_infobox,desc"]="pipe line strings to a infobox " +["show_infobox,example"]="show_infobox <<< 'hello world' ; " +["show_infobox,doc_link"]="" +["show_infobox,status"]="review" +) +# +# Function to display an infobox with a message +# +function show_infobox() { + export TERM=ansi + local input + local BACKTITLE="$BACKTITLE" + local -a buffer # Declare buffer as an array + if [ -p /dev/stdin ]; then + while IFS= read -r line; do + buffer+=("$line") # Add the line to the buffer + # If the buffer has more than 10 lines, remove the oldest line + if (( ${#buffer[@]} > 18 )); then + buffer=("${buffer[@]:1}") + fi + # Display the lines in the buffer in the infobox + + TERM=ansi $DIALOG --title "$BACKTITLE" --infobox "$(printf "%s\n" "${buffer[@]}" )" 16 90 + sleep 0.5 + done + else + + input="$1" + TERM=ansi $DIALOG --title "$BACKTITLE" --infobox "$input" 6 80 + fi + echo -ne '\033[3J' # clear the screen +} + + +module_options+=( +["show_menu,author"]="Joey Turner" +["show_menu,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L550" +["show_menu,feature"]="show_menu" +["show_menu,desc"]="Display a menu from pipe" +["show_menu,example"]="show_menu <<< armbianmonitor -h ; " +["show_menu,doc_link"]="" +["show_menu,status"]="WIP" +) +# +# +# +show_menu(){ + + # Get the input and convert it into an array of options + inpu_raw=$(cat) + # Remove the lines befor -h + input=$(echo "$inpu_raw" | sed 's/-\([a-zA-Z]\)/\1/' | grep '^ [a-zA-Z] ' | grep -v '\[') + options=() + while read -r line; do + package=$(echo "$line" | awk '{print $1}') + description=$(echo "$line" | awk '{$1=""; print $0}' | sed 's/^ *//') + options+=("$package" "$description") + done <<< "$input" + + # Display the menu and get the user's choice + [[ $DIALOG != "bash" ]] && choice=$($DIALOG --title "Menu" --menu "Choose an option:" 0 0 9 "${options[@]}" 3>&1 1>&2 2>&3) + + # Check if the user made a choice + if [ $? -eq 0 ]; then + echo "$choice" + else + exit 0 + fi + + } + + +module_options+=( +["get_user_continue,author"]="Joey Turner" +["get_user_continue,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L588" +["get_user_continue,feature"]="get_user_continue" +["get_user_continue,desc"]="Display a Yes/No dialog box and prosees continue/exit" +["get_user_continue,example"]="get_user_continue 'Do you wish to continue?' process_input" +["get_user_continue,doc_link"]="" +["get_user_continue,status"]="review" +) +# +# Function to display a Yes/No dialog box (WIP) +# +function get_user_continue() { + local message="$1" + local next_action="$2" + + if $($DIALOG --yesno "$message" 10 80 3>&1 1>&2 2>&3); then + $next_action + else + $next_action "No" + fi +} + + +menu_options+=( +["get_user_continue,author"]="Joey Turner" +["get_user_continue,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#612" +["get_user_continue,feature"]="process_input" +["get_user_continue,desc"]="used to process the user's choice paired with get_user_continue" +["get_user_continue,example"]="get_user_continue 'Do you wish to continue?' process_input" +["get_user_continue,status"]="review" +["get_user_continue,doc_link"]="" +) +# +# Function to process the user's choice paired with get_user_continue +# +function process_input() { + local input="$1" + if [ "$input" = "No" ]; then + exit 1 + fi +} + + +module_options+=( +["get_user_continue_secure,author"]="Joey Turner" +["get_user_continue_secure,ref_link"]="" +["get_user_continue_secure,feature"]="get_user_continue_secure" +["get_user_continue_secure,desc"]="Secure version of get_user_continue" +["get_user_continue_secure,example"]="get_user_continue_secure 'Do you wish to continue?' process_input" +["get_user_continue_secure,doc_link"]="" +["get_user_continue_secure,status"]="WIP" +) +# +# Secure version of get_user_continue +# +function get_user_continue_secure() { + local message="$1" + local next_action="$2" + + # Define a list of allowed functions + local allowed_functions=("process_input" "other_function") + + # Check if the next_action is in the list of allowed functions + if [[ " ${allowed_functions[@]} " =~ " ${next_action} " ]]; then + if $($DIALOG --yesno "$message" 10 80 3>&1 1>&2 2>&3); then + $next_action + else + $next_action "No" + fi + else + echo "Error: Invalid function" + + exit 1 + fi +} + + + +module_options+=( +["see_ping,author"]="Joey Turner" +["see_ping,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#632" +["see_ping,feature"]="see_ping" +["see_ping,desc"]="Check the internet connection with fallback DNS" +["see_ping,example"]="see_ping" +["see_ping,doc_link"]="" +["see_ping,status"]="review" +) +# +# Function to check the internet connection +# +function see_ping() { + # List of servers to ping + servers=("1.1.1.1" "8.8.8.8") + + # Check for internet connection + for server in "${servers[@]}"; do + if ping -q -c 1 -W 1 $server >/dev/null; then + echo "Internet connection: Present" + break + else + echo "Internet connection: Failed" + sleep 1 + fi + done + + if [[ $? -ne 0 ]]; then + read -n -r 1 -s -p "Warning: Configuration cannot work properly without a working internet connection. \ + Press CTRL C to stop or any key to ignore and continue." + fi + +} + + +module_options+=( +["see_current_apt,author"]="Joey Turner" +["see_current_apt,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#667" +["see_current_apt,feature"]="see_current_apt" +["see_current_apt,desc"]="Check when apt list was last updated" +["see_current_apt,example"]="see_current_apt" +["see_current_apt,doc_link"]="" +["see_current_apt,status"]="review" +) +# +# Function to check when the package list was last updated +# +see_current_apt() { + # Number of seconds in a day + local day=86400 + + # Get the current date as a Unix timestamp + local now=$(date +%s) + + # Get the timestamp of the most recently updated file in /var/lib/apt/lists/ + local update=$(stat -c %Y /var/lib/apt/lists/* | sort -n | tail -1) + + # Calculate the number of seconds since the last update + local elapsed=$(( now - update )) + + if ps -C apt-get,apt,dpkg >/dev/null; then + echo "A pkg is running." + export running_pkg="true" + return 1 # The processes are running + else + export running_pkg="false" + #echo "apt, apt-get, or dpkg is not currently running" + fi + # Check if the package list is up-to-date + if (( elapsed < day )); then + #echo "Checking for apt-daily.service" + echo "$(date -u -d @${elapsed} +"%T")" + return 0 # The package lists are up-to-date + else + #echo "Checking for apt-daily.service" + echo "Update the package lists" + return 1 # The package lists are not up-to-date + fi +} diff --git a/lib/armbian-configng/config.ng.jobs.json b/lib/armbian-configng/config.ng.jobs.json new file mode 100644 index 000000000..4dc2f552f --- /dev/null +++ b/lib/armbian-configng/config.ng.jobs.json @@ -0,0 +1,295 @@ +{ + "menu": [ + { + "id": "System", + "description": "System wide and admin settings", + "show": true, + "sub": [ + { + "id": "S01", + "description": "Enable Armbina kernal upgrades", + "command": [ + "get_user_continue \"This will allow apt to update boot critical items\n\n Continue?\" process_input", + "set_safe_boot unhold" + ], + "show": true, + "status": "WIP", + "doc_link": "", + "src_reference": "", + "author": "" + }, + { + "id": "S02", + "description": "Disable Armbina kernal upgrades", + "command": [ + "get_user_continue \"This will apt hold boot critical items\n\n Continue?\" process_input", + "set_safe_boot freeze" + ], + "show": true, + "status": "WIP", + "doc_link": "", + "src_reference": "", + "author": "" + }, + { + "id": "S03", + "description": "Edit the boot enviroment (WIP)", + "command": [ + "get_user_continue \"This will open /boot/armbianEnv.txt file to edit\nCTRL+S to save\nCTLR+X to exit\nwould you like to continue?\" process_input", + "nano /boot/armbianEnv.txt" + ], + "show": true, + "status": "WIP", + "doc_link": "", + "src_reference": "", + "author": "" + } + ] + }, + { + "id": "Network", + "description": "Wireless, Ethernet, and Network settings", + "show": true, + "sub": [ + { + "id": "BT0", + "description": "Install Bluetooth support", + "command": [ + "see_current_apt ", + "debconf-apt-progress -- apt-get -y install bluetooth bluez bluez-tools", + "check_if_installed xserver-xorg && debconf-apt-progress -- apt-get -y --no-install-recommends install pulseaudio-module-bluetooth blueman" + ], + "show": false, + "status": "review", + "doc_link": "", + "src_reference": "", + "author": "" + }, + { + "id": "BT1", + "description": "Remove Bluetooth support", + "command": [ + "see_current_apt ", + "debconf-apt-progress -- apt-get -y remove bluetooth bluez bluez-tools", + "check_if_installed xserver-xorg && debconf-apt-progress -- apt-get -y remove pulseaudio-module-bluetooth blueman", + "debconf-apt-progress -- apt -y -qq autoremove" + ], + "show": false, + "status": "review", + "doc_link": "", + "src_reference": "", + "author": "" + }, + { + "id": "BT3", + "description": "Bluetooth Discover", + "command": [ + "get_user_continue \"Verify that your Bluetooth device is discoverable!\" process_input ; connect_bt_interface" + + ], + "show": false, + "status": "review", + "doc_link": "", + "src_reference": "", + "author": "" + }, + { + "id": "IR0", + "description": "Install Infrared support", + "command": [ + "see_current_apt; debconf-apt-progress -- apt-get -y --no-install-recommends install lirc" + ], + "show": false, + "status": "review", + "doc_link": "", + "src_reference": "", + "author": "" + }, + { + "id": "IR1", + "description": "Uninstall Infrared support", + "command": [ + "see_current_apt; debconf-apt-progress -- apt-get -y --no-install-recommends install lirc" + ], + "show": false, + "status": "review", + "doc_link": "", + "src_reference": "", + "author": "" + }, + { + "id": "N00", + "description": "Manage wifi network connections", + "command": [ + "nmtui connect" + ], + "show": true, + "status": "review", + "doc_link": "", + "src_reference": "", + "author": "" + }, + { + "id": "N01", + "description": "Advanced Edit /etc/network/interface", + "command": [ + "get_user_continue \"This will open interface file to edit\nCTRL+S to save\nCTLR+X to exit\nwould you like to continue?\" process_input", + "nano /etc/network/interfaces" + ], + "show": true, + "status": "review", + "doc_link": "", + "src_reference": "", + "author": "" + }, + { + "id": "N02", + "description": "Disconect and forget all wifi connections (Advanced)", + "command": [ + "get_user_continue \"Disconect and forget all wifi connections\nWould you like to contiue?\" process_input", + "LC_ALL=C nmcli --fields UUID,TIMESTAMP-REAL,TYPE con show | grep wifi | awk '{print $1}' | while read line; \\ ", + "do nmcli con delete uuid $line; done > /dev/null" + ], + "show": true, + "status": "review", + "doc_link": "", + "src_reference": "", + "author": "" + }, + { + "id": "N03", + "description": "Toggle system IPv6/IPv4 internet protical", + "command": [ + "get_user_continue \"This will toggle your internet protical\nWould you like to contiue?\" process_input", + "toggle_ipv6 | show_infobox" + ], + "show": true, + "status": "review", + "doc_link": "", + "src_reference": "", + "author": "" + } + ] + }, + { + "id": "Localisation", + "description": "Localisation", + "show": true, + "sub": [ + { + "id": "L00", + "description": "Change Globla timezone (WIP)", + "command": [ + "dpkg-reconfigure tzdata" + ], + "show": true, + "status": "review", + "doc_link": "", + "src_reference": "", + "author": "" + }, + { + "id": "L01", + "description": "Change Locales reconfigure the language and charitorset", + "command": [ + "dpkg-reconfigure locales", + "source /etc/default/locale ; sed -i \"s/^LANGUAGE=.*/LANGUAGE=$LANG/\" /etc/default/locale", + "export LANGUAGE=$LANG" + ], + "show": true, + "status": "review", + "doc_link": "", + "src_reference": "", + "author": "" + }, + { + "id": "L02", + "description": "Change Keyboard layout", + "command": [ + "dpkg-reconfigure keyboard-configuration ; setupcon " + ], + "show": true, + "status": "review", + "doc_link": "", + "src_reference": "", + "author": "" + }, + { + "id": "L03", + "description": "Change APT mirrors", + "command": [ + "get_user_continue \"This is only a frontend test\" process_input" + ], + "show": false, + "status": "review", + "doc_link": "", + "src_reference": "", + "author": "" + } + ] + }, + { + "id": "Software", + "description": "Run/Install 3rd party apllications", + "show": true, + "sub": [ + { + "id": "I00", + "description": "Update Application Repository", + "command": [ + "get_user_continue \"This will update apt\" process_input", + "debconf-apt-progress -- apt update" + ], + "show": true, + "status": "review", + "doc_link": "", + "src_reference": "", + "author": "" + }, + { + "id": "I01", + "description": "CLI System Monitor", + "command": [ + "armbianmonitor -m | show_infobox" + ], + "show": true, + "status": "review", + "doc_link": "", + "src_reference": "", + "author": "" + } + ] + }, + { + "id": "Help", + "description": "About this app", + "show": true, + "sub": [ + { + "id": "H00", + "description": "About This systme. (WIP)", + "command": [ + "show_message <<< \"This app is to help exicute prosedures to configure your system\n\nSome option may not work on manualy modified sytemes\"" + ], + "show": true, + "status": "review", + "doc_link": "", + "src_reference": "", + "author": "" + }, + { + "id": "H02", + "description": "List of Config function(WIP)", + "command": [ + "show_message <<< see_use" + ], + "show": false, + "status": "review", + "doc_link": "", + "src_reference": "", + "author": "" + } + ] + } + ] +} \ No newline at end of file diff --git a/lib/armbian-configng/config.ng.network.sh b/lib/armbian-configng/config.ng.network.sh new file mode 100644 index 000000000..27b0d2a43 --- /dev/null +++ b/lib/armbian-configng/config.ng.network.sh @@ -0,0 +1,108 @@ +#!/bin/bash + +module_options+=( +["check_ip_version,author"]="Joey Turner" +["check_ip_version,ref_link"]="" +["check_ip_version,feature"]="check_ip_version" +["check_ip_version,desc"]="Check if a domain is reachable via IPv4 and IPv6" +["check_ip_version,example"]="check_ip_version google.com" +["check_ip_version,status"]="review" +["check_ip_version,doc_link"]="" +) +# +# +# +check_ip_version() { + domain=${1:-armbian.com} + + if ping -c 1 $domain > /dev/null 2>&1; then + echo "IPv4" + elif ping6 -c 1 $domain > /dev/null 2>&1; then + echo "IPv6" + else + echo "Unreachable" + fi +} + + + +module_options+=( +["toggle_ipv6,author"]="Joey Turner" +["toggle_ipv6,ref_link"]="" +["toggle_ipv6,feature"]="toggle_ipv6" +["toggle_ipv6,desc"]="Toggle IPv6 on or off" +["toggle_ipv6,example"]="toggle_ipv6" +["toggle_ipv6,status"]="review" +["toggle_ipv6,doc_link"]="" +) +# +# Function to toggle IPv6 on or off +# +toggle_ipv6() { + # Check if IPv6 is currently enabled + if sysctl net.ipv6.conf.all.disable_ipv6 | grep -q 0; then + # If IPv6 is enabled, disable it + echo "Disabling IPv6..." + sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1 + sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1 + sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1 + echo "IPv6 is now disabled." + # Confirm that IPv6 is disabled + if sysctl net.ipv6.conf.all.disable_ipv6 | grep -q 1; then + check_ip_version google.com + else + check_ip_version google.com + fi + else + # If IPv6 is disabled, enable it + echo "Enabling IPv6..." + sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0 + sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0 + sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=0 + echo "IPv6 is now enabled." + # Confirm that IPv6 is enabled + if sysctl net.ipv6.conf.all.disable_ipv6 | grep -q 0; then + check_ip_version google.com + else + check_ip_version google.com + fi + fi + + # Now call the function with a domain name + +} + +module_options+=( +["see_ping,author"]="Joey Turner" +["see_ping,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#632" +["see_ping,feature"]="see_ping" +["see_ping,desc"]="Check the internet connection with fallback DNS" +["see_ping,example"]="see_ping" +["see_ping,doc_link"]="" +["see_ping,status"]="review" +) +# +# Function to check the internet connection +# +function see_ping() { + # List of servers to ping + servers=("1.1.1.1" "8.8.8.8") + + # Check for internet connection + for server in "${servers[@]}"; do + if ping -q -c 1 -W 1 $server >/dev/null; then + echo "Internet connection: Present" + break + else + echo "Internet connection: Failed" + sleep 1 + fi + done + + if [[ $? -ne 0 ]]; then + read -n -r 1 -s -p "Warning: Configuration cannot work properly without a working internet connection. \ + Press CTRL C to stop or any key to ignore and continue." + fi + +} + diff --git a/lib/armbian-configng/config.ng.runtime.dev.sh b/lib/armbian-configng/config.ng.runtime.dev.sh new file mode 100644 index 000000000..4d840240e --- /dev/null +++ b/lib/armbian-configng/config.ng.runtime.dev.sh @@ -0,0 +1,45 @@ +#!/bin/bash + + +if [[ "$1" == "dev" || "$1" == "--dev" ]]; then + shift + get_user_continue "Development Mode:\n\nYou are entering development mode. System Administration features will be unavailable. Do you wish to continue?" process_input + json_data=$(echo "$json_data" | jq '(.menu[] | select(.id=="Development") .show) |= true') + + # sets backgrount to black + set_colors 0 + + # Append Items to main menu descriptions + json_data=$(echo "$json_data" | jq --arg str "$localisation" '(.menu[] | select(.id == "Personalisation" ) .description) += " (" + $str + ")"') + json_data=$(echo "$json_data" | jq --arg str "$install" '(.menu[] | select(.id == "Downloads" ) .description) += " (" + $str + ")"') + + + # Append Items to Sub menu descriptions + json_data=$(echo "$json_data" | jq --arg str "$network" '(.menu[] | select(.id=="Development").sub[] | select(.id == "T2").description) += " (" + $str + ")"') + json_data=$(echo "$json_data" | jq --arg str "$install" '(.menu[] | select(.id=="Development").sub[] | select(.id == "T1").description) += " (" + $str + ")"') + json_data=$(echo "$json_data" | jq --arg str "$install" '(.menu[] | select(.id=="Downloads").sub[] | select(.id == "I0").description) += " (" + $str + ")"') + + + # hide sys admin items from user menu + json_data=$(echo "$json_data" | jq '(.menu[] | select(.id=="System") .show) |= false') ; + json_data=$(echo "$json_data" | jq '(.menu[] | select(.id=="Localisation") .show) |= false') ; + json_data=$(echo "$json_data" | jq '(.menu[] | select(.id=="Network") .show) |= false') ; + json_data=$(echo "$json_data" | jq '(.menu[] | select(.id=="Software") .show) |= false') ; + + + # show menu user level menu items + json_data=$(echo "$json_data" | jq '(.menu[] | select(.id=="Personalisation") .show) |= true') ; + json_data=$(echo "$json_data" | jq '(.menu[] | select(.id=="Help") .show) |= true') ; + json_data=$(echo "$json_data" | jq '(.menu[] | select(.id=="Downloads") .show) |= true') ; + +elif [[ "$1" == "--docs" ]]; then + generate_readme + exit 0 +elif [[ "$1" == "--help" ]]; then + see_use + exit 0 +else + # exit admin tool + echo -e "error: Exiting \nTry: 'sudo armbian-config'\n or: 'armbian-config --help' for More info\n\n" + exit 0 +fi diff --git a/lib/armbian-configng/config.ng.runtime.sh b/lib/armbian-configng/config.ng.runtime.sh new file mode 100644 index 000000000..6e334f081 --- /dev/null +++ b/lib/armbian-configng/config.ng.runtime.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# This script is used to dynamically modify a JSON structure that represents a menu in the Armbian configuration tool. +# It performs several checks, such as checking if certain packages are installed and determining the network protocol used. +# Based on these checks, it appends information to the descriptions of menu and submenu items, and shows or hides certain submenu items. +# The modified JSON structure is stored in the variable 'json_data'. + +set_colors 2 # Set the color to green + +# Main menu items +system="$(uname -m)" +network="$(echo "$DEFAULT_ADAPTER")" +localisation="$LANG" +software="$(see_current_apt)" + + +# Sub menu items +bluetooth_installed=$(dpkg -s bluetooth &> /dev/null && echo true || echo false) +bluez_installed=$(dpkg -s bluez &> /dev/null && echo true || echo false) +bluez_tools_installed=$(dpkg -s bluez-tools &> /dev/null && echo true || echo false) +#check_hold=$(apt-mark showhold) + +# Append Items to menu descriptions +json_data=$(echo "$json_data" | jq --arg str "$system" '(.menu[] | select(.id == "System" ) .description) += " (" + $str + ")"') +json_data=$(echo "$json_data" | jq --arg str "$network" '(.menu[] | select(.id == "Network" ) .description) += " (" + $str + ")"') +json_data=$(echo "$json_data" | jq --arg str "$localisation" '(.menu[] | select(.id == "Localisation" ) .description) += " (" + $str + ")"') +json_data=$(echo "$json_data" | jq --arg str "$software" '(.menu[] | select(.id == "Software" ) .description) += " (" + $str + ")"') + +# +# Append Items to Sub menu descriptions +json_data=$(echo "$json_data" | jq --arg str "$network" '(.menu[] | select(.id=="Testing").sub[] | select(.id == "T2").description) += " (" + $str + ")"') +json_data=$(echo "$json_data" | jq --arg str "$software" '(.menu[] | select(.id=="Testing").sub[] | select(.id == "T1").description) += " (" + $str + ")"') +json_data=$(echo "$json_data" | jq --arg str "$software" '(.menu[] | select(.id=="Install").sub[] | select(.id == "I0").description) += " (" + $str + ")"') + +# Show or hide Sub menu items dynamicly + +if [ "$network" = "IPv6" ]; then + # If IPv6 is being used, do something + json_data=$(echo "$json_data" | jq --arg str "IPV6" '(.menu[] | select(.id=="Network").sub[] | select(.id == "N03").description) += " (" + $str + ")"') +else + # If IPv4 is being used or the domain is unreachable, do something else + json_data=$(echo "$json_data" | jq --arg str "IPV4" '(.menu[] | select(.id=="Network").sub[] | select(.id == "N03").description) += " (" + $str + ")"') +fi + +if [ "$bluetooth_installed" = false ] || [ "$bluez_installed" = false ] || [ "$bluez_tools_installed" = false ]; then + json_data=$(echo "$json_data" | jq '(.menu[] | select(.id=="Network").sub[] | select(.id == "BT0").show) |= true') + json_data=$(echo "$json_data" | jq '(.menu[] | select(.id=="Network").sub[] | select(.id == "BT3").show) |= false') + +else + json_data=$(echo "$json_data" | jq '(.menu[] | select(.id=="Network").sub[] | select(.id == "BT1").show) |= true') + json_data=$(echo "$json_data" | jq '(.menu[] | select(.id=="Network").sub[] | select(.id == "BT3").show) |= true') +fi + +# Show or hide Sub menu items dynamicly +# + +[[ -n "$check_hold" ]] && json_data=$(echo "$json_data" | jq '(.menu[] | select(.id=="System").sub[] | select(.id == "S03").show) |= true') +[[ -z "$check_hold" ]] && json_data=$(echo "$json_data" | jq '(.menu[] | select(.id=="System").sub[] | select(.id == "S04").show) |= true') + + diff --git a/share/doc/armbian-configng/Functions.md b/share/doc/armbian-configng/Functions.md new file mode 100644 index 000000000..de99d4987 --- /dev/null +++ b/share/doc/armbian-configng/Functions.md @@ -0,0 +1,35 @@ + +# Helper functions +A list of the heper function ie bash prosedures used in Jobs file. + +| Feature | Description | Credit | Reference | Documents | Status | +|:------- | ----------- | ----------- |:---------:|:---------:|:------:| +| set_runtime_variables | Run time varibales Migrated procedures from Armbian config. | Igor Pecovnik | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L136) | X | review | +| see_function_table_md | Generate this markdown table of all module_options | Tearran | X | X | source link Needed | +| show_menu | Display a menu from pipe | Joey Turner | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L550) | X | WIP | +| generate_top_menu | Build the main menu from a object | Joey Turner | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L370) | X | review | +| is_package_manager_running | Migrated procedures from Armbian config. | Igor Pecovnik | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L111) | X | review | +| check_desktop | Migrated procedures from Armbian config. | Igor Pecovnik | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L16) | X | review | +| generate_readme | Generate Document files. | Joey Turner | [Source](https://github.com/armbian/configng/blob/main/lib/armbian-configng/documents.sh#L18) | X | review | +| execute_command | Needed by generate_menu | Joey Turner | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L464) | X | review | +| get_user_continue | Display a Yes/No dialog box and prosees continue/exit | Joey Turner | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L588) | X | review | +| show_message | Display a message box | Joey Turner | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#486) | [Document](https://github.com/armbian/configng/wiki/interface) | Review | +| connect_bt_interface | Migrated procedures from Armbian config. | Igor Pecovnik | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L221) | X | review | +| set_safe_boot | Freeze/unhold Migrated procedures from Armbian config. | Igor Pecovnik | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L188) | X | review | +| see_current_apt | Check when apt list was last updated | Joey Turner | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#667) | X | review | +| check_if_installed | Migrated procedures from Armbian config. | Igor Pecovnik | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L88) | X | review | +| generate_svg | Generate 'Armbian CPU logo' SVG for docunment file. | Tearran | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#201) | X | review | +| check_ip_version | Check if a domain is reachable via IPv4 and IPv6 | Joey Turner | X | X | source link Needed | +| set_header_remove | Migrated procedures from Armbian config. | Igor Pecovnik | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L64) | X | review | +| generate_menu | Generate a submenu from a parent_id | Joey Turner | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L416) | X | review | +| see_jq_menu_list | Generate a markdown list json objects using jq. | Tearran | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L304) | X | review | +| generate_jobs_from_json | Generate jobs from JSON file. | Tearran | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L223) | X | review | +| toggle_ipv6 | Toggle IPv6 on or off | Joey Turner | X | X | source link Needed | +| generate_json | Generate JSON-like object file. | Tearran | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L149) | X | review | +| set_colors | Change the background color of the terminal or dialoge box | Joey Turner | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L287) | X | review | +| serve_doc | Serve the edit and debug server. | Tearran | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L89) | X | review | +| show_infobox | pipe line strings to a infobox | Joey Turner | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#512) | X | review | +| see_use | Show the usage of the functions. | Tearran | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L126) | X | review | +| see_ping | Check the internet connection with fallback DNS | Joey Turner | [Source](https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#632) | X | review | +| get_user_continue_secure | Secure version of get_user_continue | Joey Turner | X | X | source link Needed | + diff --git a/share/doc/armbian-configng/Home.md b/share/doc/armbian-configng/Home.md new file mode 100644 index 000000000..413391cff --- /dev/null +++ b/share/doc/armbian-configng/Home.md @@ -0,0 +1,100 @@ + +# Armbian configuration utility +Utility for configuring your board, divided into four main sections: + +- System - system and security settings, +- Network - wired, wireless, Bluetooth, access point, +- Personal - timezone, language, hostname, +- Software - system and 3rd party software install. + + + +To Configure and change global sytem settings, run the following command: `./armbian-configng` + +*** +## Screenshots +![edit-boot-env-2024-04-03 10-06-58](https://github.com/armbian/configng/assets/2831630/448f0515-0854-4a8a-8421-53c8b72bb5c5) +![BT-connect-2024-04-03 10-06-58](https://github.com/armbian/configng/assets/2831630/fef037ce-346d-4d70-9025-90f69fbdf5d3) +Following was updated on: +Fri Apr 12 01:33:08 AM MST 2024. + +*** +- ## **System** + - **S01** - Description: Enable Armbina kernal upgrades + - Status: [WIP](https://github.com/armbian/configng/wiki/Menu#s01) + - **S02** - Description: Disable Armbina kernal upgrades + - Status: [WIP](https://github.com/armbian/configng/wiki/Menu#s02) + - **S03** - Description: Edit the boot enviroment (WIP) + - Status: [WIP](https://github.com/armbian/configng/wiki/Menu#s03) + + +- ## **Network** + - **BT0** - Description: Install Bluetooth support + - Status: [review](https://github.com/armbian/configng/wiki/Menu#bt0) + - **BT1** - Description: Remove Bluetooth support + - Status: [review](https://github.com/armbian/configng/wiki/Menu#bt1) + - **BT3** - Description: Bluetooth Discover + - Status: [review](https://github.com/armbian/configng/wiki/Menu#bt3) + - **IR0** - Description: Install Infrared support + - Status: [review](https://github.com/armbian/configng/wiki/Menu#ir0) + - **IR1** - Description: Uninstall Infrared support + - Status: [review](https://github.com/armbian/configng/wiki/Menu#ir1) + - **N00** - Description: Manage wifi network connections + - Status: [review](https://github.com/armbian/configng/wiki/Menu#n00) + - **N01** - Description: Advanced Edit /etc/network/interface + - Status: [review](https://github.com/armbian/configng/wiki/Menu#n01) + - **N02** - Description: Disconect and forget all wifi connections (Advanced) + - Status: [review](https://github.com/armbian/configng/wiki/Menu#n02) + - **N03** - Description: Toggle system IPv6/IPv4 internet protical + - Status: [review](https://github.com/armbian/configng/wiki/Menu#n03) + + +- ## **Localisation** + - **L00** - Description: Change Globla timezone (WIP) + - Status: [review](https://github.com/armbian/configng/wiki/Menu#l00) + - **L01** - Description: Change Locales reconfigure the language and charitorset + - Status: [review](https://github.com/armbian/configng/wiki/Menu#l01) + - **L02** - Description: Change Keyboard layout + - Status: [review](https://github.com/armbian/configng/wiki/Menu#l02) + - **L03** - Description: Change APT mirrors + - Status: [review](https://github.com/armbian/configng/wiki/Menu#l03) + + +- ## **Software** + - **I00** - Description: Update Application Repository + - Status: [review](https://github.com/armbian/configng/wiki/Menu#i00) + - **I01** - Description: CLI System Monitor + - Status: [review](https://github.com/armbian/configng/wiki/Menu#i01) + + +- ## **Help** + - **H00** - Description: About This systme. (WIP) + - Status: [review](https://github.com/armbian/configng/wiki/Menu#h00) + - **H02** - Description: List of Config function(WIP) + - Status: [review](https://github.com/armbian/configng/wiki/Menu#h02) + + +*** +## Quick start +Run the following commands: + + echo "deb [signed-by=/usr/share/keyrings/armbian.gpg] https://armbian.github.io/configng stable main" | sudo tee /etc/apt/sources.list.d/armbian-development.list > /dev/null + + armbian-configng --dev + +If all goes well you should see the Text-Based User Inerface (TUI) + +## Development +Development test brances are available for testing. To clone the development branch, run the following commands: + +~~~ +git clone https://github.com/armbian/configng.git +cd configng +~~~ + + + +## Note: +> +> The Bash procedures embedded within the JSON structure are meticulously designed with a focus on clear naming conventions and the simplicity of key pairs. These procedures serve multiple purposes, including facilitating the generation of content in various formats, such as Whiptail, Markdown, json out and others. Moreover, they are utilized for evaluation and execution of commands outlined in the JSON structure. +> diff --git a/share/doc/armbian-configng/Menu.md b/share/doc/armbian-configng/Menu.md new file mode 100644 index 000000000..8e67088d4 --- /dev/null +++ b/share/doc/armbian-configng/Menu.md @@ -0,0 +1,233 @@ + +# Armbian-config Menu list. +armbian-config jobs list. + +### S01 + +Enable Armbina kernal upgrades + +Jobs: + +~~~ +get_user_continue "This will allow apt to update boot critical items + + Continue?" process_input +set_safe_boot unhold +~~~ + +### S02 + +Disable Armbina kernal upgrades + +Jobs: + +~~~ +get_user_continue "This will apt hold boot critical items + + Continue?" process_input +set_safe_boot freeze +~~~ + +### S03 + +Edit the boot enviroment (WIP) + +Jobs: + +~~~ +get_user_continue "This will open /boot/armbianEnv.txt file to edit +CTRL+S to save +CTLR+X to exit +would you like to continue?" process_input +nano /boot/armbianEnv.txt +~~~ + +### BT0 + +Install Bluetooth support + +Jobs: + +~~~ +see_current_apt +debconf-apt-progress -- apt-get -y install bluetooth bluez bluez-tools +check_if_installed xserver-xorg && debconf-apt-progress -- apt-get -y --no-install-recommends install pulseaudio-module-bluetooth blueman +~~~ + +### BT1 + +Remove Bluetooth support + +Jobs: + +~~~ +see_current_apt +debconf-apt-progress -- apt-get -y remove bluetooth bluez bluez-tools +check_if_installed xserver-xorg && debconf-apt-progress -- apt-get -y remove pulseaudio-module-bluetooth blueman +debconf-apt-progress -- apt -y -qq autoremove +~~~ + +### BT3 + +Bluetooth Discover + +Jobs: + +~~~ +get_user_continue "Verify that your Bluetooth device is discoverable!" process_input ; connect_bt_interface +~~~ + +### IR0 + +Install Infrared support + +Jobs: + +~~~ +see_current_apt; debconf-apt-progress -- apt-get -y --no-install-recommends install lirc +~~~ + +### IR1 + +Uninstall Infrared support + +Jobs: + +~~~ +see_current_apt; debconf-apt-progress -- apt-get -y --no-install-recommends install lirc +~~~ + +### N00 + +Manage wifi network connections + +Jobs: + +~~~ +nmtui connect +~~~ + +### N01 + +Advanced Edit /etc/network/interface + +Jobs: + +~~~ +get_user_continue "This will open interface file to edit +CTRL+S to save +CTLR+X to exit +would you like to continue?" process_input +nano /etc/network/interfaces +~~~ + +### N02 + +Disconect and forget all wifi connections (Advanced) + +Jobs: + +~~~ +get_user_continue "Disconect and forget all wifi connections +Would you like to contiue?" process_input +LC_ALL=C nmcli --fields UUID,TIMESTAMP-REAL,TYPE con show | grep wifi | awk '{print $1}' | while read line; \ +do nmcli con delete uuid $line; done > /dev/null +~~~ + +### N03 + +Toggle system IPv6/IPv4 internet protical + +Jobs: + +~~~ +get_user_continue "This will toggle your internet protical +Would you like to contiue?" process_input +toggle_ipv6 | show_infobox +~~~ + +### L00 + +Change Globla timezone (WIP) + +Jobs: + +~~~ +dpkg-reconfigure tzdata +~~~ + +### L01 + +Change Locales reconfigure the language and charitorset + +Jobs: + +~~~ +dpkg-reconfigure locales +source /etc/default/locale ; sed -i "s/^LANGUAGE=.*/LANGUAGE=$LANG/" /etc/default/locale +export LANGUAGE=$LANG +~~~ + +### L02 + +Change Keyboard layout + +Jobs: + +~~~ +dpkg-reconfigure keyboard-configuration ; setupcon +~~~ + +### L03 + +Change APT mirrors + +Jobs: + +~~~ +get_user_continue "This is only a frontend test" process_input +~~~ + +### I00 + +Update Application Repository + +Jobs: + +~~~ +get_user_continue "This will update apt" process_input +debconf-apt-progress -- apt update +~~~ + +### I01 + +CLI System Monitor + +Jobs: + +~~~ +armbianmonitor -m | show_infobox +~~~ + +### H00 + +About This systme. (WIP) + +Jobs: + +~~~ +show_message <<< "This app is to help exicute prosedures to configure your system + +Some option may not work on manualy modified sytemes" +~~~ + +### H02 + +List of Config function(WIP) + +Jobs: + +~~~ +show_message <<< see_use +~~~ + diff --git a/share/doc/armbian-configng/ScreenShot.md b/share/doc/armbian-configng/ScreenShot.md new file mode 100644 index 000000000..f82a980d0 --- /dev/null +++ b/share/doc/armbian-configng/ScreenShot.md @@ -0,0 +1,17 @@ +# Wiptail +## usage +### Ok message box +image + + +the following will output the boot up time +```bash + systemd-analyze | show_message +``` +image + +### Menu selection box +```bash +apt-cache search desktop | grep -i -e "\-desktop-full " -e "\-desktop-environment " | awk -F "- " '{print $1, $2}' | show_menu +``` +(WIP) \ No newline at end of file diff --git a/share/doc/armbian-configng/Standards.md b/share/doc/armbian-configng/Standards.md new file mode 100644 index 000000000..ffe5d857b --- /dev/null +++ b/share/doc/armbian-configng/Standards.md @@ -0,0 +1,37 @@ +# Naming Convention + +## Categories +1. Network - Ethernet Wireless Bluetooth Access Point +2. Locales - Locale Language Region Time Keyboard +3. System - System and Security +4. SoftWare - Third-party applications + +# Function Naming Convention + +This project uses the following naming convention for functions: +## Admin sudo user +### main function groups system and security +- `see_`: used for retrieving or viewing values `apt-cashe grep something` `ls -h` `cat file.txt` `lsblk` +- `set_`: used for setting or updating values `echo "somevalue" > somefile.txt` +- `get_`: used for getting downloads or updates `apt-get install something` +- `rem_`: used for removing or uninstalling something `apt-get purge something` +## Non Admin non sudo +### user space, end-user Customization +- `run_`: used for running apps in the user space `/usr/bin/chromium --kiosk https://forum.armbian.com/ https://github.com/armbian/configng &` +- `mod_`: used for modifying or getting something in user space `git clone` `wget` + +Please use these prefixes consistently when naming functions in this project. + +# Help message format +## Existing Example +- `ls --help` Shows advanced flag options +- `p7zip -h` Shows simple flag options +- `git --help` Shows advanced non flag options + +## Base Example. +potentially build to any of the with previous +```bash + +``` + + diff --git a/share/doc/armbian-configng/system.gif b/share/doc/armbian-configng/system.gif new file mode 100644 index 000000000..2e839d115 Binary files /dev/null and b/share/doc/armbian-configng/system.gif differ