iankelling.org
/
git
/
basic-https-conf
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
74fad77
)
use gnu getopt for more flexible arg parsing
author
Ian Kelling
<ian@iankelling.org>
Mon, 5 Sep 2016 06:50:38 +0000
(23:50 -0700)
committer
Ian Kelling
<ian@iankelling.org>
Mon, 5 Sep 2016 06:50:38 +0000
(23:50 -0700)
apache-site
patch
|
blob
|
history
diff --git
a/apache-site
b/apache-site
index 8a67722ada42f9487a7fa6408a0a9d29d7612784..4550e85f5b55ee15eba1617444f4e6ceafdc1ec6 100755
(executable)
--- a/
apache-site
+++ b/
apache-site
@@
-13,7
+13,6
@@
# See the License for the specific language governing permissions and
# limitations under the License.
# See the License for the specific language governing permissions and
# limitations under the License.
-# run as root.
[[ $EUID == 0 ]] || exec sudo -E "$BASH_SOURCE" "$@"
set -eE -o pipefail
[[ $EUID == 0 ]] || exec sudo -E "$BASH_SOURCE" "$@"
set -eE -o pipefail
@@
-28,14
+27,13
@@
location for storing certs.
EXTRA_SETTINGS_FILE can be - for stdin
-p PORT
EXTRA_SETTINGS_FILE can be - for stdin
-p PORT
--i
Insecure, no ssl
+-i Insecure, no ssl
-c CERT_DIR In priority: this arg, $ACME_TINY_WRAPPER_CERT_DIR,
$HOME/webservercerts, if the other options aren't set.
-c CERT_DIR In priority: this arg, $ACME_TINY_WRAPPER_CERT_DIR,
$HOME/webservercerts, if the other options aren't set.
--h|--help Print help and exit
-r DocumentRoot
-r DocumentRoot
--
- Subsequent arguments are never treated as options
+-
h|--help Print help and exit
-Note:
options and non-options can be in any order.
+Note:
Uses GNU getopt options parsing style
EOF
exit $1
}
EOF
exit $1
}
@@
-48,22
+46,22
@@
if [[ ! $cert_dir ]]; then
fi
ssl=true
extra_settings=
fi
ssl=true
extra_settings=
-args=()
port="*:443"
port="*:443"
-while [[ $1 ]]; do
+temp=$(getopt -l help ic:p:r:h "$@") || usage 1
+eval set -- "$temp"
+while true; do
case $1 in
case $1 in
- -i) ssl=false; shift ;;
# i for insecure
+ -i) ssl=false; shift ;;
-c) cert_dir="$2"; shift 2 ;;
-p) port="$2"; shift 2 ;;
-r) root="$2"; shift 2 ;;
--) shift; break ;;
-c) cert_dir="$2"; shift 2 ;;
-p) port="$2"; shift 2 ;;
-r) root="$2"; shift 2 ;;
--) shift; break ;;
- -
?*|-
h|--help) usage ;;
- *)
args+=("$1"); shift
;;
+ -h|--help) usage ;;
+ *)
echo "$0: Internal error!" ; exit 1
;;
esac
done
esac
done
-args+=("$@")
-if (( ${#
args[@]
} == 2 )); then
+if (( ${#
@
} == 2 )); then
read extra_settings h <<<"${args[@]}"
else
read h <<<"${args[@]}"
read extra_settings h <<<"${args[@]}"
else
read h <<<"${args[@]}"