Skip to content

Commit

Permalink
Merge pull request #38 from mordiaky/mordiaky-patch-1
Browse files Browse the repository at this point in the history
Mordiaky patch 1
  • Loading branch information
Tearran authored Jul 7, 2024
2 parents 722fe9f + baee3e7 commit 841ea1a
Show file tree
Hide file tree
Showing 30 changed files with 1,187 additions and 2,033 deletions.
532 changes: 462 additions & 70 deletions README.md

Large diffs are not rendered by default.

100 changes: 0 additions & 100 deletions bin/README.md

This file was deleted.

128 changes: 97 additions & 31 deletions bin/armbian-configng
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,12 @@ 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")"

# 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"

#
Expand All @@ -44,38 +36,112 @@ 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




tput clear
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")
if [[ $EUID != 0 ]]; then
echo "Error: The --cli option requires root privileges. Please run as root or use sudo."
exit 1
fi
shift
args=$(sanitize_input "$@")
execute_command "$args"
exit 0
;;
"--api")
if [[ $EUID != 0 ]]; then
echo "Error: The --api option requires root privileges. Please run as root or use sudo."
exit 1
fi
shift
args=$(sanitize_input "$@")
"$args"
exit 0
;;
"main=help" | "main=Help")
see_cli_legacy
echo ""
exit 0
;;
"main="*)
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
Expand Down
Loading

0 comments on commit 841ea1a

Please sign in to comment.