HowTos/ChangeFQDN

From Scalix Wiki
Revision as of 05:18, 23 October 2007 by Florian (Talk | contribs) (Changing the Hostname of a Scalix Server)

Jump to: navigation, search

Scalix Wiki -> How-Tos -> Change FQDN/Hostname

Changing the Hostname of a Scalix Server

If for some reason you need to change the name of a Scalix server please follow these steps.

For this example we will change the hostname from old.scalix.demo to new.scalix.demo.

Change the server's name

The procedure for doing this will vary based on your linux distribution, the basic idea is to change /etc/hosts so that your server can resolve its own IP, as well as changing whichever file your distribution uses to store the hostname, such as /etc/default/hostname, /etc/sysconfig/network or similar.

When you are done the command hostname --fqdn should output the new hostname correctly. Check hostname -s for good measure as well to ensure it returns correctly.

Use sxmodfqdn to correct user settings

Output of sxmodfqdn

[root@new ~]# sxmodfqdn 
usage:/opt/scalix/bin/sxmodfqdn -o oldfqdn -n newfqdn

The syntax in our example would then be sxmodfqdn -o old.scalix.demo -n new.scalix.demo

This command will rewrite the relevant parts of the user configuration to tell Scalix where to look for existing users' directory entries.

Change the configuration in /opt/scalix/

The file /opt/scalix/global/config contains the lines:

OMNAME=old
OMHOSTNAME=old.scalix.demo

These can be changed by hand to read:

OMNAME=new
OMHOSTNAME=new.scalix.demo

Change the configuration in /etc/opt/scalix-tomcat

There are several files to be changed in /etc/opt/scalix.

Grepping over the directory reveals that the following files currently contain the old fully qualified hostname:

[root@new ~]# grep -iRl old.scalix.demo /etc/opt/scalix-tomcat
/etc/opt/scalix-tomcat/connector/ajp/app-old.m.conf
/etc/opt/scalix-tomcat/connector/ajp/instance-old.conf
/etc/opt/scalix-tomcat/connector/ajp/app-old.api.conf
/etc/opt/scalix-tomcat/connector/ajp/app-old.res.conf
/etc/opt/scalix-tomcat/connector/ajp/app-old.sac.conf
/etc/opt/scalix-tomcat/connector/ajp/app-old.caa.conf
/etc/opt/scalix-tomcat/connector/ajp/app-old.sis.conf
/etc/opt/scalix-tomcat/connector/ajp/app-old.webmail.conf
/etc/opt/scalix-tomcat/connector/jk/instance-old.conf
/etc/opt/scalix-tomcat/ports

Each of these files needs to have the fully qualified hostname changed in one or more places. You can either do this by hand, or, if you're lazy like me, with a quick macro.

Use the following command:

grep -iRl old.scalix.demo /etc/opt/scalix-tomcat | while read line; do sed -i -e 's/old.scalix.demo/new.scalix.demo/g' $line; done

Replace both instances of old.scalix.demo with your old FQDN and the single instance of new.scalix.demo with your new FQDN.

What this does, is find each file with the old FQDN, globally replace each instance of the old FQDN with the new FQDN and save the file.

Change the configuration in /var/opt/scalix

Grepping through the directories you'll find various instances of your old servername, which need to be replaced with the new server name.

The following command may repair everything on a simple mail server, but your mileage may vary!! Don't use it unless you know what all the component parts do. Look for and change the files by hand in that case.

[root@new ~]# source /opt/scalix/global/config; for i in /var/opt/scalix/<instance_name>/* ; do \
if [ $i != $OMDATADIR ]; then grep -iRl old.scalix.demo $i 2>/dev/null| egrep -iv 'new.scalix.demo| \
logs|indexes|postgres/data'; fi;done | sed -i -e 's/old.scalix.demo/new.scalix.demo/g'

Most likely the files that need changing will be:

