Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add support for Raspberry Pi Zero 2 W #2111

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ansible/roles/network/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
- name: Enable network systemd services
ansible.builtin.systemd:
name: "{{ item }}"
state: started
enabled: true
state: stopped
enabled: false
with_items: "{{ network_systemd_units }}"

- name: Disable network manager
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/screenly/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
- name: Enable screenly systemd services
ansible.builtin.systemd:
name: "{{ item }}"
state: started
state: stopped
enabled: true
with_items: "{{ screenly_systemd_units }}"

Expand Down
63 changes: 0 additions & 63 deletions ansible/roles/system/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@
- name: Remove deprecated apt dependencies
ansible.builtin.apt:
name:
- dphys-swapfile
- lightdm
- lightdm-gtk-greeter
- matchbox
Expand All @@ -246,60 +245,6 @@
- xserver-xorg
state: absent

- name: Make sure distro package of Docker is absent
ansible.builtin.apt:
name:
- docker
- docker-engine
- docker.io
- containerd
- runc
- docker-compose
state: absent

- name: Add Docker apt key (x86)
ansible.builtin.apt_key:
url: https://download.docker.com/linux/debian/gpg
state: present
when: ansible_architecture == "x86_64"

- name: Add Docker apt key (Raspberry Pi)
ansible.builtin.apt_key:
url: https://download.docker.com/linux/raspbian/gpg
state: present
when: |
ansible_architecture == "aarch64" or
ansible_architecture == "armv7l" or
ansible_architecture == "armv6l"

- name: Get Debian name
ansible.builtin.command: lsb_release -cs
register: debian_name
changed_when: false

- name: Set architecture
ansible.builtin.set_fact:
architecture: "{{ 'amd64' if ansible_architecture == 'x86_64' else 'armhf' }}"

- name: Add Docker repo
ansible.builtin.lineinfile:
path: /etc/apt/sources.list.d/docker.list
create: true
line: "deb [arch={{ architecture }}] https://download.docker.com/linux/debian {{ debian_name.stdout }} stable"
state: present
owner: root
group: root
mode: "0644"

- name: Install Docker
ansible.builtin.apt:
name:
- docker-ce:{{ architecture }}
- docker-ce-cli:{{ architecture }}
- docker-compose-plugin:{{ architecture }}
update_cache: true
install_recommends: false

Comment on lines -249 to -302
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcrosson, I've created a PR (#2089, still in progress and being code-reviewed) for this so that arm64/aarch64 Docker will be installed instead.

- name: Add user to Docker group (all platforms)
ansible.builtin.user:
name: "{{ lookup('env', 'USER') }}"
Expand Down Expand Up @@ -377,11 +322,3 @@
mode: "0644"
owner: root
group: root

- name: Disable swap
ansible.builtin.command: /sbin/swapoff --all removes=/var/swap

