Everything is running as user 'ad2usb', so create a local user and give them access to the serial lines.
- Code: Select all
sudo useradd -r -s /bin/false ad2usb
sudo addsuser ad2usb dialout
I first installed ser2sock and wrote an upstart file so that can launch on startup using the ad2usb user. Let me know if you want a copy of that file (or write your own init.d or systemd file depending on your OS). Use telnet to check that ser2sock is working and that you can receive and send commands to your panel.
The web app has a lot of hard coded paths and ports so I chose to install it in that location (/opt/alarmdecoder-webapp) though I did edit the code to use a different port number (22000). Just grep for 5000 in the python code to find the files that need to be modified to change the port.
- Code: Select all
# Get the web application source code
cd /opt
sudo git clone https://github.com/nutechsoftware/alarmdecoder-webapp.git
# Change the source to your local user - this makes it easier to edit and test until things are working.
sudo chown -R [USER] alarmdecoder-webapp
# Install the python dependencies using virtualenv to avoid conflicts with the system. This assumes you're using a bash shell.
cd /opt/alarmdecoder
sudo apt-get install python-virtualenv python-pip
virtualenv pyenv
. pyenv/bin/activate
pip install alarmdecoder
pip install gunicorn
pip install -r requirements.txt
# Create a script to run the server.
cat << EOF > run.sh
#!/bin/sh
cd /opt/alarmdecoder-webapp
. pyenv/bin/activate
gunicorn --name alarmdecoder \\
--worker-class=socketio.sgunicorn.GeventSocketIOWorker \\
--env=POLICY_SERVER=0 \\
--workers=1 \\
--log-file /var/log/alarmdecoder.log \\
--timeout=120 \\
wsgi:application
EOF
chmod a+x run.sh
# Initialize the database.
python manage.py initdb
# Try running in debug mode to make sure things work.
python manage.db run
firefox localhost:5000
# ctrl-c to kill the debug server above and try the run script
./run.sh
firefox localhost:5000
# Assuming all of that works fine, create an upstart/init.d/systemv file to execute run.sh as the ad2usb user
# Change the files to be owned by ad2usb
sudo chown -R ad2usb:dialout /opt/alarmdecoder-webapp
# Start the service (upstart). Errors can be found at /var/log/upstart/alarmdecoder-webapp.log
sudo service alarmdecoder-webapp start