[root@new ~]# source /opt/scalix/global/config; for i in /var/opt/scalix/<instance_name>/* ; do \
if [ $i != $OMDATADIR ]; then grep -iR $OMHOSTNAME $i 2>/dev/null| egrep -iv 'logs|indexes|postgres/data'; \
fi; done
/var/opt/scalix/<instance_name>/caa/scalix.res/config/ubermanager.properties:ubermanager.query.server=new.scalix.demo
/var/opt/scalix/<instance_name>/caa/scalix.res/config/ubermanager.properties:ubermanager.console.localDomains=new.scalix.demo
/var/opt/scalix/<instance_name>/mobile/mobile.properties:platform.url=new.scalix.demo
/var/opt/scalix/<instance_name>/platform/platform.properties:imap.host=new.scalix.demo
/var/opt/scalix/<instance_name>/platform/platform.properties:smtp.host=new.scalix.demo
/var/opt/scalix/<instance_name>/platform/platform.properties:hibernate.connection.url = jdbc:postgresql://new.scalix.demo:5733/scalix
/var/opt/scalix/<instance_name>/res/config/res.properties:res.ubermanager.host=new.scalix.demo
/var/opt/scalix/<instance_name>/res/config/res.properties:res.kerberos.allowedclients=ubermanager/new.scalix.demo
/var/opt/scalix/<instance_name>/webmail/swa.properties:swa.email.domain=new.scalix.demo
/var/opt/scalix/<instance_name>/webmail/swa.properties:swa.email.imapServer=new.scalix.demo
/var/opt/scalix/<instance_name>/webmail/swa.properties:swa.email.smtpServer=new.scalix.demo
/var/opt/scalix/<instance_name>/webmail/swa.properties:swa.platform.url=http://new.scalix.demo:8080/api
/var/opt/scalix/<instance_name>/webmail/swa.properties:swa.ldap.1.server=new.scalix.demo
/var/opt/scalix/<instance_name>/webmail/swa.properties:swa.ldap.2.server=new.scalix.demo

Change SIS-URLs for users

Each user has a unique SIS-URL for the search and index services.

Take a look at yours using omshowu -n "Your Name"

It will look something like the following:

[root@new ~]# omshowu -n tester
Authentication ID: tester
Globally Unique ID: 1d100000d97e5164-041.261.961.18
User Name : tester /CN=tester
MailNode : demo,scalix
Internet Address : "tester" <tester@scalix.demo>
System Login : 60539
Password : set
Admin Capabilities : NO
Mailbox Admin Capabilities : NO
Language : C
Mail Account: Unlocked
Last Signon : Never.
Receipt of mail : ENABLED
Service level : 0
Excluded from Tidying : NO
Recovery Folder visible : NO
User Class : Full
SIS URL : sxidx://old.scalix.demo/0d100000d97e5164-041.261.961.18

The bottom URL needs to be changed to reflect the new hostname. The easiest way is probably as follows:

omshowu -m all| while read line; do ommodu "$line" --index `omshowu -n "$line"|grep -i sis|\
sed -e 's/^.*old.scalix.demo/sxidx:\/\/new.scalix.demo/g'`; done

Alternatively, you can manually cut and paste text around, and call ommodu by hand for each user. The goal is just to change the host name without changing the rest of the URL.

Your user should then look something like the following:

[root@new ~]# omshowu -n tester|egrep 'Auth|SIS'                  
Authentication ID: tester
SIS URL : sxidx://new.scalix.demo/0d100000d97e5164-041.261.961.18

Correct local mailnode mappings

remove mappings for local mailnodes with omdelmnmp "mailnode". Then, readd them with omaddmnmp mailnode hostname

For example:

[root@new ~]# omshowmnmp   
demo,scalix     old.scalix.demo
Disabling 1 subsystem(s).
Directory Relay Server      Stopped
Enabling 1 subsystem(s).
Directory Relay Server      Started
[root@new ~]# omshowmnmp        
No entries in mailnode mapping file
[root@new ~]# omaddmnmp demo,scalix new.scalix.demo   
Disabling 1 subsystem(s).
Directory Relay Server      Stopped
Enabling 1 subsystem(s).
Directory Relay Server      Started
[root@new ~]# omshowmnmp                        
demo,scalix     new.scalix.demo

Reboot and enjoy your server

After you have finished this procedure please reboot. Everything should be working just like before.

Do remember, however, that this discussion only covered Scalix. Things like apache VirtualHost declarations or other parts of the server which depend on the hostname will still need to be changed. And remember, what you just did was a bad idea.