Skip to content

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
vpetersson committed Jul 3, 2017
2 parents bd6309e + 372f7d9 commit 02543d2
Show file tree
Hide file tree
Showing 38 changed files with 4,463 additions and 735 deletions.
14 changes: 11 additions & 3 deletions .travis.yml
Expand Up @@ -2,32 +2,40 @@ language: python
python:
- "2.7"
addons:
firefox: "45.0"
apt:
packages:
- net-tools
- mplayer
- python-setuptools
install:
- pip install -U pip
- pip install -r requirements.txt
- pip install -r requirements.dev.txt
before_script:
- mkdir -p ~/.screenly ~/.config/uzbl/
- mkdir -p ~/.screenly ~/.config/uzbl/ ~/screenly_assets
- cp ansible/roles/screenly/files/uzbl-config ~/.config/uzbl/config-screenly
- cp ansible/roles/screenly/files/screenly.conf ~/.screenly/
- cp ansible/roles/screenly/files/screenly.db ~/.screenly/
- cp ansible/roles/screenly/files/screenly_utils.sh /tmp/screenly_utils.sh
- echo -e "[local]\nlocalhost ansible_connection=local" > ansible/localhost
- curl https://www.screenly.io/upload/ose-logo.png > /tmp/image.png
- curl https://www.screenly.io/upload/ose_tests/little_buck_bunny_trailer_480p.mov > /tmp/video.mov
- curl https://www.screenly.io/upload/ose-logo.png > ~/screenly_assets/image.tmp
- curl https://www.screenly.io/upload/big_buck_bunny_720p_10mb.flv > /tmp/video.flv
- export DISPLAY=:99.0
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16
- python tests/rtmplite/rtmp.py -r /tmp/ &
- sleep 3
- python server.py &
- sleep 3 # give xvfb some time to start

script:
- find . -name \*.py -exec pep8 --ignore=E402,E501,E731 {} +
- find . ! -path "*/rtmplite/*" -name \*.py -exec pep8 --ignore=E402,E501,E731 {} +
- nosetests -v -a '!fixme' --with-isolation
- ansible-playbook --syntax-check -i ansible/localhost ansible/site.yml
- python -m SimpleHTTPServer 8080 &
- sleep 3
- bash static/spec/runner.sh

sudo: false
dist: trusty
7 changes: 4 additions & 3 deletions Dockerfile
@@ -1,13 +1,14 @@
FROM debian:jessie
MAINTAINER Viktor Petersson <vpetersson@wireload.net>
MAINTAINER Viktor Petersson <vpetersson@screenly.io>

RUN apt-get update && \
apt-get -y install git-core net-tools python-pip python-netifaces python-simplejson python-imaging python-dev sqlite3 libffi-dev libssl-dev && \
apt-get -y install build-essential git-core net-tools python-netifaces python-simplejson python-imaging python-dev sqlite3 libffi-dev libssl-dev curl mplayer && \
apt-get clean

# Install Python requirements
ADD requirements.txt /tmp/requirements.txt
RUN pip install -r /tmp/requirements.txt
RUN curl -s https://bootstrap.pypa.io/get-pip.py | python && \
pip install -r /tmp/requirements.txt

