From Scalix Wiki
Revision as of 15:17, 23 March 2012 by MediaWiki spam cleanup (Talk | contribs) (Reverted edits by Boreli (Talk) to last version by Ltward)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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

Changing the Hostname of a Scalix Server

Scalix Server is quite dependent on correct hostnames throughout it's configuration. For this reason, we recommend to keep the system's hostname if at all possible. For changing the hostname when it cannot be avoided, 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:


These can be changed by hand to read:


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

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 \
    sed -i -e 's/old.scalix.demo/new.scalix.demo/g' \
      `grep -iRl old.scalix.demo $i 2>/dev/null \
       | egrep -iv 'new.scalix.demo|logs|indexes|postgres/data' \
       | xargs`; fi; done

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>/platform/ = jdbc:postgresql://new.scalix.demo:5733/scalix

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
[root@new ~]#
[root@new ~]# omdelmnmp scalix,demo
Disabling 1 subsystem(s).
Directory Relay Server      Stopped
Enabling 1 subsystem(s).
Directory Relay Server      Started
[root@new ~]#
[root@new ~]# omshowmnmp
No entries in mailnode mapping file
[root@new ~]#
[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 ~]#
[root@new ~]# omshowmnmp
demo,scalix     new.scalix.demo

If you have very many mailnodes, as will be the case in a hosted installation, you could run a command similar to

[root@new~]# omshowmnmp | awk '{ print $1 }' | while read mn do; omdelmnmp "$line"; omaddmnmp "$line" new.scalix.demo; done

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.