- name: Remove swapfile from disk
ansible.builtin.file:
path: /var/swap
state: absent
9 changes: 2 additions & 7 deletions bin/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,6 @@ function install_ansible() {
function run_ansible_playbook() {
display_section "Run the Anthias Ansible Playbook"

sudo -u ${USER} ${SUDO_ARGS[@]} ansible localhost \
-m git \
-a "repo=$REPOSITORY dest=${ANTHIAS_REPO_DIR} version=${BRANCH} force=yes"
cd ${ANTHIAS_REPO_DIR}/ansible

if [ "$ARCHITECTURE" == "x86_64" ]; then
Expand All @@ -200,10 +197,6 @@ function run_ansible_playbook() {
function upgrade_docker_containers() {
display_section "Initialize/Upgrade Docker Containers"

wget -q \
"$GITHUB_RAW_URL/master/bin/upgrade_containers.sh" \
-O "$UPGRADE_SCRIPT_PATH"

sudo -u ${USER} \
DOCKER_TAG="${DOCKER_TAG}" \
"${UPGRADE_SCRIPT_PATH}"
Expand All @@ -212,6 +205,8 @@ function upgrade_docker_containers() {
function cleanup() {
display_section "Clean Up Unused Packages and Files"

sudo -E docker compose -f /home/${USER}/screenly/docker-compose.yml down

sudo apt-get autoclean
sudo apt-get clean
sudo docker system prune -f
Expand Down
7 changes: 4 additions & 3 deletions bin/upgrade_containers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# Export various environment variables
export MY_IP=$(ip -4 route get 8.8.8.8 | awk {'print $7'} | tr -d '\n')
TOTAL_MEMORY_KB=$(grep MemTotal /proc/meminfo | awk {'print $2'})
export VIEWER_MEMORY_LIMIT_KB=$(echo "$TOTAL_MEMORY_KB" \* 0.8 | bc)
export SHM_SIZE_KB="$(echo "$TOTAL_MEMORY_KB" \* 0.3 | bc | cut -d'.' -f1)"
export VIEWER_MEMORY_LIMIT_KB=$(echo "$TOTAL_MEMORY_KB" \* 0.6 | bc)
export SHM_SIZE_KB="$(echo "$TOTAL_MEMORY_KB" \* 0.25 | bc | cut -d'.' -f1)"

export GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)

Expand All @@ -26,7 +26,8 @@ elif grep -qF "Raspberry Pi 2" /proc/device-tree/model; then
export DEVICE_TYPE="pi2"
else
# If all else fail, assume pi1
export DEVICE_TYPE="pi1"
# TODO: If Raspberry Pi Zero, set DEVICE_TYPE to "pi3."
export DEVICE_TYPE="pi3" # TODO: Revert to "pi1"
fi

if [[ -n $(docker ps | grep srly-ose) ]]; then
Expand Down
79 changes: 60 additions & 19 deletions docker-compose.yml.tmpl
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
# vim: ft=yaml.docker-compose

services:
anthias-wifi-connect:
image: screenly/anthias-wifi-connect:${DOCKER_TAG}-${DEVICE_TYPE}
build:
context: .
dockerfile: docker/Dockerfile.wifi-connect
depends_on:
- anthias-viewer
environment:
PORTAL_LISTENING_PORT: 8000
CHECK_CONN_FREQ: 10
PORTAL_SSID: 'Anthias WiFi Connect'
DBUS_SYSTEM_BUS_ADDRESS: 'unix:path=/run/dbus/system_bus_socket'
network_mode: host
privileged: true
volumes:
- type: bind
source: /run/dbus/system_bus_socket
target: /run/dbus/system_bus_socket

anthias-server:
image: screenly/anthias-server:${DOCKER_TAG}-${DEVICE_TYPE}
build:
context: .
dockerfile: docker/Dockerfile.server
cpus: "0.25"
cpuset: "1"
blkio_config:
weight: 300
device_read_bps:
- path: /dev/mmcblk0
rate: '5mb'
device_write_bps:
- path: /dev/mmcblk0
rate: '1024k'
environment:
- MY_IP=${MY_IP}
- HOST_USER=${USER}
Expand All @@ -50,6 +41,16 @@ services:
build:
context: .
dockerfile: docker/Dockerfile.viewer
cpus: "0.5"
cpuset: "1"
blkio_config:
weight: 300
device_read_bps:
- path: /dev/mmcblk0
rate: '5mb'
device_write_bps:
- path: /dev/mmcblk0
rate: '1024k'
mem_limit: ${VIEWER_MEMORY_LIMIT_KB}k
depends_on:
- anthias-server
Expand Down Expand Up @@ -77,6 +78,16 @@ services:
build:
context: .
dockerfile: docker/Dockerfile.websocket
cpus: "0.25"
cpuset: "1"
blkio_config:
weight: 300
device_read_bps:
- path: /dev/mmcblk0
rate: '5mb'
device_write_bps:
- path: /dev/mmcblk0
rate: '1024k'
depends_on:
- anthias-server
environment:
Expand All @@ -95,6 +106,16 @@ services:
build:
context: .
dockerfile: docker/Dockerfile.celery
cpus: "0.25"
cpuset: "1"
blkio_config:
weight: 300
device_read_bps:
- path: /dev/mmcblk0
rate: '5mb'
device_write_bps:
- path: /dev/mmcblk0
rate: '1024k'
depends_on:
- anthias-server
- redis
Expand All @@ -119,6 +140,16 @@ services:
build:
context: .
dockerfile: docker/Dockerfile.redis
cpus: "0.25"
cpuset: "1"
blkio_config:
weight: 300
device_read_bps:
- path: /dev/mmcblk0
rate: '5mb'
device_write_bps:
- path: /dev/mmcblk0
rate: '1024k'
ports:
- 127.0.0.1:6379:6379
restart: always
Expand All @@ -130,6 +161,16 @@ services:
build:
context: .
dockerfile: docker/Dockerfile.nginx
cpus: "0.25"
cpuset: "1"
blkio_config:
weight: 300
device_read_bps:
- path: /dev/mmcblk0
rate: '5mb'
device_write_bps:
- path: /dev/mmcblk0
rate: '1024k'
ports:
- 80:80
environment:
Expand Down
Loading