Skip to content

Installation

Jérôme Mouneyrac edited this page May 2, 2013 · 53 revisions

Recommandations

It's highly recommended to setup [Isolated Python Environments](Isolated Python Environments) instead of installing python packages in system level.

Debian / Ubuntu

(Credits to Jerome Mouneyrac)

Install Python packages

sudo apt-get install python-pip python-dev build-essential
sudo easy_install -U pip
sudo pip install --upgrade pip

Install MongoDB

sudo apt-get install mongodb

Create directories to store certificates and private keys

sudo mkdir -p /var/airnotifier/files

Git clone AirNotifier app

git clone git://github.com/dongsheng/airnotifier.git airnotifier
cd airnotifier
sudo pip install -r requirements.txt

Setup AirNotifier

Copy airnotifier.conf-sample to airnotifier.conf, and change the settings accorddingly.

Run the command below to set up the initial admin user:

python install.py

Set up IPTables rules

sudo vim /etc/iptables.up.rules

Add:

-A INPUT -p tcp -m state --state NEW,ESTABLISHED -s YOUR_SERVER_IP -d YOUR_SERVER_IP --dport 27017 -j ACCEPT
-A INPUT -p tcp -m state --state NEW --dport 8801 -j ACCEPT
sudo /sbin/iptables -F
sudo /sbin/iptables-restore < /etc/iptables.up.rules

Start AirNotifier app

sudo python airnotifier.py >> airnotifier.log 2>> airnotifier.err &

Note: the server will start in the background (so the server doesn't get kill once the terminal is closed) . The log will be saved in airnotifier.log (you want a cron to clean it time to time as it's currently dev logging). To kill the process, run 'top' and kill the python job (hopefully you'll run only one python job).

Alternative to find the process running it:

ps -ef | grep python

Set up AirNotifier

  1. In your browser: http://YOUR_SERVER_IP:8801 - Connect as admin/admin
  2. Create a new application
  3. In the application page you need to upload the certificate + key. Follow the steps indicated in developer.apple.com to create a new Development Push Notification certificate. To summarize, in keychain you'll create a signing request file (it will also generate a public and private key) and upload it to developer.apple.com.
  4. Download the generated apnscertificate.cer and double click on it to install it in keychain.
  5. Convert the apnscertificate.cer file into apnscertificate.pem file
openssl x509 -in apnscertificate.cer -inform der -out apnscertificate.pem
  1. From keychain export the private key in privatekey.p12 (you'll need to enter an export password). This private key has for name what you enter as "Common name" in during the signing request generation,
  2. Extract the key from this p12 file:
openssl pkcs12 -in privatekey.p12 -nocerts -out privatekey.key

You'll have to enter the export password and add a new PEM phrase. 8. Remove the PEM phrase from the key:

openssl rsa -in privatekey.key -out privatekey.key
  1. Upload both apnscertificate.pem and privatekey.key to AirNotifier.
  2. Launch the server, no error message should appear.

Potential errors:

  • The APNS connection loop as "appname is online"/"appname is offline" => check that you are in Sandbox mode if you are using a development certificate.
  • You have an SSL PEM something error => confirm that your certificate is a pem (not a cert). See above instructions.

Mac OSX

  1. Install Homebrew:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
  1. Install python, pip, mongodb, airnotifier These are the command lines that I executed to install the all thing on my Mac. Change jerome by your Mac username. Obviously it's not the best way (twice running python install, probably unuseful pip upgrade, chown on /usr/local/lib), but I confirm it works in this order.
brew install python
sudo chown -R jerome /usr/local/lib
brew link sqlite
brew install mongodb
pip install --upgrade distribute
pip install --upgrade pip
brew linkapps
ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
sudo mkdir /var/airnotifier
sudo mkdir /var/airnotifier/files
chown -R jerome /var/airnotifier/
cd ~/Applications/
git clone git://github.com/dongsheng/airnotifier.git airnotifier
cd airnotifier
sudo easy_install -U pip
sudo pip install -r requirements.txt
cp airnotifier.conf-sample airnotifier.conf
python install.py
python airnotifier.py
  1. The setup process is similar to the one explained for Ubuntu.

Testing that it works

  1. In the web interface, create an access keys for testing. Give it all permissions. It's not good behavior but for testing it's ok.
  2. Do some curl calls. Go to https://github.com/dongsheng/airnotifier/tree/master/test, open one of the curl test, modify it to match your installation. You have done your first API call. Well done!
Clone this wiki locally