Переглянути джерело

Added usage function

closes #3

Also put nmcli con show into its own function.
master
Brandon Nolet 2 роки тому
джерело
коміт
349d1f16f9
1 змінених файлів з 35 додано та 11 видалено
  1. +35
    -11
      nmcli-basic.sh

+ 35
- 11
nmcli-basic.sh Переглянути файл

@@ -18,13 +18,6 @@
# as valid dynamic address inputs.


nmcli con show



echo
read -p "Which interface to configure? " IntID
echo

function setstatic() {

@@ -58,19 +51,50 @@ function setdynamic() {
function apply() {

#Applying the changes
echo "Applying changes..."
nmcli con down ${IntID} > /dev/null
nmcli con up ${IntID} > /dev/null
echo "Done!"
echo "Applying changes..."
nmcli con down ${IntID} > /dev/null
nmcli con up ${IntID} > /dev/null
echo "Done!"
}

function conshow() {
nmcli con show
echo
read -p "Which interface to configure? " IntID
echo
}

function usage() {
echo "
Description: This is a basic script that makes use
of the nmcli command, setting either a static or
dynamic IPv4 address. The script will take one or
no arguments. Should no arguments be passed to the
script, then the user will be prompted for the mode
to set the interface to. Otherwise the syntax is as follows

Syntax:
./nmcli-basic.sh [dynamic|static]

The script will also take automatic, auto, and dhcp
as valid inputs for dynamic addressing.
"
}

case "$1" in
[dD]ynamic | [aA]uto | [aA]utomatic | [dD][hH][cC][pP])
conshow
setdynamic
;;
[sS]tatic | [mM]anual)
conshow
setstatic
;;

[uU]sage)
usage
;;
"")
read -p "Static or DHCP? " CHOICE
case ${CHOICE} in


Завантаження…
Відмінити
Зберегти