56,10 → 56,21 |
{ |
|
fqdn=$(openssl x509 -noout -subject -in $cert | sed -n '/^subject/s/^.*CN=//p' | cut -d'/' -f 1) |
hostname=`echo $fqdn | awk -F'.' '{ print $1 }'` |
domain=`echo $fqdn | awk -F'.' '{$1="";OFS=".";print $0}' |sed 's/^.//'` |
echo "fqdn=$fqdn hostname=$hostname domain=$domain" |
if [ "$fqdn" != "" ] |
|
#check if there is a wildcard in $fqdn |
mystar='*' |
if [[ $fqdn == *"${mystar}"* ]]; |
then |
hostname="alcasar" |
fqdn=${fqdn/$mystar/$hostname} |
else |
hostname=`echo $fqdn | awk -F'.' '{ print $1 }'` |
fi |
domain=`echo $fqdn | awk -F'.' '{$1="";OFS=".";print $0}' |sed 's/^.//'` |
echo "fqdn=$fqdn hostname=$hostname domain=$domain" |
|
#check fqdn format |
if [[ "$fqdn" != "" && "$domain" != "" && "$hostname" == "alcasar" ]]; |
then |
$SED "s/^HOSTNAME=.*/HOSTNAME=$hostname/g" /usr/local/etc/alcasar.conf |
$SED "s/^DOMAIN=.*/DOMAIN=$domain/g" /usr/local/etc/alcasar.conf |