# Create runtime user
RUN useradd pi
Expand Down
11 changes: 7 additions & 4 deletions README.md
@@ -1,5 +1,5 @@
[![Build Status](https://travis-ci.org/wireload/screenly-ose.svg?branch=master)](https://travis-ci.org/wireload/screenly-ose)
[![Coverage Status](https://coveralls.io/repos/wireload/screenly-ose/badge.svg?branch=master&service=github)](https://coveralls.io/github/wireload/screenly-ose?branch=master)
[![Build Status](https://travis-ci.org/screenly/Screenly-ose.svg?branch=master)](https://travis-ci.org/Screenly/screenly-ose)
[![Coverage Status](https://coveralls.io/repos/Screenly/screenly-ose/badge.svg?branch=master&service=github)](https://coveralls.io/github/Screenly/screenly-ose?branch=master)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/dfbdedc7a56c4589b931b40ee77e8d9f)](https://www.codacy.com/app/renat-2017/screenly-ose?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=wireload/screenly-ose&amp;utm_campaign=Badge_Grade)

# Screenly OSE - Digital Signage for the Raspberry Pi
Expand All @@ -14,9 +14,12 @@ $ bash <(curl -sL https://www.screenly.io/install-ose.sh)

To learn more about Screenly, please visit the official website at [Screenly.io](http://www.screenly.io). On the official site, you'll find the complete installation instructions and disk images.

[![An introduction to digital signage with Screenly OSE](http://img.youtube.com/vi/FQte5yP0azE/0.jpg)](http://www.youtube.com/watch?v=FQte5yP0azE)

Quick links:

* [FAQ](https://www.screenly.io/faq/ose/)
* [FAQ](https://support.screenly.io/hc/en-us/sections/202652366-Frequently-Asked-Questions-FAQ-)
* [Support Forum](https://support.screenly.io)
* [Screenly OSE Home](https://www.screenly.io/ose/)
* [Live Demo](http://ose.demo.screenlyapp.com/)
* [QA Checklist](https://www.forgett.com/checklist/1789089623)
Expand All @@ -33,7 +36,7 @@ Assuming you're in the source code repository, simply run:
$ docker run --rm -ti \
-p 8080:8080 \
-v $(pwd):/home/pi/screenly \
wireload/screenly-ose-server
screenly/ose-dev-server
```

## Running the Unit Tests
Expand Down
19 changes: 2 additions & 17 deletions ansible/roles/network/files/network.ini-sample
@@ -1,33 +1,18 @@
; Screenly network configuration


; This is how a static network configuration
; for wired networking would look like this.
; Read more here:
; https://www.screenlyapp.com/faq/pro.html#static_ip
; To generate your own network.ini file, visit:
; https://wizard.screenly.io

;[eth0]
;mode=static
;ip=192.168.1.10
;netmask=255.255.255.0
;gateway=192.168.1.1


; If you want to configure your WLAN with DHCP,
; the configuration would look something like this.
; Read more here:
; https://support.screenly.io/hc/en-us/articles/212107126-Can-I-use-a-WiFi-adapter-with-Screenly-Pro-

;[wlan0]
;ssid=NameOfYourNetwork
;passphrase=YourNetworkPassword


; You may also want to explicitly set
; the DNS and ntp servers as follows.
; Read more here:
; https://www.screenlyapp.com/faq/pro/#custom_ntp

;[generic]
;dns=8.8.8.8,8.8.4.4
;ntp=0.pool.ntp.org,1.pool.ntp.org
57 changes: 21 additions & 36 deletions ansible/roles/network/files/screenly_net_mgr.py
Expand Up @@ -28,6 +28,7 @@ def if_config(
ssid=None,
passphrase=None,
hidden_ssid=False,
dns=None,
):
if not interface:
raise ValueError
Expand All @@ -52,13 +53,16 @@ def if_config(
interface_stanza += '\n wireless-power off'

if ssid:
interface_stanza += '\n wpa-ssid "{}"'.format(ssid)
interface_stanza += '\n wpa-ssid {}'.format(ssid)
if passphrase:
interface_stanza += '\n wpa-psk "{}"'.format(passphrase)
interface_stanza += '\n wpa-psk {}'.format(passphrase)
if hidden_ssid:
if str(hidden_ssid).lower() in ['true', 'yes', 'on', '1']:
interface_stanza += '\n wpa-ap-scan 1\n wpa-scan-ssid 1'

if dns:
interface_stanza += '\n dns-nameservers {}'.format(dns)

# Make sure we end with a newline
interface_stanza += '\n'

Expand Down Expand Up @@ -99,27 +103,6 @@ def generate_ntp_conf(ntpservers=[
return ntp_conf


def generate_resolv_conf(dns=[
'8.8.8.8',
'8.8.4.4'
]):
"""
Generates a `resolv.conf` file.
:param dns: DNS servers (list)
"""

if not isinstance(dns, list):
logging.error('"{}" is an invalid DNS option.'.format(dns))
return False

resolv_file = "# Generated by Screenly Network Manager\n"

for i in dns:
resolv_file += 'nameserver {}\n'.format(i.lower())

return resolv_file


def write_file(path, content):

with open(path, 'r') as f:
Expand Down Expand Up @@ -194,11 +177,16 @@ def main():
ethernet = get_active_iface(config, 'eth')
wifi = get_active_iface(config, 'wlan')

if config.has_option('generic', 'dns'):
dns = config['generic']['dns']
else:
dns = None

if ethernet:
ethernet_dhcp = is_dhcp(config, ethernet)

if ethernet_dhcp:
interfaces += if_config(interface=ethernet)
interfaces += if_config(interface=ethernet, dns=dns)
else:
ethernet_ip = lookup(config, ethernet, 'ip')
ethernet_netmask = lookup(config, ethernet, 'netmask')
Expand All @@ -208,7 +196,8 @@ def main():
interface=ethernet,
ip=ethernet_ip,
netmask=ethernet_netmask,
gateway=ethernet_gateway
gateway=ethernet_gateway,
dns=dns,
)

if wifi:
Expand All @@ -223,6 +212,7 @@ def main():
ssid=ssid,
passphrase=passphrase,
hidden_ssid=hidden_ssid,
dns=dns,
)
else:
wifi_ip = lookup(config, wifi, 'ip')
Expand All @@ -237,20 +227,15 @@ def main():
ssid=ssid,
passphrase=passphrase,
hidden_ssid=hidden_ssid,
dns=dns,
)

write_file(INTERFACES_PATH, interfaces)

"""
Configure DNS
"""
# In case neither wired or wireless is configured,
# let's just assume wired and dhcp as the default.
if not (wifi or ethernet):
interfaces += if_config(interface='eth0', dns=dns)

if config.has_option('generic', 'dns'):
resolv_conf = generate_resolv_conf(config['generic']['dns'].split(','))
if resolv_conf:
write_file(RESOLV_PATH, resolv_conf)
else:
logging.error('Unable to read DNS settings.')
write_file(INTERFACES_PATH, interfaces)

"""
Configure NTP
Expand Down
46 changes: 19 additions & 27 deletions ansible/roles/network/files/test_screenly_net_mgr.py
Expand Up @@ -62,7 +62,7 @@ def test_wlan0_dhcp_no_passphrase():
auto wlan0
iface wlan0 inet dhcp
wireless-power off
wpa-ssid "foobar"
wpa-ssid foobar
""")


Expand All @@ -75,8 +75,8 @@ def test_wlan0_dhcp_with_passphrase():
auto wlan0
iface wlan0 inet dhcp
wireless-power off
wpa-ssid "foobar"
wpa-psk "password"
wpa-ssid foobar
wpa-psk password
""")


Expand All @@ -89,8 +89,8 @@ def test_wlan1_dhcp_with_passphrase():
auto wlan1
iface wlan1 inet dhcp
wireless-power off
wpa-ssid "foobar"
wpa-psk "password"
wpa-ssid foobar
wpa-psk password
""")


Expand All @@ -109,8 +109,8 @@ def test_wlan0_static_with_passphrase():
netmask 255.255.255.0
gateway 192.168.10.1
wireless-power off
wpa-ssid "foobar"
wpa-psk "password"
wpa-ssid foobar
wpa-psk password
""")


Expand All @@ -124,37 +124,29 @@ def test_wlan0_dhcp_with_hidden_ssid():
auto wlan0
iface wlan0 inet dhcp
wireless-power off
wpa-ssid "foobar"
wpa-psk "password"
wpa-ssid foobar
wpa-psk password
wpa-ap-scan 1
wpa-scan-ssid 1
""")


def test_resolv_conf_without_options():
eq_(screenly_net_mgr.generate_resolv_conf(), """# Generated by Screenly Network Manager
nameserver 8.8.8.8
nameserver 8.8.4.4
""")


def test_resolv_conf_with_one_option():
eq_(screenly_net_mgr.generate_resolv_conf(dns=['1.2.3.4']), """# Generated by Screenly Network Manager
nameserver 1.2.3.4
def ifconfig_with_one_dns_server():
eq_(screenly_net_mgr.if_config(interface='eth0', dns='1.2.3.4'), """
auto eth0
iface eth0 inet dhcp
dns-nameservers 1.2.3.4
""")


def test_resolv_conf_with_two_options():
eq_(screenly_net_mgr.generate_resolv_conf(dns=['1.1.1.1', '2.2.2.2']), """# Generated by Screenly Network Manager
nameserver 1.1.1.1
nameserver 2.2.2.2
def ifcconfig_with_two_dns_servers():
eq_(screenly_net_mgr.if_config(interface='eth0', dns='1.1.1.1, 2.2.2.2'), """
auto eth0
iface eth0 inet dhcp
dns-nameservers 1.2.3.4, 2.2.2.2
""")


def test_resolv_conf_with_invalid_input():
eq_(screenly_net_mgr.generate_resolv_conf(dns='foobar'), False)


def test_ntp_conf_without_options():
ntp_conf = NTP_CONF_STANZA
for n in range(0, 3):
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/network/tasks/main.yml
Expand Up @@ -36,7 +36,7 @@
group: root
mode: 0644
src: network.ini-sample
dest: /boot/network.ini
dest: /boot/network.ini-sample

- name: Activate network manager
command: systemctl enable screenly-net-manager.service chdir=/etc/systemd/system
Expand Down
10 changes: 9 additions & 1 deletion ansible/roles/screenly/files/screenly.conf
Expand Up @@ -15,11 +15,19 @@ audio_output = hdmi
; Shuffle playlist before playing (otherwise sorted by name)
shuffle_playlist = False

; Asset duration default value
; Stream asset duration default value (seconds)
default_streaming_duration = 300

; Asset duration default value (seconds)
default_duration = 10

; Debug logging toggle
debug_logging = False

; Only display pages with proper SSL certificates
verify_ssl = True

[auth]
; If desired, fill in with appropriate username and password.
user=
password=
1 change: 1 addition & 0 deletions ansible/roles/screenly/files/screenly_overrides
@@ -0,0 +1 @@
pi ALL=NOPASSWD:/usr/local/bin/screenly_utils.sh

0 comments on commit 02543d2

Please sign in to comment.