Subversion Repositories ALCASAR

Rev

Rev 1765 | Rev 1941 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 1765 Rev 1934
Line 54... Line 54...
54
 
54
 
55
function domainName() # change the domain name in the conf files
55
function domainName() # change the domain name in the conf files
56
{
56
{
57
 
57
 
58
	fqdn=$(openssl x509 -noout -subject -in $cert | sed -n '/^subject/s/^.*CN=//p' | cut -d'/' -f 1)
58
	fqdn=$(openssl x509 -noout -subject -in $cert | sed -n '/^subject/s/^.*CN=//p' | cut -d'/' -f 1)
-
 
59
 
-
 
60
        #check if there is a wildcard in $fqdn
-
 
61
        mystar='*'
-
 
62
        if [[ $fqdn == *"${mystar}"* ]];
-
 
63
        then
-
 
64
                hostname="alcasar"
-
 
65
                fqdn=${fqdn/$mystar/$hostname}
-
 
66
        else
59
	hostname=`echo $fqdn | awk -F'.' '{ print $1 }'`
67
                hostname=`echo $fqdn | awk -F'.' '{ print $1 }'`
-
 
68
        fi
60
	domain=`echo $fqdn | awk -F'.' '{$1="";OFS=".";print $0}' |sed 's/^.//'`
69
        domain=`echo $fqdn | awk -F'.' '{$1="";OFS=".";print $0}' |sed 's/^.//'`
61
	echo "fqdn=$fqdn hostname=$hostname domain=$domain"
70
        echo "fqdn=$fqdn hostname=$hostname domain=$domain"
-
 
71
 
62
	if [ "$fqdn" != "" ]
72
        #check fqdn format      
-
 
73
        if [[ "$fqdn" != "" && "$domain" != "" && "$hostname" == "alcasar" ]];
63
	then
74
	then
64
		$SED "s/^HOSTNAME=.*/HOSTNAME=$hostname/g" /usr/local/etc/alcasar.conf
75
		$SED "s/^HOSTNAME=.*/HOSTNAME=$hostname/g" /usr/local/etc/alcasar.conf
65
		$SED "s/^DOMAIN=.*/DOMAIN=$domain/g" /usr/local/etc/alcasar.conf
76
		$SED "s/^DOMAIN=.*/DOMAIN=$domain/g" /usr/local/etc/alcasar.conf
66
		cat <<EOF > /etc/hosts
77
		cat <<EOF > /etc/hosts
67
127.0.0.1	localhost
78
127.0.0.1	localhost