diff --git a/lib/armbian-configng/config.ng.docs.sh b/lib/armbian-configng/config.ng.docs.sh index c3c0fda1..81e05871 100644 --- a/lib/armbian-configng/config.ng.docs.sh +++ b/lib/armbian-configng/config.ng.docs.sh @@ -391,7 +391,7 @@ function see_full_list() { doc_link=$(jq -r ".menu[$i].sub[$j].doc_link" "$json_file") # Check if src_reference and doc_link are null - [ -z "$doc_link" == "" ] && doc_link="#$id_link" || doc_link="$doc_link" + [ -z "$doc_link" ] && doc_link="#$id_link" || doc_link="$doc_link" echo -e " - **$id** - $description" # echo -e " - Status: [$status]($doc_link)" diff --git a/lib/armbian-configng/config.ng.jobs.json b/lib/armbian-configng/config.ng.jobs.json index 1451729f..533a9c48 100644 --- a/lib/armbian-configng/config.ng.jobs.json +++ b/lib/armbian-configng/config.ng.jobs.json @@ -435,6 +435,16 @@ "src_reference": "", "author": "Igor Pecovnik", "condition": "" + }, + { + "id": "N90", + "description": "Display status", + "command": [ "show_message <<< \"$(sudo netplan status)\"" ], + "status": "Active", + "doc_link": "", + "src_reference": "", + "author": "Igor Pecovnik", + "condition": "" } ] }, diff --git a/lib/armbian-configng/config.ng.network.sh b/lib/armbian-configng/config.ng.network.sh index 2fa47ab2..15014d23 100644 --- a/lib/armbian-configng/config.ng.network.sh +++ b/lib/armbian-configng/config.ng.network.sh @@ -244,16 +244,23 @@ function choose_adapter() { if [[ $intf =~ $HIDE_IP_PATTERN ]]; then continue else - QUERY=$(ip -br addr show dev $interface | grep "^$type" | awk '{print $1" " $3}') + QUERY=$(ip -br addr show dev $interface | grep "^$type" | awk '{ print $1, " " , ($3==""?"unassigned":$3) }') [[ -n $QUERY ]] && LIST+=($QUERY) fi done LIST_LENGTH=$((${#LIST[@]}/2)); - adapter=$(whiptail --title "Select interface" --menu "" $((${LIST_LENGTH} + 8)) 40 $((${LIST_LENGTH})) "${LIST[@]}" 3>&1 1>&2 2>&3) - if [[ -n $adapter && adapter != "all-eth-interfaces" && "${getip}" != false ]]; then - address=$(ip -br addr show dev $adapter | awk '{print $3}') - address=$(whiptail --title "Enter new IP for $adapter" --inputbox "\nValid format: $address" 9 40 "$address" 3>&1 1>&2 2>&3) + if [[ -n $adapter && adapter != "all-eth-interfaces" && "${getip}" != false && $? == 0 ]]; then + address=$(ip -br addr show dev $adapter | awk '{print $3}') + address=$(whiptail --title "Enter IP for $adapter" --inputbox "\nValid format: $address" 9 40 "$address" 3>&1 1>&2 2>&3) + if [[ -n $address && $? == 0 ]]; then + defaultroute=$(ip route show default | grep "$adapter" | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]") + defaultroute=$(whiptail --title "Enter IP for default route" --inputbox "\nValid format: $defaultroute" 9 40 "$defaultroute" 3>&1 1>&2 2>&3) + if [[ -n $defaultroute && $? == 0 ]]; then + nameservers="9.9.9.9,1.1.1.1" + nameservers=$(whiptail --title "Enter DNS server" --inputbox "\nValid format: $nameservers" 9 40 "$nameservers" 3>&1 1>&2 2>&3) + fi + fi fi } @@ -273,9 +280,10 @@ module_options+=( function wifi_connect() { choose_adapter "w" "false" "true" - + # enable adapter + ip link set ${adapter} up LIST=() - LIST=($(sudo iw dev ${adapter} scan 2> /dev/null | grep 'SSID\|^BSS' | cut -d" " -f2 | sed "s/(.*//g" | xargs -n2 -d'\n' | awk '{print $2,$1}')) + LIST=($(iw dev ${adapter} scan 2> /dev/null | grep 'SSID\|^BSS' | cut -d" " -f2 | sed "s/(.*//g" | xargs -n2 -d'\n' | awk '{print $2,$1}')) LIST_LENGTH=$((${#LIST[@]}/2)); SELECTED_SSID=$(whiptail --title "Select SSID" --menu "rf" $((${LIST_LENGTH} + 6)) 50 $((${LIST_LENGTH})) "${LIST[@]}" 3>&1 1>&2 2>&3) if [[ -n $SELECTED_SSID ]]; then @@ -332,8 +340,8 @@ function netplan_wrapper() { rm -f /etc/netplan/10-dhcp-all-interfaces.yaml netplan set --origin-hint ${config} renderer=${renderer} netplan set --origin-hint ${config} ethernets.${adapter}.addresses=[$address] - netplan set --origin-hint ${config} ${type}.${adapter}.dhcp6=false - netplan set --origin-hint ${config} ${type}.${adapter}.dhcp4=false + netplan set --origin-hint ${config} ${type}.${adapter}.routes='[{"to":"0.0.0.0/0", "via": "'$defaultroute'","metric":200}]' + netplan set --origin-hint ${config} ${type}.${adapter}.nameservers.addresses=[$nameservers] show_message <<< "$(sudo netplan get ${type})" else [[ -n "${address}" ]] && show_message <<< "IP address is wrong. Try 1.2.3.4/5"