summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFredrik Thulin <fredrik@thulin.net>2015-03-31 09:18:06 +0200
committerFredrik Thulin <fredrik@thulin.net>2015-03-31 09:18:06 +0200
commit05b8a51e6ef6ee7e2db8af0fecfc8840bcb58652 (patch)
treedad078baacad56abf6525bc73172ad28eb3647e2
parent9fd62e1c4294ae8c1921aefd41d55f2e70816dd6 (diff)
argument parsing piff-up
-rwxr-xr-xscripts/mkreq24
1 files changed, 22 insertions, 2 deletions
diff --git a/scripts/mkreq b/scripts/mkreq
index 4493867..c5e8e9f 100755
--- a/scripts/mkreq
+++ b/scripts/mkreq
@@ -1,6 +1,5 @@
#!/bin/sh
-host="$1"; shift
ca_host="ca.sunet.se"
ca_name="infra"
type=""
@@ -22,14 +21,21 @@ Usage: mkreq [-v] [-s*] [-c] [-C <ca host>] [-N <ca name>] [--] <fqdn>
" 1>&2
}
+if [ "x$1" = "x" ]; then
+ usage
+ exit 1
+fi
+
{
while test $# -gt 0; do
case "$1" in
-s)
type="server"
+ shift
;;
-c)
type="client"
+ shift
;;
-C)
ca_host="$2"
@@ -46,11 +52,25 @@ Usage: mkreq [-v] [-s*] [-c] [-C <ca host>] [-N <ca name>] [--] <fqdn>
--)
break
;;
+ *)
+ echo $1 | grep -q '^-' || break # found the fqdn
+ echo "$0: Unknown option $1"
+ echo ""
+ usage
+ exit 1
esac
- shift
done
}
+host="$1"
+
+if [ "x$host" = "x" ]; then
+ echo "$0: No fqdn supplied"
+ echo ""
+ usage
+ exit 1
+fi
+
if [ -d $host -a -z $type ]; then
type="server"
fi