diff --git a/README.md b/README.md index 413391cf..c1d734c7 100644 --- a/README.md +++ b/README.md @@ -8,88 +8,147 @@ Utility for configuring your board, divided into four main sections: - 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) + - Status: [Active](https://github.com/armbian/configng/wiki/Menu#s01) - **S02** - Description: Disable Armbina kernal upgrades - - Status: [WIP](https://github.com/armbian/configng/wiki/Menu#s02) + - Status: [Active](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) + - Status: [Active](https://github.com/armbian/configng/wiki/Menu#s03) + - **S04** - Description: Install Linux headers + - Status: [Pending Review](https://github.com/armbian/config/wiki#System) + - **S05** - Description: Remove Linux headers + - Status: [Pending Review](https://github.com/armbian/config/wiki#System) - ## **Network** - **BT0** - Description: Install Bluetooth support - - Status: [review](https://github.com/armbian/configng/wiki/Menu#bt0) + - Status: [Active](https://github.com/armbian/configng/wiki/Menu#bt0) - **BT1** - Description: Remove Bluetooth support - - Status: [review](https://github.com/armbian/configng/wiki/Menu#bt1) + - Status: [Active](https://github.com/armbian/configng/wiki/Menu#bt1) - **BT3** - Description: Bluetooth Discover - - Status: [review](https://github.com/armbian/configng/wiki/Menu#bt3) + - Status: [Active](https://github.com/armbian/configng/wiki/Menu#bt3) - **IR0** - Description: Install Infrared support - - Status: [review](https://github.com/armbian/configng/wiki/Menu#ir0) + - Status: [Active](https://github.com/armbian/configng/wiki/Menu#ir0) - **IR1** - Description: Uninstall Infrared support - - Status: [review](https://github.com/armbian/configng/wiki/Menu#ir1) + - Status: [Active](https://github.com/armbian/configng/wiki/Menu#ir1) - **N00** - Description: Manage wifi network connections - - Status: [review](https://github.com/armbian/configng/wiki/Menu#n00) + - Status: [Active](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) + - Status: [Active](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) + - Status: [Active](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) + - Status: [Active](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) + - Status: [Active](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) + - Status: [Active](https://github.com/armbian/configng/wiki/Menu#l01) - **L02** - Description: Change Keyboard layout - - Status: [review](https://github.com/armbian/configng/wiki/Menu#l02) + - Status: [Active](https://github.com/armbian/configng/wiki/Menu#l02) - **L03** - Description: Change APT mirrors - - Status: [review](https://github.com/armbian/configng/wiki/Menu#l03) + - Status: [Active](https://github.com/armbian/configng/wiki/Menu#l03) - ## **Software** - **I00** - Description: Update Application Repository - - Status: [review](https://github.com/armbian/configng/wiki/Menu#i00) + - Status: [Active](https://github.com/armbian/configng/wiki/Menu#i00) - **I01** - Description: CLI System Monitor - - Status: [review](https://github.com/armbian/configng/wiki/Menu#i01) + - Status: [Active](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) + - Status: [Active](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) + - Status: [Active](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: + +To clone this development branch, run the following commands: ~~~ -git clone https://github.com/armbian/configng.git -cd configng + git clone https://github.com/armbian/configng + cd configng + ./armbian-configng --help +~~~ + +## Install latest release +dowload .deb package: + +~~~ +{ + latest_release=$(curl -s https://api.github.com/repos/armbian/configng/releases/latest) + deb_url=$(echo "$latest_release" | jq -r '.assets[] | select(.name | endswith(".deb")) | .browser_download_url') + curl -LO "$deb_url" + deb_file=$(echo "$deb_url" | awk -F"/" '{print $NF}') + sudo dpkg -i "$deb_file" + sudo dpkg --configure -a + sudo apt --fix-broken install +} +~~~ + +*** + +## CLI options +Command ine options. + +Use: +~~~ + armbian-config --help +~~~ + +Outputs: +~~~ +Usage: armbian-configng [option] [arguments] + + --help - Display this help message. + main=Help - Display Legacy Options (Backward Compatible) + + --cli S01 - Enable Armbina kernal upgrades + --cli S02 - Disable Armbina kernal upgrades + --cli S03 - Edit the boot enviroment (WIP) + --cli S04 - Install Linux headers + --cli S05 - Remove Linux headers + --cli BT0 - Install Bluetooth support + --cli BT1 - Remove Bluetooth support + --cli BT3 - Bluetooth Discover + --cli IR0 - Install Infrared support + --cli IR1 - Uninstall Infrared support + --cli N00 - Manage wifi network connections + --cli N01 - Advanced Edit /etc/network/interface + --cli N02 - Disconect and forget all wifi connections (Advanced) + --cli N03 - Toggle system IPv6/IPv4 internet protical + --cli L00 - Change Globla timezone (WIP) + --cli L01 - Change Locales reconfigure the language and charitorset + --cli L02 - Change Keyboard layout + --cli L03 - Change APT mirrors + --cli I00 - Update Application Repository + --cli I01 - CLI System Monitor +~~~ + +## Legacy options +Backward Compatible options. + +Use: + + armbian-config main=Help + +Outputs: +~~~ +Legacy Options (Backward Compatible) +Please use 'armbian-config --help' for more information. + +Usage: armbian-configng main=[arguments] selection=[options] + + armbian-configng main=System selection=Headers - Install headers: + armbian-configng main=System selection=Headers_remove - Remove headers: ~~~ diff --git a/bin/README.md b/bin/README.md deleted file mode 100644 index 413391cf..00000000 --- a/bin/README.md +++ /dev/null @@ -1,100 +0,0 @@ - -# 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 100644 new mode 100755 index c6d040f1..85208504 --- a/bin/armbian-configng +++ b/bin/armbian-configng @@ -10,13 +10,6 @@ tput init # allows CTRL c to exit trap "exit" INT TERM -if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then -# TODO : Add help message - echo -e "\nComming soon:\nsimple help meassage\n" - exit 0 ; -fi - - # Get the script directory script_dir="$(dirname "$0")" @@ -44,38 +37,103 @@ declare -A module_options # # Load configng core functions and module options array - 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 ; +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 ; +echo "Loaded Docs..." #| show_infobox ; source "$lib_dir/config.ng.network.sh" -echo "Loaded Network helpers..." | show_infobox ; - +echo "Loaded Network helpers..." #| show_infobox ; # # Loads the varibles from beta armbian-config for runtime handeling source "$lib_dir/config.ng.runtime.sh" ; -echo "Loaded Runtime conditions..." | show_infobox ; - -# -# 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 +echo "Loaded Runtime conditions..." #| show_infobox ; +clear +case "$1" in + "--dev") + if [[ $EUID != 0 ]]; then + source "$lib_dir/config.ng.runtime.dev.sh" + echo "Loaded Development Runtime conditions..." | show_infobox + fi + ;; + "--help") + see_cli_list + exit 0 + ;; + "--doc") + if [[ $EUID != 0 ]]; then + generate_readme + exit 0 + else + echo "Error: You must run this command as a normal user" + exit 1 + fi + ;; + "--cli") + shift + args=$(sanitize_input "$@") + execute_command "$args" + exit 0 + ;; + "main=help" | "main=Help") + see_cli_legacy + echo "" + exit 0 + ;; + "main="*) + cat << EOF +Legacy help commands are deprecated. May not work as expected. +Please use 'armbian-config --help' for more information. -tput clear +EOF + declare -A main_map + main_map=( + # map name to menu catagory + ["System"]="S" + ["Software"]="I" + ["Network"]="N" + ["Localisation"]="L" + ) + main_value="${1#main=}" + main_value="${main_map[$main_value]}" + + if [ -z "$main_value" ]; then + echo "Error: Invalid List $1" + exit 1 + fi + declare -A select_map + # map name to menu number + select_map=( + ["Headers"]="04" + ["Headers_install"]="04" + ["Headers_remove"]="05" + ["Firmware"]="06" + ["Nightly"]="07" + ) + select_value="${2#selection=}" + select_value="${select_map[$select_value]}" + if [ -z "$select_value" ]; then + echo "Error: Invalid Option $2" + exit 1 + fi + echo "$main_value""$select_value" + execute_command "$main_value""$select_value" + exit 0 + ;; + *) + if [[ $EUID != 0 ]]; then + echo -e "error: Exiting \nTry: 'sudo armbian-config'\n or: 'armbian-config --help' for More info\n\n" + exit 0 + fi + ;; +esac # # Generate the top menu with the modified Object data diff --git a/bin/configng-cli b/bin/configng-cli deleted file mode 100755 index 2a6c8977..00000000 --- a/bin/configng-cli +++ /dev/null @@ -1,222 +0,0 @@ -#!/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/configng-tui b/bin/configng-tui deleted file mode 100755 index 5f6e27c1..00000000 --- a/bin/configng-tui +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/bash - -# -# Copyright (c) 2023 Joseph C Turner -# All rights reserved. -# -# This script. -# demonstrates the compatibility of multiple interfaces for displaying menus or messages. -# It uses an array to set the options for all three menus (bash, whiptail, and dialog). -# The script checks if whiptail or dialog are available on the system and uses them to display the menu in a more user-friendly way. -# If neither of these programs is available, it falls back to using bash. -# while both are installed falls back to whiptail to display the menu. -# The user can override the default program by passing an argument when running the script: -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -## DIRECTORY variable to the absolute path of the script's directory -# directory="$(dirname "$(readlink -f "$0")")" -filename=$(basename "${BASH_SOURCE[0]}") - -## DIALOG variable to the absolute path of the script's directory -DIALOG="bash" -[[ -x "$(command -v dialog)" ]] && DIALOG="dialog" -[[ -x "$(command -v whiptail)" ]] && DIALOG="whiptail" - -show_help(){ - - echo -e "\nUsage: [command] | ${filename%.*} [ -h | -m | -o ]" - echo "Options:" - echo " -h, Print this help." - echo "" - echo " -o, Opens an OK message Box" - echo "" - echo " -m, Opens an Menu select Box." - echo "" - echo " -p, Opens Popup message box. " - echo "" - exit 1; - } - -show_message(){ - - # Read the input from the pipe continuously until there is no more input - input="" - while read -r line; do - input+="$line\n" - done - - # Display the "OK" message box with the input data - [[ $DIALOG != "bash" ]] && $DIALOG --title "Message Box" --msgbox "$input" 0 0 - [[ $DIALOG == "bash" ]] && echo -e "$input" - [[ $DIALOG == "bash" ]] && read -p -r "Press [Enter] to continue..." ; echo "" ; exit 1 - - } - -show_popup(){ - - - input="" - while read -r line; do - input+="$line\n" - done - - [[ $DIALOG != "bash" ]] && $DIALOG --title "Popup Box" --infobox "$input" 0 0 - [[ $DIALOG == "bash" ]] && echo -e "$input" - - } - -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 - echo "You cancelled." - fi - } - -[[ $1 == "-m" ]] && show_menu ; -[[ $1 == "-o" ]] && show_message ; -[[ $1 == "-h" ]] && show_help ; -[[ $1 == "-p" ]] && show_popup ; -[[ -z "$*" ]] && show_help ; diff --git a/lib/armbian-configng/config.ng.docs.sh b/lib/armbian-configng/config.ng.docs.sh index 791ba27e..96fa4d2c 100644 --- a/lib/armbian-configng/config.ng.docs.sh +++ b/lib/armbian-configng/config.ng.docs.sh @@ -4,7 +4,7 @@ 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,ref_link"]="https://github.com/armbian/configng/blob/main/lib/armbian-configng/config.ng.functions.sh#L17" ["generate_readme,feature"]="generate_readme" ["generate_readme,desc"]="Generate Document files." ["generate_readme,example"]="generate_readme" @@ -18,29 +18,26 @@ function generate_readme() { # Get the current date local current_date=$(date) + # setup doc folders + mkdir -p "$script_dir/../share/doc/armbian-configng" -# [[ ! -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 ; +echo -e "Sorting data\nUpdating documentation" # current_date ; ###################################### # Generate the README.md file -echo "$(see_jobs_list)" > "$script_dir/README.md" -echo "Updating Readme.md" | show_infobox +echo "$(see_full_list)" > "$script_dir/../README.md" +echo "Updating Readme.md" # current_date ###################################### -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 +cp "$script_dir/../README.md" "$doc_dir/Home.md" +echo "README.md has been updated." # current_date ###################################### -echo "Updating WIKI Functions" | show_infobox +echo "Updating WIKI Functions" # current_date cat << EOF > "$doc_dir/Functions.md" # Helper functions @@ -52,10 +49,10 @@ EOF ###################################### -echo "Updating WIKI HowTo" | show_infobox +echo "Updating WIKI HowTo" # current_date cat << EOF > "$doc_dir/Menu.md" -# Armbian-config Menu list. +# Menu list. armbian-config jobs list. $(see_jq_menu_list) @@ -64,16 +61,39 @@ 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 +echo "Updating WIKI Command line options" # current_date +cat << EOF > "$doc_dir/Command.md" +## CLI options +Command ine options. + +Use: + + armbian-config --help + +Outputs: +~~~ +$(see_cli_list) +~~~ + +## Legacy options +deprecated + +Use: + + armbian-config main=Help + +Outputs: +~~~ +$(see_cli_legacy) +~~~ +EOF } module_options+=( ["serve_doc,author"]="Tearran" - ["serve_doc,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L89" + ["serve_doc,ref_link"]="https://github.com/armbian/configng/blob/main/lib/armbian-configng/config.ng.functions.sh#L106" ["serve_doc,feature"]="serve_doc" ["serve_doc,desc"]="Serve the edit and debug server." ["serve_doc,example"]="serve_doc" @@ -112,7 +132,7 @@ function serve_doc() { module_options+=( ["see_use,author"]="Tearran" - ["see_use,ref_link"]="https://github.com/Tearran/configng/blob/main/config.ng.functions.sh#L126" + ["see_use,ref_link"]="https://github.com/armbian/configng/blob/main/lib/armbian-configng/config.ng.functions.sh#L145" ["see_use,feature"]="see_use" ["see_use,desc"]="Show the usage of the functions." ["see_use,example"]="see_use" @@ -141,7 +161,7 @@ function see_use() { 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,ref_link"]="https://github.com/armbian/configng/blob/main/lib/armbian-configng/config.ng.functions.sh#L174" ["generate_json_options,feature"]="generate_json" ["generate_json_options,desc"]="Generate JSON-like object file." ["generate_json_options,example"]="generate_json" @@ -195,7 +215,7 @@ 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,ref_link"]="https://github.com/armbian/configng/blob/main/lib/armbian-configng/config.ng.functions.sh#L201" ["generate_svg,feature"]="generate_svg" ["generate_svg,desc"]="Generate 'Armbian CPU logo' SVG for docunment file." ["generate_svg,example"]="generate_svg" @@ -220,7 +240,7 @@ 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,ref_link"]="https://github.com/armbian/configng/blob/main/lib/armbian-configng/config.ng.functions.sh#L253" ["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" @@ -268,7 +288,7 @@ done } -function see_jobs_list() { +function see_full_list() { cat << EOF @@ -281,20 +301,9 @@ Utility for configuring your board, divided into four main sections: - 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 + # Use jq to parse the JSON into markdown menu_items=$(jq -r '.menu | length' "$json_file") for (( i=0; i<$menu_items; i++ )) @@ -331,22 +340,57 @@ EOF 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: + +To clone this development branch, run the following commands: ~~~ -git clone https://github.com/armbian/configng.git -cd configng + git clone https://github.com/armbian/configng + cd configng + ./armbian-configng --help +~~~ + +## Install latest release +dowload .deb package: + +~~~ +{ + latest_release=\$(curl -s https://api.github.com/repos/armbian/configng/releases/latest) + deb_url=\$(echo "\$latest_release" | jq -r '.assets[] | select(.name | endswith(".deb")) | .browser_download_url') + curl -LO "\$deb_url" + deb_file=\$(echo "\$deb_url" | awk -F"/" '{print \$NF}') + sudo dpkg -i "\$deb_file" + sudo dpkg --configure -a + sudo apt --fix-broken install +} +~~~ + +*** + +## CLI options +Command ine options. + +Use: +~~~ + armbian-config --help +~~~ + +Outputs: +~~~ +$(see_cli_list) +~~~ + +## Legacy options +Backward Compatible options. + +Use: + + armbian-config main=Help + +Outputs: +~~~ +$(see_cli_legacy) ~~~ @@ -358,6 +402,8 @@ cd configng EOF +exit 0 ; + } @@ -398,7 +444,7 @@ function see_function_table_md() { 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,ref_link"]="https://github.com/armbian/configng/blob/main/lib/armbian-configng/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" @@ -419,4 +465,74 @@ jq -r ' "\n~~~\n" ' $json_file } +module_options+=( + ["see_cli_list,author"]="Tearran" + ["see_cli_list,ref_link"]="" + ["see_cli_list,feature"]="see_cli_list" + ["see_cli_list,desc"]="Generate a Help message for cli commands." + ["see_cli_list,example"]="see_cli_list" + ["see_cli_list,status"]="review" + ["see_cli_list,doc_link"]="" +) +# +# See command line options +# +function see_cli_list() { + local script_name=$(basename "$0") + cat << EOF +Usage: $script_name [option] [arguments] + --help - Display this help message. + main=Help - Display Legacy Options (Backward Compatible) + +EOF + # TODO: Migrate More features. + #echo " main=help - Display Legacy cli commands." + jq -r --arg script_name "$script_name" ' + .menu[] | + .sub[] | + select(.id | startswith("H") | not) | + " --cli " + .id + " - " + .description + ' $json_file +} + +module_options+=( + ["see_cli_legacy,author"]="Tearran" + ["see_cli_legacy,ref_link"]="" + ["see_cli_legacy,feature"]="see_cli_legacy" + ["see_cli_legacy,desc"]="Generate a Help message legacy cli commands." + ["see_cli_legacy,example"]="see_cli_legacy" + ["see_cli_legacy,status"]="review" + ["see_cli_legacy,doc_link"]="" +) +function see_cli_legacy() { + local script_name=$(basename "$0") + cat << EOF +Legacy Options (Backward Compatible) +Please use 'armbian-config --help' for more information. + +Usage: $script_name main=[arguments] selection=[options] + +EOF + cat << EOF + $script_name main=System selection=Headers - Install headers: + $script_name main=System selection=Headers_remove - Remove headers: + +EOF + +# TODO Migrate following features + +# $script_name main=System selection=Firmware - Update, upgrade and reboot: +# $script_name main=System selection=Nightly - Switch to nightly builds: +# $script_name main=System selection=Stable - Switch to stable builds: +# $script_name main=System selection=Default - Install default desktop: +# $script_name main=System selection=ZSH - Change to ZSH: +# $script_name main=System selection=BASH - Change to BASH: +# $script_name main=System selection=Stable - Change to stable repository [branch=dev]: +# $script_name main=System selection=Nightly - Change to nightly repository [branch=dev]: +# $script_name main=Software selection=Source_install - Install kernel source: +# $script_name main=Software selection=Source_remove - Remove kernel source: +# $script_name main=Software selection=Avahi - Install Avahi mDNS/DNS-SD daemon: + + +} diff --git a/lib/armbian-configng/config.ng.functions.sh b/lib/armbian-configng/config.ng.functions.sh index 9fe363d4..c726aacf 100644 --- a/lib/armbian-configng/config.ng.functions.sh +++ b/lib/armbian-configng/config.ng.functions.sh @@ -10,7 +10,7 @@ module_options+=( ["check_desktop,feature"]="check_desktop" ["check_desktop,desc"]="Migrated procedures from Armbian config." ["check_desktop,example"]="check_desktop" -["check_desktop,status"]="review" +["check_desktop,status"]="Active" ["check_desktop,doc_link"]="" ) # @@ -36,7 +36,7 @@ menu_options+=( ["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,status"]="Active" ["get_headers_kernel,doc_link"]="" ) # @@ -61,7 +61,7 @@ module_options+=( ["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,status"]="Active" ["set_header_remove,doc_ink"]="" ) # @@ -89,7 +89,7 @@ module_options+=( ["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_if_installed,status"]="Active" ) # # check dpkg status of $1 -- currently only 'not installed at all' case caught @@ -112,7 +112,7 @@ module_options+=( ["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" +["is_package_manager_running,status"]="Active" ) # # check if package manager is doing something @@ -135,7 +135,7 @@ module_options+=( ["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" +["set_runtime_variables,status"]="Active" ) # # gather info about the board and start with loading menu variables @@ -185,7 +185,7 @@ module_options+=( ["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" +["set_safe_boot,status"]="Active" ) # # freeze/unhold packages @@ -220,7 +220,7 @@ module_options+=( ["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_bt_interface,status"]="Active" ) # # connect to bluetooth device @@ -278,7 +278,7 @@ module_options+=( ["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" +["set_colors,status"]="Active" ) # # Function to set the tui colors @@ -357,7 +357,7 @@ module_options+=( ["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" +["generate_top_menu,status"]="Active" ) # # Function to generate the main menu from a JSON object @@ -407,7 +407,7 @@ module_options+=( ["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" +["generate_menu,status"]="Active" ) # # Function to generate the submenu @@ -445,6 +445,7 @@ function generate_menu() { # If it doesn't, execute the command [[ -n "$debug" ]] && echo "$OPTION" execute_command "$OPTION" + #show_message <<< "$OPTION" fi fi @@ -460,7 +461,7 @@ module_options+=( ["execute_command,desc"]="Needed by generate_menu" ["execute_command,example"]="" ["execute_command,doc_link"]="" -["execute_command,status"]="review" +["execute_command,status"]="Active" ) # # Function to execute the command @@ -484,7 +485,7 @@ module_options+=( ["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" +["show_message,status"]="Active" ) # # Function to display a message box @@ -510,7 +511,7 @@ module_options+=( ["show_infobox,desc"]="pipe line strings to a infobox " ["show_infobox,example"]="show_infobox <<< 'hello world' ; " ["show_infobox,doc_link"]="" -["show_infobox,status"]="review" +["show_infobox,status"]="Active" ) # # Function to display an infobox with a message @@ -548,7 +549,7 @@ module_options+=( ["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,status"]="Active" ) # # @@ -586,10 +587,10 @@ module_options+=( ["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" +["get_user_continue,status"]="Active" ) # -# Function to display a Yes/No dialog box (WIP) +# Function to display a Yes/No dialog box # function get_user_continue() { local message="$1" @@ -609,7 +610,7 @@ menu_options+=( ["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,status"]="Active" ["get_user_continue,doc_link"]="" ) # @@ -630,7 +631,7 @@ module_options+=( ["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" +["get_user_continue_secure,status"]="Active" ) # # Secure version of get_user_continue @@ -641,9 +642,16 @@ function get_user_continue_secure() { # 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 + found=0 + for func in "${allowed_functions[@]}"; do + if [[ "$func" == "$next_action" ]]; then + found=1 + break + fi + done + + if [[ "$found" -eq 1 ]]; then if $($DIALOG --yesno "$message" 10 80 3>&1 1>&2 2>&3); then $next_action else @@ -665,7 +673,7 @@ module_options+=( ["see_ping,desc"]="Check the internet connection with fallback DNS" ["see_ping,example"]="see_ping" ["see_ping,doc_link"]="" -["see_ping,status"]="review" +["see_ping,status"]="Active" ) # # Function to check the internet connection @@ -700,7 +708,7 @@ module_options+=( ["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" +["see_current_apt,status"]="Active" ) # # Function to check when the package list was last updated @@ -737,3 +745,83 @@ see_current_apt() { return 1 # The package lists are not up-to-date fi } + + +module_options+=( +["Headers_install,author"]="https://github.com/Tearran" +["Headers_install,ref_link"]="https://github.com/armbian/config/blob/master/debian-config-jobs#L160" +["Headers_install,feature"]="Headers_install" +["Headers_install,desc"]="Install kernel headers" +["Headers_install,example"]="if ! is_package_manager_running; then, 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},fi" +["Headers_install,status"]="Pending Review" +["Headers_install,doc_link"]="https://github.com/armbian/config/wiki#System" +) +# +# @description Install kernel headers +# +function Headers_install () { + if ! is_package_manager_running; then + 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} + fi +} + +module_options+=( +["Headers_remove,author"]="https://github.com/Tearran" +["Headers_remove,ref_link"]="https://github.com/armbian/config/blob/master/debian-config-jobs#L160" +["Headers_remove,feature"]="Headers_remove" +["Headers_remove,desc"]="Remove Linux headers" +["Headers_remove,example"]="if ! is_package_manager_running; then, 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,fi" +["Headers_remove,status"]="Pending Review" +["Headers_remove,doc_link"]="https://github.com/armbian/config/wiki#System" +) +# +# @description Remove Linux headers +# +function Headers_remove () { + if ! is_package_manager_running; then + 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 + fi +} + +module_options+=( +["sanitize_input,author"]="https://github.com/Tearran" +["sanitize_input,ref_link"]="https://github.com/armbian/config/blob/master/debian-config-jobs#L160" +["sanitize_input,feature"]="Headers_remove" +["sanitize_input,desc"]="Remove Linux headers" +["sanitize_input,example"]="if ! is_package_manager_running; then, 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,fi" +["sanitize_input,status"]="Pending Review" +["sanitize_input,doc_link"]="https://github.com/armbian/config/wiki#System" +) +# +# sanitize input cli +# +sanitize_input() { + local sanitized_input=() + for arg in "$@"; do + if [[ $arg =~ ^[a-zA-Z0-9_=]+$ ]]; then + sanitized_input+=("$arg") + else + echo "Invalid argument: $arg" + exit 1 + fi + done + echo "${sanitized_input[@]}" +} + + + + \ No newline at end of file diff --git a/lib/armbian-configng/config.ng.jobs.json b/lib/armbian-configng/config.ng.jobs.json index 4dc2f552..9a3a227d 100644 --- a/lib/armbian-configng/config.ng.jobs.json +++ b/lib/armbian-configng/config.ng.jobs.json @@ -9,11 +9,10 @@ "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" + "set_safe_boot unhold" ], "show": true, - "status": "WIP", + "status": "Active", "doc_link": "", "src_reference": "", "author": "" @@ -22,11 +21,10 @@ "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", + "status": "Active", "doc_link": "", "src_reference": "", "author": "" @@ -39,10 +37,34 @@ "nano /boot/armbianEnv.txt" ], "show": true, - "status": "WIP", + "status": "Active", "doc_link": "", "src_reference": "", "author": "" + }, + { + "id": "S04", + "description": "Install Linux headers", + "command": [ + "Headers_install" + ], + "show": true, + "status": "Pending Review", + "doc_link": "https://github.com/armbian/config/wiki#System", + "src_reference": "https://github.com/armbian/config/blob/master/debian-config-jobs#L160", + "author": "https://github.com/Tearran" + }, + { + "id": "S05", + "description": "Remove Linux headers", + "command": [ + "Headers_remove" + ], + "show": true, + "status": "Pending Review", + "doc_link": "https://github.com/armbian/config/wiki#System", + "src_reference": "https://github.com/armbian/config/blob/master/debian-config-jobs#L160", + "author": "https://github.com/Tearran" } ] }, @@ -60,7 +82,7 @@ "check_if_installed xserver-xorg && debconf-apt-progress -- apt-get -y --no-install-recommends install pulseaudio-module-bluetooth blueman" ], "show": false, - "status": "review", + "status": "Active", "doc_link": "", "src_reference": "", "author": "" @@ -75,7 +97,7 @@ "debconf-apt-progress -- apt -y -qq autoremove" ], "show": false, - "status": "review", + "status": "Active", "doc_link": "", "src_reference": "", "author": "" @@ -88,7 +110,7 @@ ], "show": false, - "status": "review", + "status": "Active", "doc_link": "", "src_reference": "", "author": "" @@ -100,7 +122,7 @@ "see_current_apt; debconf-apt-progress -- apt-get -y --no-install-recommends install lirc" ], "show": false, - "status": "review", + "status": "Active", "doc_link": "", "src_reference": "", "author": "" @@ -112,7 +134,7 @@ "see_current_apt; debconf-apt-progress -- apt-get -y --no-install-recommends install lirc" ], "show": false, - "status": "review", + "status": "Active", "doc_link": "", "src_reference": "", "author": "" @@ -124,7 +146,7 @@ "nmtui connect" ], "show": true, - "status": "review", + "status": "Active", "doc_link": "", "src_reference": "", "author": "" @@ -137,7 +159,7 @@ "nano /etc/network/interfaces" ], "show": true, - "status": "review", + "status": "Active", "doc_link": "", "src_reference": "", "author": "" @@ -151,7 +173,7 @@ "do nmcli con delete uuid $line; done > /dev/null" ], "show": true, - "status": "review", + "status": "Active", "doc_link": "", "src_reference": "", "author": "" @@ -164,7 +186,20 @@ "toggle_ipv6 | show_infobox" ], "show": true, - "status": "review", + "status": "Active", + "doc_link": "", + "src_reference": "", + "author": "" + }, + { + "id": "N04", + "description": "(WIP) Setup Hotspot?Access point", + "command": [ + "get_user_continue \"This operation will install necessary software and add configuration files.\nDo you wish to continue?\" process_input", + "hotspot_setup" + ], + "show": false, + "status": "WIP", "doc_link": "", "src_reference": "", "author": "" @@ -183,7 +218,7 @@ "dpkg-reconfigure tzdata" ], "show": true, - "status": "review", + "status": "Active", "doc_link": "", "src_reference": "", "author": "" @@ -197,7 +232,7 @@ "export LANGUAGE=$LANG" ], "show": true, - "status": "review", + "status": "Active", "doc_link": "", "src_reference": "", "author": "" @@ -209,7 +244,7 @@ "dpkg-reconfigure keyboard-configuration ; setupcon " ], "show": true, - "status": "review", + "status": "Active", "doc_link": "", "src_reference": "", "author": "" @@ -221,7 +256,7 @@ "get_user_continue \"This is only a frontend test\" process_input" ], "show": false, - "status": "review", + "status": "Active", "doc_link": "", "src_reference": "", "author": "" @@ -241,7 +276,7 @@ "debconf-apt-progress -- apt update" ], "show": true, - "status": "review", + "status": "Active", "doc_link": "", "src_reference": "", "author": "" @@ -253,7 +288,7 @@ "armbianmonitor -m | show_infobox" ], "show": true, - "status": "review", + "status": "Active", "doc_link": "", "src_reference": "", "author": "" @@ -272,7 +307,7 @@ "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", + "status": "Active", "doc_link": "", "src_reference": "", "author": "" @@ -284,7 +319,7 @@ "show_message <<< see_use" ], "show": false, - "status": "review", + "status": "Active", "doc_link": "", "src_reference": "", "author": "" diff --git a/lib/armbian-configng/config.ng.network.sh b/lib/armbian-configng/config.ng.network.sh index 27b0d2a4..9d20e7dd 100644 --- a/lib/armbian-configng/config.ng.network.sh +++ b/lib/armbian-configng/config.ng.network.sh @@ -106,3 +106,112 @@ function see_ping() { } + + +module_options+=( +["hotspot_setup,author"]="Joey Turner" +["hotspot_setup,ref_link"]="" +["hotspot_setup,feature"]="hotspot_setup" +["hotspot_setup,desc"]="Set up a WiFi hotspot on the device" +["hotspot_setup,example"]="hotspot_setup" +["hotspot_setup,status"]="review" +["hotspot_setup,doc_link"]="" +) + +# Function to display an error message and exit +function error_exit { + whiptail --msgbox "$1" 8 40 + exit 1 +} + +function hotspot_setup() { +# Ensure the script is run as root +if [[ $EUID -ne 0 ]]; then + error_exit "This script must be run as root." +fi + +# Gather SSID and passphrase for the hotspot +SSID=$(whiptail --inputbox "Enter SSID for the Hotspot:" 8 40 3>&1 1>&2 2>&3) +if [ $? -ne 0 ]; then + error_exit "SSID input cancelled." +fi + +PASSPHRASE=$(whiptail --passwordbox "Enter Passphrase for the Hotspot:" 8 40 3>&1 1>&2 2>&3) +if [ $? -ne 0 ]; then + error_exit "Passphrase input cancelled." +fi + +# Confirm SSID and Passphrase +whiptail --msgbox "SSID: $SSID\nPassphrase: $PASSPHRASE" 8 40 + +# Update and install necessary packages +apt update +apt install -y hostapd dnsmasq + +# Stop services while configuring +systemctl stop hostapd +systemctl stop dnsmasq + +# Configure hostapd +cat > /etc/hostapd/hostapd.conf < /etc/dnsmasq.conf <> /etc/network/interfaces < /etc/iptables.ipv4.nat" + +# Ensure iptables rule is loaded on boot +cat > /etc/rc.local < /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: + +To clone this development branch, run the following commands: ~~~ -git clone https://github.com/armbian/configng.git -cd configng + git clone https://github.com/armbian/configng + cd configng + ./armbian-configng --help +~~~ + +## Install latest release +dowload .deb package: + +~~~ +{ + latest_release=$(curl -s https://api.github.com/repos/armbian/configng/releases/latest) + deb_url=$(echo "$latest_release" | jq -r '.assets[] | select(.name | endswith(".deb")) | .browser_download_url') + curl -LO "$deb_url" + deb_file=$(echo "$deb_url" | awk -F"/" '{print $NF}') + sudo dpkg -i "$deb_file" + sudo dpkg --configure -a + sudo apt --fix-broken install +} +~~~ + +*** + +## CLI options +Command ine options. + +Use: +~~~ + armbian-config --help +~~~ + +Outputs: +~~~ +Usage: armbian-configng [option] [arguments] + + --help - Display this help message. + main=Help - Display Legacy Options (Backward Compatible) + + --cli S01 - Enable Armbina kernal upgrades + --cli S02 - Disable Armbina kernal upgrades + --cli S03 - Edit the boot enviroment (WIP) + --cli S04 - Install Linux headers + --cli S05 - Remove Linux headers + --cli BT0 - Install Bluetooth support + --cli BT1 - Remove Bluetooth support + --cli BT3 - Bluetooth Discover + --cli IR0 - Install Infrared support + --cli IR1 - Uninstall Infrared support + --cli N00 - Manage wifi network connections + --cli N01 - Advanced Edit /etc/network/interface + --cli N02 - Disconect and forget all wifi connections (Advanced) + --cli N03 - Toggle system IPv6/IPv4 internet protical + --cli L00 - Change Globla timezone (WIP) + --cli L01 - Change Locales reconfigure the language and charitorset + --cli L02 - Change Keyboard layout + --cli L03 - Change APT mirrors + --cli I00 - Update Application Repository + --cli I01 - CLI System Monitor +~~~ + +## Legacy options +Backward Compatible options. + +Use: + + armbian-config main=Help + +Outputs: +~~~ +Legacy Options (Backward Compatible) +Please use 'armbian-config --help' for more information. + +Usage: armbian-configng main=[arguments] selection=[options] + + armbian-configng main=System selection=Headers - Install headers: + armbian-configng main=System selection=Headers_remove - Remove headers: ~~~ diff --git a/share/doc/armbian-configng/Menu.md b/share/doc/armbian-configng/Menu.md index 8e67088d..1e50aaa7 100644 --- a/share/doc/armbian-configng/Menu.md +++ b/share/doc/armbian-configng/Menu.md @@ -1,5 +1,5 @@ -# Armbian-config Menu list. +# Menu list. armbian-config jobs list. ### S01 @@ -9,9 +9,6 @@ Enable Armbina kernal upgrades Jobs: ~~~ -get_user_continue "This will allow apt to update boot critical items - - Continue?" process_input set_safe_boot unhold ~~~ @@ -22,9 +19,6 @@ Disable Armbina kernal upgrades Jobs: ~~~ -get_user_continue "This will apt hold boot critical items - - Continue?" process_input set_safe_boot freeze ~~~ @@ -42,6 +36,26 @@ would you like to continue?" process_input nano /boot/armbianEnv.txt ~~~ +### S04 + +Install Linux headers + +Jobs: + +~~~ +Headers_install +~~~ + +### S05 + +Remove Linux headers + +Jobs: + +~~~ +Headers_remove +~~~ + ### BT0 Install Bluetooth support diff --git a/share/doc/armbian-configng/ScreenShot.md b/share/doc/armbian-configng/ScreenShot.md deleted file mode 100644 index f82a980d..00000000 --- a/share/doc/armbian-configng/ScreenShot.md +++ /dev/null @@ -1,17 +0,0 @@ -# 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 deleted file mode 100644 index ffe5d857..00000000 --- a/share/doc/armbian-configng/Standards.md +++ /dev/null @@ -1,37 +0,0 @@ -# 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/armbian-configng.csv b/share/doc/armbian-configng/armbian-configng.csv deleted file mode 100755 index 40dc84ad..00000000 --- a/share/doc/armbian-configng/armbian-configng.csv +++ /dev/null @@ -1,5 +0,0 @@ -Function Name,Group Name,Description,Options,Category,Category Description -NMTUI,network,Network Manager.,none.,network,Network Wired wireless Bluetooth access point -Hello,system,Hello System.,none,system,System and Security -Bencharking,monitor,Armbian Monitor and Benchmarking.,,system,System and Security -Install,system,Armbian installer,none.,system,System and Security diff --git a/share/doc/armbian-configng/armbian-configng.html b/share/doc/armbian-configng/armbian-configng.html deleted file mode 100755 index 40c3d780..00000000 --- a/share/doc/armbian-configng/armbian-configng.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - Armbian armbian-configng - - - -
-

armbian-configng

-
- -
-
- -
-
- - - - - - diff --git a/share/doc/armbian-configng/armbian-configng.json b/share/doc/armbian-configng/armbian-configng.json deleted file mode 100755 index 806c67fa..00000000 --- a/share/doc/armbian-configng/armbian-configng.json +++ /dev/null @@ -1,34 +0,0 @@ -[ - { - "Function Name": "NMTUI", - "Group Name": "network", - "Description": "Network Manager.", - "Options": "none.", - "Category": "network", - "Category Description": "Network Wired wireless Bluetooth access point" - }, - { - "Function Name": "Hello", - "Group Name": "system", - "Description": "Hello System.", - "Options": "none", - "Category": "system", - "Category Description": "System and Security" - }, - { - "Function Name": "Benchmarking", - "Group Name": "monitor", - "Description": "Armbian Monitor and Benchmarking.", - "Options": "", - "Category": "system", - "Category Description": "System and Security" - }, - { - "Function Name": "Install", - "Group Name": "system", - "Description": "Armbian installer", - "Options": "none.", - "Category": "system", - "Category Description": "System and Security" - } -] diff --git a/share/doc/armbian-configng/armbianCPU.svg b/share/doc/armbian-configng/armbianCPU.svg deleted file mode 100755 index 4d19784d..00000000 --- a/share/doc/armbian-configng/armbianCPU.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/share/doc/armbian-configng/index.html b/share/doc/armbian-configng/index.html deleted file mode 100755 index dc65e111..00000000 --- a/share/doc/armbian-configng/index.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - -
Function NameGroup NameDescriptionOptionsCategoryCategory Description
NMTUInetworkNetwork Manager.none.networkNetwork Wired wireless Bluetooth access point
HellosystemHello System.nonesystemSystem and Security
BenchmarkingmonitorArmbian Monitor and Benchmarking.systemSystem and Security
InstallsystemArmbian installernone.systemSystem and Security
- - - diff --git a/share/doc/armbian-configng/system.gif b/share/doc/armbian-configng/system.gif deleted file mode 100644 index 2e839d11..00000000 Binary files a/share/doc/armbian-configng/system.gif and /dev/null differ