-1

Hello There my fellow devs, So recently i made this script that does wireguard installation and management, so i have been trying to add a usage on my shell script and i need some help.

Original Script https://github.com/complexorganizations/wireguard-manager

Usage: https://github.com/complexorganizations/wireguard-manager/issues/170

I know i made a bunch of mistakes can anyone take a look and help me out?

function usage-guide() {
  echo "usage: ./"$(basename "$0")" [OPTIONS]"
  echo "  --install     Install WireGuard Interface"
  echo "  --start       Start WireGuard Interface"
  echo "  --stop        Stop WireGuard Interface"
  echo "  --restart     Restart WireGuard Interface"
  echo "  --list        Show WireGuard Peers"
  echo "  --add         Add WireGuard Peer"
  echo "  --remove      Remove WireGuard Peer"
  echo "  --uninstall   Uninstall WireGuard Interface"
  echo "  --update      Update WireGuard Script"
  exit
}


while [ "$1" != "" ]; do
  case $1 in
  --install)
    shift
    HEADLESS_INSTALL=${HEADLESS_INSTALL:-y}=$1
    ;;
  --start)
    shift
    WIREGUARD_OPTIONS=${WIREGUARD_OPTIONS:-2}=$1
    ;;
  --stop)
    shift
    WIREGUARD_OPTIONS=${WIREGUARD_OPTIONS:-3}=$1
    ;;
  --restart)
    shift
    WIREGUARD_OPTIONS=${WIREGUARD_OPTIONS:-4}=$1
    ;;
  --list)
    shift
    WIREGUARD_OPTIONS=${WIREGUARD_OPTIONS:-1}=$1
    ;;
  --add)
    shift
    WIREGUARD_OPTIONS=${WIREGUARD_OPTIONS:-5}=$1
    ;;
  --remove)
    shift
    WIREGUARD_OPTIONS=${WIREGUARD_OPTIONS:-6}=$1
    ;;
  --uninstall)
    shift
    WIREGUARD_OPTIONS=${WIREGUARD_OPTIONS:-7}=$1
    ;;
  --update)
    shift
    WIREGUARD_OPTIONS=${WIREGUARD_OPTIONS:-8}=$1
    ;;
  esac
  shift
done
```
  • You don't seem to have a specific problem. If you want a code review of your script, you may want to try [CodeReview](https://codereview.stackexchange.com/) instead. – Aserre Mar 06 '20 at 09:08

1 Answers1

0

You can insert lines (on the bottom) like this:

  --update)
    shift
    WIREGUARD_OPTIONS=${WIREGUARD_OPTIONS:-8}=$1
    ;;
  *)
   usage-guide
   ;;
  esac
  shift
done
Romeo Ninov
  • 6,538
  • 1
  • 22
  • 31