diff --git a/README.md b/README.md index f52cff0..2cb16e4 100644 --- a/README.md +++ b/README.md @@ -391,11 +391,12 @@ Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkMa ``` Usage: - nmcli-cli-autoconnect-list on|off + nmcli-cli-autoconnect-list all + nmcli-cli-autoconnect-list yes|no or on|off Examples: - nmcli-cli-autoconnect-list off - nmcli-cli-autoconnect-list on + nmcli-cli-autoconnect-list all + nmcli-cli-autoconnect-list yes ``` Run examples: diff --git a/nmcli-cli-autoconnect-list b/nmcli-cli-autoconnect-list index 9480299..4652e23 100755 --- a/nmcli-cli-autoconnect-list +++ b/nmcli-cli-autoconnect-list @@ -11,11 +11,12 @@ usage() { cat << _EOF_ Usage: - $0 on|off + $0 all + $0 yes|no or on|off Examples: - $0 off - $0 on + $0 all + $0 yes _EOF_ } @@ -23,9 +24,11 @@ _EOF_ autoconnect_list() { ON_OFF=${1:-} - if [[ "${ON_OFF}" = on ]]; then + if [[ "${ON_OFF}" == "all" ]]; then + ON_OFF="all" + elif [[ "${ON_OFF}" == "on" ]] || [[ "${ON_OFF}" == "yes" ]]; then ON_OFF="yes" - elif [[ "${ON_OFF}" = off ]]; then + elif [[ "${ON_OFF}" == "off" ]] || [[ "${ON_OFF}" == "no" ]]; then ON_OFF="no" else echo "Error: option \"${ON_OFF}\" is invalid." @@ -33,7 +36,15 @@ autoconnect_list() { fi # list - grep "^ONBOOT=${ON_OFF}" /etc/sysconfig/network-scripts/ifcfg-* | cut -d':' -f 1 | sed 's|.*/ifcfg-||g' + LIST=$(nmcli connection | awk '{ print $1 }' | grep -v "^NAME$") + for INTERFACE in ${LIST} + do + STATUS_LINE=$(nmcli connection show "${INTERFACE}" | grep connection.autoconnect:) + STATUS=$(echo "${STATUS_LINE}" | awk '{ print $2 }') + if [[ "${ON_OFF}" == "all" ]] || [[ "${STATUS}" == "${ON_OFF}" ]]; then + echo "${INTERFACE}" + fi + done } # Main diff --git a/nmcli-cli-bond-delete b/nmcli-cli-bond-delete index 4cdecd7..1a02ffd 100755 --- a/nmcli-cli-bond-delete +++ b/nmcli-cli-bond-delete @@ -49,11 +49,11 @@ check() { bond_delete() { local BOND_IF_NAME=${1:-} - # Find slave interfaces - SLAVE_LIST=$(grep "^MASTER=${BOND_IF_NAME}$" /etc/sysconfig/network-scripts/ifcfg-* | cut -d':' -f 1 | egrep -o "bond-slave.*") + # Find lower interfaces + INTERFACE_LIST=$(ls "/sys/class/net/${BOND_IF_NAME}/" | grep "^lower_" | sed 's|lower_||') - # Delete slave interfaces - for i in ${SLAVE_LIST} + # Delete lower interfaces + for i in ${INTERFACE_LIST} do echo_or_execute nmcli connection delete \"${i}\" done diff --git a/nmcli-cli-bridge-delete b/nmcli-cli-bridge-delete index 5d31cf7..a35349f 100755 --- a/nmcli-cli-bridge-delete +++ b/nmcli-cli-bridge-delete @@ -49,11 +49,11 @@ check() { bridge_delete() { local BRIDGE_NAME=${1:-} - # Find slave interfaces - SLAVE_LIST=$(grep "^BRIDGE=${BRIDGE_NAME}$" /etc/sysconfig/network-scripts/ifcfg-* | cut -d':' -f 1 | sed 's|.*/ifcfg-||g') + # Find lower interface + INTERFACE_LIST=$(ls "/sys/class/net/${BRIDGE_NAME}/" | grep "^lower_" | sed 's|lower_||') - # Delete slave interfaces - for i in ${SLAVE_LIST} + # Delete lower interface + for i in ${INTERFACE_LIST} do echo_or_execute nmcli connection modify \"${i}\" connection.master \"\" connection.slave-type \"\" done diff --git a/nmcli-cli-slave-list b/nmcli-cli-slave-list index 828031a..80fc352 100755 --- a/nmcli-cli-slave-list +++ b/nmcli-cli-slave-list @@ -23,27 +23,14 @@ _EOF_ slave_list() { local IF_NAME=${1:-} - # Bond - # Find slave interfaces - SLAVE_LIST=$(grep "^MASTER=${IF_NAME}$" /etc/sysconfig/network-scripts/ifcfg-* | cut -d':' -f 1 | egrep -o "bond-slave.*") - for i in ${SLAVE_LIST} - do - echo "${i}" - done - - # Bridge - # Find slave interfaces - SLAVE_LIST=$(grep "^BRIDGE=${IF_NAME}$" /etc/sysconfig/network-scripts/ifcfg-* | cut -d':' -f 1 | sed 's|.*/ifcfg-||g') - for i in ${SLAVE_LIST} - do - echo "${i}" - done - - # VLAN - # Find physical interface - IFCFG_FILE="/etc/sysconfig/network-scripts/ifcfg-${IF_NAME}" - if [[ -f "${IFCFG_FILE}" ]]; then - grep "^PHYSDEV=" "${IFCFG_FILE}" | cut -d'=' -f 2 + # Find lower interfaces + TARGET="/sys/class/net/${IF_NAME}/" + if [[ -e "${TARGET}" ]]; then + INTERFACE_LIST=$(ls "${TARGET}" | grep "^lower_" | sed 's|lower_||') + for i in ${INTERFACE_LIST} + do + echo "${i}" + done fi }