Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a warning to welcome screen #276

Merged
merged 13 commits into from
Dec 9, 2024
1 change: 1 addition & 0 deletions bin/armbian-config
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ declare -A module_options

source "$lib_dir/config.functions.sh"
set_runtime_variables
check_distro_status
echo "Loaded Runtime variables..." #| show_infobox ;
#set_newt_colors 2
echo "Loaded Dialog..." #| show_infobox ;
Expand Down
46 changes: 46 additions & 0 deletions tools/modules/functions/check_distro_status.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

module_options+=(
["check_os_status,author"]="@Tearran"
["check_os_status,feature"]="check_os_status"
["check_os_status,example"]="help"
["check_os_status,desc"]="Check if the current OS is supported based on /etc/armbian-distribution-status"
["check_os_status,status"]="Active"
)

function check_distro_status() {
case "$1" in
help)
echo "Usage: check_os_status"
echo "This function checks if the current OS is supported based on /etc/armbian-distribution-status."
echo "It retrieves the current OS distribution and checks if it is listed as supported in the specified file."
;;
*)

# Ensure OS detection succeeded
# if [[ -z "$DISTROID" && -z "$ARMBIAN" ]]; then
if [[ -z "$DISTROID" ]]; then
echo "Error: Unable to detect the current OS distribution."
exit 1
fi

# Check if the OS is listed as supported in the DISTRO_STATUS
if grep -qE "^${DISTROID}=.*supported" "$DISTRO_STATUS" 2> /dev/null; then
echo "The current $ARMBIAN ($DISTROID) is supported."
else
BACKTITLE="Warning: The current OS ($DISTROID) is not supported or not listed"
set_colors 1
get_user_continue "Warning:

The current OS ($DISTROID) is not a officially supported distribution!

The tool might still work well, but be aware that issues may
not be accepted and addressed by the maintainers. However, you are
welcome to contribute fixes for any problems you encounter.


Would you like to continue?
" process_input
fi
;;
esac
}
5 changes: 4 additions & 1 deletion tools/modules/functions/set_runtime_variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ function set_runtime_variables() {
fi

[[ -f /etc/armbian-release ]] && source /etc/armbian-release && ARMBIAN="Armbian $VERSION $IMAGE_TYPE"
[[ -f /etc/armbian-distribution-status ]] && DISTRO_STATUS="/etc/armbian-distribution-status"

DISTRO=$(lsb_release -is)
DISTROID=$(lsb_release -sc)
DISTROID=$(lsb_release -sc || grep "VERSION=" /etc/os-release | grep -oP '(?<=\().*(?=\))')
KERNELID=$(uname -r)
[[ -z "${ARMBIAN// /}" ]] && ARMBIAN="$DISTRO $DISTROID"

SOFTWARE_FOLDER="/armbian" # where we should keep 3rd party software
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)
Expand Down
Loading