Skip to content
Snippets Groups Projects
Commit a5f17c4f authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

each fqdn in cli params is allowed only once.

parent fd495d86
No related branches found
No related tags found
No related merge requests found
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
# 2021-02-17 <axel.hahn@iml.unibe.ch> ensure checks list of aliases; new: optional host filter before adding a cert # 2021-02-17 <axel.hahn@iml.unibe.ch> ensure checks list of aliases; new: optional host filter before adding a cert
# 2021-03-12 <axel.hahn@iml.unibe.ch> create file for haproxy # 2021-03-12 <axel.hahn@iml.unibe.ch> create file for haproxy
# 2021-03-22 <axel.hahn@iml.unibe.ch> for haproxy: use chained cert instead of server cert # 2021-03-22 <axel.hahn@iml.unibe.ch> for haproxy: use chained cert instead of server cert
# 2021-04-12 <axel.hahn@iml.unibe.ch> reject multiple usage of fqdn in cli params
# ====================================================================== # ======================================================================
...@@ -255,7 +256,23 @@ function _sortWords(){ ...@@ -255,7 +256,23 @@ function _sortWords(){
echo $* | tr " " "\n" | sort | tr "\n" " " echo $* | tr " " "\n" | sort | tr "\n" " "
} }
# internal function; verify fqdn in cli params - each fqdn is allowed only once.
# on error it shows the count of usage of each fqdn
function _testFqdncount(){
typeset -i local iHostsInParam=$( echo $* | wc -w )
typeset -i iHostsUniq=$( echo $* | tr " " "\n" | sort -u | wc -w )
if [ $iHostsInParam -ne $iHostsUniq ]; then
echo "ERROR: each given FQDN is allowed only once. You need to remove double entries."
for myhost in $( echo $* | tr " " "\n" | sort -u )
do
typeset -i iHostcount=$( echo $* | tr " " "\n" | grep "^$myhost$" | wc -l )
test $iHostcount -gt 1 && echo " $iHostcount x $myhost"
done
echo
exit 1
fi
}
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# #
# PUBLIC FUNCTIONS # PUBLIC FUNCTIONS
...@@ -523,6 +540,8 @@ if [ $# -gt 0 -a $? -eq 0 ]; then ...@@ -523,6 +540,8 @@ if [ $# -gt 0 -a $? -eq 0 ]; then
CM_fqdn=$2 CM_fqdn=$2
shift 2 shift 2
_testFqdncount $CM_fqdn $*
test -z "${ACME}" && ACME=$( which acme.sh ) test -z "${ACME}" && ACME=$( which acme.sh )
if [ ! -x "${ACME}" ]; then if [ ! -x "${ACME}" ]; then
echo "ERROR: acme.sh not found. You need to install acme.sh client and configure it in inc_config.sh." echo "ERROR: acme.sh not found. You need to install acme.sh client and configure it in inc_config.sh."
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment