Parameter --hostname is used for 2 separate things
thomas-maeder opened this issue · 0 comments
thomas-maeder commented
As can bee seen from the name of the variable domain which is used to store the value of the command line argument --hostname, that parameter is used for 2 separate things:
- the internal name of the Zimbra host providing the proxy server
- the external name used to reach this proxy from the internet, and which should end up as CN in the certificates
I have hacked the script so that I have been able to use it on my Zimbra installation - see below for diff. I don't think that my modification is correct for all cases, but it may serve as a start:
174c174
< [[ -z "$domain" ]] && printf 'Unexpected error (check_zimbra_proxy domain not set).\n' >&2 && exit 1
---
> [[ -z "$hostname" ]] && printf 'Unexpected error (check_zimbra_proxy hostname not set).\n' >&2 && exit 1
183c183
< if ! sudo -in -u zimbra -- '$HOME/bin/zmprov' $zmprov_opts gs "$domain" zimbraReverseProxyHttpEnabled | grep -q TRUE; then
---
> if ! sudo -in -u zimbra -- '$HOME/bin/zmprov' $zmprov_opts gs "$hostname" zimbraReverseProxyHttpEnabled | grep -q TRUE; then
190c190
< port="$(sudo -in -u zimbra -- '$HOME/bin/zmprov' $zmprov_opts gs "$domain" zimbraMailProxyPort | sed -n "s/zimbraMailProxyPort: //p")"
---
> port="$(sudo -in -u zimbra -- '$HOME/bin/zmprov' $zmprov_opts gs "$hostname" zimbraMailProxyPort | sed -n "s/zimbraMailProxyPort: //p")"
376,379c376,379
< # If we got no domain from command line try using Zimbra hostname
< if [[ -z "$domain" ]]; then
< ! "$quiet" && printf 'Using zmhostname to detect domain name.\n' >&2
< domain="$("$zmpath/bin/zmhostname")"
---
> # If we got no hostname from command line try using Zimbra hostname
> if [[ -z "$hostname" ]]; then
> ! "$quiet" && printf 'Using zmhostname to detect hostname.\n' >&2
> hostname="$("$zmpath/bin/zmhostname")"
382c382
< [[ -z "$domain" ]] && printf 'Error: No hostname found! Please run with -H/--hostname or check why zmhostname is not working.\n' >&2 && exit 1
---
> [[ -z "$hostname" ]] && printf 'Error: No hostname found! Please run with -H/--hostname or check why zmhostname is not working.\n' >&2 && exit 1
388c388
< (( $? == 1 )) && printf 'Error: Please manually specify your hostname with "--hostname your.host.name".\n' >&2 && exit 0
---
> (( $? == 1 )) && printf 'Error: Please manually specify your domain with "--domain my.domain.name".\n' >&2 && exit 0
764c764,765
< -H | --hostname <my.host.name>: hostname being requested. If not passed it's automatically detected using "zmhostname". Used as Zimbra server name in zmprov, CN and name for certificate.
---
> -H | --hostname <my.host.name>: hostname being requested. If not passed it's automatically detected using "zmhostname". Used as Zimbra server name in zmprov
> -D | --domain <my.domain.name>: primary domain name in certificate (CN)
844a846,850
> -D|--domain)
> [[ -z "$2" ]] && printf 'Error: missing --domain argument\n' >&2 && exit 1
> domain="$2"
> shift
> ;;
853c859
< domain="$2"
---
> hostname="$2"