Wednesday, November 27, 2013

Ejabberd13.10

Prepair the Ejabberd-Base Image

  • If you have already a Base-Image with security hardening and so on you can use this one to create the ejabberd-base
baseimageid=`aws --region us-west-2 ec2 describe-images  --owners self | grep -A 2 -i base-ami | grep -i imageid | cut -d '"' -f 4`
instance_size="t1.micro"
sshkeyname="myamazonkey"
securitygroup=`aws --region us-west-2 ec2 describe-security-groups | grep -A 3 -i ssh | grep -i groupid | cut -d '"' -f 4`
subnet=`aws --region us-west-2 ec2 describe-subnets | grep -i subnetid | head -n 1 | cut -d '"' -f 4`

aws ec2 --region us-west-2 run-instances --image-id $baseimageid --count 1 \
--key-name $sshkeyname --security-group-ids $securitygroup \
--instance-type $instance_size --subnet-id $subnet
  • when the instance is created you will get a instance-id, note it
instanceid="<insyance-id>"
name="<your-instance-name>"
allocid="<>"   #you can find free one with "aws --region us-west-2 ec2 describe-addresses" or create new one "aws --region us-west-2 ec2 allocate-address"

aws ec2 --region us-west-2 create-tags --resources $instanceid --tags Key=Name,Value=$name
aws ec2 --region us-west-2 associate-address --instance-id $instanceid --allocation-id $allocid
  • now we can ssh on it an start the base installation/configuration
  • First we need Erlang (you might want to look for the newest version http://www.erlang.org)
sudo apt-get update && sudo apt-get -y dist-upgrade && sudo reboot now
sudo apt-get install -y subversion gcc make libexpat1-dev zlib1g-dev libssl-dev libncurses5-dev fop openjdk-6-jdk unixodbc-dev g++ libwxbase2.8 libwxgtk2.8-dev libqt4-opengl-dev libgtk2.0-dev xsltproc git libyaml-dev libaio1
sudo su -
mkdir /usr/local/src/ejabberd && mkdir /usr/local/src/erlang
wget http://www.erlang.org/download/otp_src_R16B02.tar.gz -O - > /usr/local/src/erlang/otp_src_R16B02.tar.gz
cd /usr/local/src/erlang && gunzip -c otp_src_R16B02.tar.gz | tar xf -
cd otp_src_R16B02 && touch lib/wx/SKIP && ./configure && make && make install
  • Now everything is set to install Ejabberd-13.10
cd /usr/local/src/ejabberd/ && git clone git://github.com/rebar/rebar.git && cd rebar/
./bootstrap 
mv rebar /usr/local/bin/ && cp rebar.config /usr/local/bin/ && chmod +x /usr/local/bin/rebar && rebar -V
mv /home/peter/ejabberd-13.10.tgz /usr/local/src/ejabberd/ && cd /usr/local/src/ejabberd/
gunzip ejabberd-13.10.tgz && tar xf ejabberd-13.10.tar
groupadd -r ejabberd
useradd -g ejabberd -r ejabberd
cd ejabberd-13.10 && ./configure --enable-user=ejabberd --enable-odbc && make && make install
sed -i "s/home\/ejabberd/var\/lib\/ejabberd/g" /etc/passwd
cp /usr/local/src/ejabberd/ejabberd-13.10/ejabberd.init /etc/init.d/ejabberd && chmod +x /etc/init.d/ejabberd && update-rc.d ejabberd defaults
chmod 755 /sbin/ejabberdctl && chown -R ejabberd:root /var/lib/ejabberd && chmod 755 /var/lib/ejabberd
chown -R ejabberd:root /lib/ejabberd && chmod 755 /lib/ejabberd
chown ejabberd:ejabberd /var/lib/ejabberd/.erlang.cookie && chmod 400 /var/lib/ejabberd/.erlang.cookie
cd /usr/local/src/ejabberd && git clone https://github.com/processone/mysql && cd mysql
rebar compile && cp ebin/p1_mysql* /lib/ejabberd/ebin/
  • Here is what i used for the base configuration, you might want to change it and add additional tables to use mysql
sed -i '277 c\
odbc_type: mysql' /etc/ejabberd/ejabberd.yml && sed -i '278 c\
odbc_server: "localhost"' /etc/ejabberd/ejabberd.yml && sed -i '279 c\
odbc_database: "ejabberd"' /etc/ejabberd/ejabberd.yml && sed -i '280 c\
odbc_username: "ejabberd"' /etc/ejabberd/ejabberd.yml && sed -i '281 c\
odbc_password: "ejabberd"' /etc/ejabberd/ejabberd.yml && sed -i '204 c\
auth_method: odbc' /etc/ejabberd/ejabberd.yml && sed -i '183 c\
## auth_method: internal' /etc/ejabberd/ejabberd.yml && sed -i '62 c\
  - "chaatz.com"' /etc/ejabberd/ejabberd.yml && sed -i '525,534 c\
  mod_last:\
    db_type: odbc\
  mod_muc:\
    ## host: "conference.@HOST@"\
    access: muc\
    access_create: muc_create\
    access_persistent: muc_create\
    access_admin: muc_admin\
    max_users_admin_threshold: 100000\
    max_user_conferences: 100000\
    db_type: odbc\
  ## mod_muc_log: {}\
  mod_offline:\
    access_max_user_messages: max_user_offline_messages\
    db_type: odbc' /etc/ejabberd/ejabberd.yml && sed -i '512 c\
  mod_admin_extra: {}\
  mod_adhoc: {}' /etc/ejabberd/ejabberd.yml && sed -i '411 c\
    all: 3000 ' /etc/ejabberd/ejabberd.yml && sed -i '347,349 c\
  admin:\
    user:\
      - "admin": "domain.com"' /etc/ejabberd/ejabberd.yml && sed -i '338 c\
max_fsm_queue: 2000' /etc/ejabberd/ejabberd.yml && sed -i '332 c\
  fast: 100000' /etc/ejabberd/ejabberd.yml && sed -i '327 c\
  normal: 10000' /etc/ejabberd/ejabberd.yml
  • Lets create the new Base-Image for Ejabberd
aws --region us-west-2 ec2 create-image --instance-id $instanceid --name EJABBERD-BASE --no-reboot

[edit]Complete configuration after launching a Base-Image

echo "hostname.domain.com" > /etc/hostname && hostname -F /etc/hostname
echo "
# Ejabberd Localhost
"<you-ip>  <hostname.domainname.com>   <hostname>"
"127.0.1.1  <hostname.domainname.com>   <hostname>"
" >> /etc/hosts
echo "
# Ejabberd Node Config
INET_DIST_INTERFACE="<you-ip>"
" >> /etc/ejabberd/ejabberdctl.cfg

  • If you find how to DONT store passwords in plaintext in the database with 13.10 please tell me :)

No comments:

Post a Comment