auto detect passwords if documented

master
Marc Wäckerlin 7 years ago
parent 8dfa0dc850
commit e004687ce1
  1. 15
      template.sh

@ -1,5 +1,12 @@
#!/bin/bash -e
file=
if test -e "${!#}"; then
for var in $(sed -n 's,^ *# \+\(-p\|--pwd\) \+\([a-zA-Z][a-zA-Z0-9_]*\),\2,p' "${!#}"); do
export ${var}=$(pwgen 40 1)
done
fi
while test $# -gt 0; do
case "$1" in
(-h|--help) if test -e "${!#}"; then
@ -20,6 +27,10 @@ OPTIONS
-v, --var name=value Set environment variable to be used in the template.
-p, --pwd name Generate a random password with the given name.
If a password is documented, then it does not
need to be specified. But automated
generation can be overwritten assigning a
value using option -v.
FILE
@ -115,8 +126,8 @@ EOF
exit 1
fi;;
(*) if test $# -ne 1 -o ! -e "$1"; then
echo "ERROR please specify exactly one template file $*" 1>&2
echo " this not a template file: $*" 1>&2
echo "ERROR please specify exactly one template file" 1>&2
echo " this not one template file: $*" 1>&2
echo " see: $0 --help" 1>&2
exit 1
fi

Loading…
Cancel
Save