Install Diaspora one Centos 6.4 with Apache

So Im going to test diaspora on one of my virtual server with run centos 6.4.

Setup Centos

Setup Repos

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm"

Install packages

yum install tar make automake gcc gcc-c++ git net-tools libcurl-devel libxml2-devel libffi-devel libxslt-devel tcl redis ImageMagick npm mysql-server mysql-devel httpd mod_ssl libyaml libyaml-devel patch readline-devel libtool bison

Start services

chkconfig --level 3 httpd on
chkconfig --level 3 mysqld on
chkconfig --level 3 redis on

 

service mysqld start
service httpd start
service redis start

 

Install Diaspora

adduser diaspora
su diaspora

Install ruby

\curl -L https://get.rvm.io | bash -s stable
source /home/diaspora/.rvm/scripts/rvm
 rvm autolibs read-only
rvm install 1.9.3-p448
git clone -b master git://github.com/diaspora/diaspora.git
cd diaspora <-- press y

Configure Mysql

Run this in mysql

Create database diaspora;
CREATE USER 'diaspora'@'localhost' IDENTIFIED BY 'some_pass@diaspora';
GRANT ALL PRIVILEGES ON diaspora.* TO 'diaspora'@'localhost';
 

 

Configure Diaspora

 

cp config/diaspora.yml.example config/diaspora.yml
cp config/database.yml.example config/database.yml

Set up your mysql settings in configure/diaspora.yml

Set up the diaspora.yml with you settings. This is the settings I enabled

url: "https://pod.ztekarna.com"
certificate_authorities: '/etc/pki/tls/certs/ca-bundle.crt'
rails_environment: 'production'
database: 'mysql'
unicorn_worker: 2
pod_name: "Ztekarna"
enable_registrations: true
autofollow_on_join_user: 'diasporahq@joindiaspora.com'
open: true
count: 25
suggest_email: 'admin@ztekarna.com'
enable: true
sender_address: 'no-reply@ztekarna.com'
method: 'smtp'
host: 'localhost'
 port: 25

 

Run diaspora setup

RAILS_ENV=production bundle install --without test development
RAILS_ENV=production bundle exec rake db:create db:schema:load

Start Diaspora

./script/server

Setup Apache config

Use this config for setting up apache

https://gist.github.com/MrZYX/719014

I now for testing use the ssl keys in /etc/pki/tls but for production you should use sign keys.

DONE !

No when diaspora is started you can visit your url and start using Diaspora

 

Starting diaspora then

install screen

yum install screen

Then to start diaspora run

screen
su diaspora
source /home/diaspora/.rvm/scripts/rvm
./script/server
ctr+d

More reading

https://gist.github.com/MrZYX/719014

https://wiki.diasporafoundation.org/Installation/CentOS/6

https://wiki.diasporafoundation.org/Main_Page

Custom nagios plugins in python

For monitoring different service and function you may need to build some custom monitoring plugins. I have some build for nrpe and will work with both nagios and icinga.
This script will do and mysql check and then send the data back and also start graphing the data back if you use pnp4nagios 🙂

Every plugin must have two things.

1. an exit code thet will say the state of the plugin (OK.Critical,warning) <- this will generate the alerts

  • 1 = ok
  • 2= Critical
  • 3=Warnings
  • 4= unknown

 

2. Some text to abaout the plugin saying for exampel disk space.

 

Here below is my small script that will de some db qestions ans return the result to nagios. If the values return is under 0 then it will exit in state 2 and then nagios will alert.

 

#!/usr/bin/env python
#Mysql stats
#Get stats from mysql server
#then prints the stats to icinga to process
import MySQLdb
from datetime import date, timedelta
import datetime
import sys
'''
MYSQL
'''
mysqlhost="localhost"
mysqluser="monitor"
mysqlpass="XXXXXXX"
mysqldb="db"
def mysql_query(sql):
 '''
 run an mysql mysql_query
 '''
 try:
 con = None
 con = MySQLdb.Connection(mysqlhost, mysqluser,
 mysqlpass, mysqldb)
 curs = con.cursor()
 curs.execute(sql)
 con.commit()
 back=[]
 for value in curs:
 back.append(value[0])
 return back
 except MySQLdb.Error, e:
 print "Error in MYSQL {0} : {1}".format(e.args[0], e.args[1])
 sys.exit(1)
 finally:
 if con:
 con.close()

#mysql to run on the mysql server
qery="""SELEC your own super mysql qery and the group by"""

#Send mysql to server
back =mysql_query(qery)

#Testing result and building string back to nagios
if back[0] <= 30:
 print "CRITICAL | 'value'="+str(back[0])+" 'value'="+str(back[1])
 sys.exit(2)
else:
 print "OK: | 'value'="+str(back[0])+" 'value'="+str(back[1])
 sys.exit(0)

Rolling back Andrioid on your Nexus 4 after Ubuntu

So i had to roll back to andriod. ubunut is not realy ready for my phone.
So this is how you do.

1. download you andriod images from here

https://developers.google.com/android/nexus/images#nakasi

Download and untar in nice folder.

2. Connect with USB to phone and power it on (Booting to ubuntu is ok)

run

adb reboot-bootloader

This will make the phone go into boot image.

 

3. Install andriod

in the folder that the downloadin andriod image is in run

sudo ./flash-all.sh

 

4. All Done

So now you have you phone back to running andriod. You can look down the boot images but i did not 🙂

 

2013-11-04 10.33.26
2013-11-04 10.37.16
2013-11-04 10.36.11