Installation

This document will show you how to get up and running with Trunk Player.

Currently install is based on a Debian like system, Ubuntu.

System Prerequisites

Using apt-get

$ sudo apt-get install python3-dev virtualenv redis-server python3-pip postgresql libpq-dev postgresql-client postgresql-client-common git

Assumptions

  • Project directory is /home/radio/trunk-player - You can replace /home/radio with your own home directory.
  • Redis is running and listening on default port of :6379

Getting Trunk Player

The source is on GitHub, use git to clone the repository. Starting from your home directory of /home/radio

$ git clone https://github.com/ScanOC/trunk-player.git

This will pull down the most current version of Trunk Player.

Setup Virtual Environment

Setup a new Python 3.x virtual environment in the env direcory. Set the visual prompt to (Trunk Player).

$ cd trunk-player
$ virtualenv -p python3 env --prompt='(Trunk Player)'

Activate Virtual Environment

You will need to re run this step each time you start a new shell or log into your machine.

$ source env/bin/activate

This will set you into a new python environment any packages you install via pip will only live in this area and do not touch your system files. This allowed you to have multiple projects with different dependencies.

You can use the command deactivate to exit back to your normal system environment.

Install Python Packages

Using pip install all required packages from the requirements.txt file.

(Trunk Player)$ pip install -r requirements.txt

Configure for first use

You will need to setup a local version of the setting.py file, create and initialize the database, and create a default admin account.

Local settings file

You will need to create a local settings file to override any settings in the trunk_player/settings.py file. This will allow you to pull down updates from GitHub without losing your local settings.

Make a copy of the sample local settings file

(Trunk Player)$ cp trunk_player/settings_local.py.sample trunk_player/settings_local.py

Important You need to set/change the SECRET_KEY in the trunk_player/settings_local.py. This value is used to protect sensitive data like passwords. If you keep the one from the project a bad actor may be able to compromise your site or worse your server. See the django project about SECRET_KEY.

Configure Postgres Database

You need to create a postgres user that has full access to your database.

Logged into your postgres database as an admin user

$ sudo su - postgres
(postgres)$ psql

Create your user (trunk_player_user, with pass CHANGE_ME)

postgres=# CREATE USER trunk_player_user WITH PASSWORD 'CHANGE_ME';

Create your database named trunk_player

postgres=# CREATE DATABASE trunk_player;

Allow your user full control of the new DB

postgres=# GRANT ALL PRIVILEGES ON DATABASE trunk_player TO trunk_player_user;

Configure some settings as recomended by Django

ALTER ROLE trunk_player_user SET client_encoding TO 'utf8';
ALTER ROLE trunk_player_user SET default_transaction_isolation TO 'read committed';
ALTER ROLE trunk_player_user SET timezone TO 'UTC';

Exit from postgres and back to your user

postgres=# \q
(postgres)$ exit
$

Edit the trunk_player/settings_local.py and configure the DATABASES to match your server/username/passwords.

Initialize the database

Using the django manage.py command to build the new database.

(Trunk Player)$ ./manage.py migrate

Create admin account

(Trunk Player)$ ./manage.py createsuperuser
Username: test
Email address: test@sample.com
Password: mypassword
Password (again): mypassword
Superuser created successfully.

Starting the test web server

First note this is not full producation ready server. It can handle a couple users.

Using the manage.py command agian

(Trunk Player)$ ./manage.py runserver

This will start the server up listening on the local loopback address on port 8000. Start your web browser and go to http://localhost:8000. You should seen the main page Visit /admin/ to log into the admin area.

If you are running this on a remote server you need to have the web server us its’ public IP adress so you can connect.

(Trunk Player)$ ./manage.py runserver 0.0.0.0:8000

This will run the server also on port 8000 but will be accessible via the servers IP address or dns name on port 8000 also.