浏览代码

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


正在加载...
取消
保存