-
-
Notifications
You must be signed in to change notification settings - Fork 191
Installation
It's highly recommended to setup [Isolated Python Environments](Isolated Python Environments) instead of installing python packages in system level.
(Credits to Jerome Mouneyrac)
sudo apt-get install python-pip python-dev build-essential
sudo easy_install -U pip
sudo pip install --upgrade pip
sudo apt-get install mongodb
sudo mkdir -p /var/airnotifier/files
git clone git://github.com/dongsheng/airnotifier.git airnotifier
cd airnotifier
sudo pip install -r requirements.txt
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
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
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
- In your browser: http://YOUR_SERVER_IP:8801 - Connect as admin/admin
- Create a new application
- 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.
- Download the generated
apnscertificate.cer
and double click on it to install it in keychain. - Convert the
apnscertificate.cer
file intoapnscertificate.pem
file
openssl x509 -in apnscertificate.cer -inform der -out apnscertificate.pem
- 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, - 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
- Upload both
apnscertificate.pem
andprivatekey.key
to AirNotifier. - Launch the server, no error message should appear.
- The APNS connection loop as "appname is online"/"appname is offline" => in the Airnotifier application setting page, check that the Production mode is Sandbox if you are using a development certificate.
- You have an SSL PEM something error => check that your certificate is a .pem (not a .cer). See above instructions.
- Install Homebrew:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
- 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
- The setup process is similar to the one explained for Ubuntu.
- 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.
- 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!