mirror of
https://github.com/iiab/iiab.git
synced 2025-02-14 12:12:12 +00:00
which nmcli -> [[ command -v nmcli
]]
This commit is contained in:
parent
4797f0805c
commit
1a802fcaf1
1 changed files with 8 additions and 4 deletions
12
iiab-network
12
iiab-network
|
@ -41,9 +41,13 @@ if [ "$OS" == "centos" ] || [ "$OS" == "fedora" ]; then
|
|||
fi
|
||||
|
||||
# Ubuntu desktop/others might be using NM (NetworkManager) - split out.
|
||||
# if [ $(which nmcli) ]; then # syntax fails when multiple lines returned
|
||||
# if [[ `which nmcli` ]]; then # syntax also works
|
||||
if which nmcli; then # syntax works great, with "grep -q" too!
|
||||
#if [ $(grep ubuntu /etc/apt/sources.list) ]; then # FAILS when multiple lines returned, due to single square brackets
|
||||
#if grep -q ubuntu /etc/apt/sources.list ; then # Works: bypasses need for "> /dev/null" thanks to "grep -q" (quiet)
|
||||
#if command -v nmcli > /dev/null ; then # Works But Wordy!
|
||||
#if [[ $(command -v nmcli) ]]; then # Also Works! $(...) nests more easily than backticks
|
||||
#if [[ `which nmcli` ]]; then # "which" misses built-in commands like cd, and is RISKY per https://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script
|
||||
#if [[ `type -P nmcli` ]]; then # "type -P" isn't POSIX compliant; it misses built-in commands like "cd"
|
||||
if [[ `command -v nmcli` ]]; then # "command -v" is POSIX compliant; it catches built-in commands like "cd"
|
||||
nmcli d >> iiab-network.log
|
||||
nmcli c >> iiab-network.log
|
||||
fi
|
||||
|
@ -59,7 +63,7 @@ echo "" >> iiab-network.log
|
|||
|
||||
|
||||
# Put the same diagnostics on screen, for live operator
|
||||
if which nmcli; then # syntax works great, with "grep -q" too!
|
||||
if [[ `command -v nmcli` ]]; then # syntax works great, with "grep -q" too!
|
||||
nmcli d
|
||||
nmcli c
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue