Skip to content

Commit

Permalink
Move TinyPilot systemd service to Debian package (#1506)
Browse files Browse the repository at this point in the history
Resolves #1430

Notes
1. The TinyPilot systemd service config template has been converted into
a static file and the Jinja2 variables has been inlined. Specifically:
    * `tinypilot_user`
    * `tinypilot_dir `
2. The following Ansible variables have been dropped because they are no
longer being used:
    * `tinypilot_user`
    * `tinypilot_group`
    * `tinypilot_dir`
    * `tinypilot_privileged_dir `
4. All the `ansible-role` handlers have also been dropped because they
are no longer used

You can test this PR on a device using:
```bash
curl \
  --silent \
  --show-error \
  --location \
  https://raw.githubusercontent.com/tiny-pilot/tinypilot/master/scripts/install-bundle | \
  sudo bash -s -- \
    https://output.circle-artifacts.com/output/job/bde586ac-7a10-42ec-bb6f-2cb293915cae/artifacts/0/bundler/dist/tinypilot-community-20230719T1211Z-1.9.0-35+768bef5.tgz
```

<a data-ca-tag
href="https://codeapprove.com/pr/tiny-pilot/tinypilot/1506"><img
src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review
on CodeApprove" /></a>
  • Loading branch information
jdeanwallace authored Jul 19, 2023
1 parent ec45ba7 commit 964afb7
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 44 deletions.
1 change: 0 additions & 1 deletion ansible-role/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
# Specifies the filesystem path or URL of a Debian package that installs
# TinyPilot.
tinypilot_debian_package_path: null
tinypilot_enable_debug_logging: no
10 changes: 0 additions & 10 deletions ansible-role/handlers/main.yml

This file was deleted.

18 changes: 0 additions & 18 deletions ansible-role/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,3 @@
- name: install TinyPilot Debian package
apt:
deb: "{{ tinypilot_debian_package_path }}"
notify:
- restart TinyPilot service

- name: install TinyPilot as a service
template:
src: tinypilot.systemd.j2
dest: /lib/systemd/system/tinypilot.service
owner: root
group: root
mode: "0644"
notify:
- reload TinyPilot systemd config
- restart TinyPilot service

- name: enable systemd TinyPilot service file
systemd:
name: tinypilot
enabled: yes
9 changes: 0 additions & 9 deletions ansible-role/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
---
# TinyPilot's get-tinypilot.sh script (which it uses for installation and
# updates) relies on the tinypilot user being named "tinypilot" so changing this
# value will break updates.
tinypilot_user: tinypilot
tinypilot_group: tinypilot

tinypilot_dir: /opt/tinypilot
tinypilot_privileged_dir: /opt/tinypilot-privileged

# uStreamer variables are placed here, instead of in `defaults/main.yml`,
# in order to elevate their variable precedence. These variables will now
# override the default variables in the uStreamer role.
Expand Down
1 change: 1 addition & 0 deletions debian-pkg/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export DEB_BUILD_OPTIONS=noddebs
dh $@ --with python-virtualenv

override_dh_installsystemd:
dh_installsystemd --name=tinypilot
dh_installsystemd --name=tinypilot-updater --no-start --no-enable
dh_installsystemd --name=usb-gadget --no-start

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ StartLimitIntervalSec=0

[Service]
Type=simple
User={{ tinypilot_user }}
WorkingDirectory={{ tinypilot_dir }}
ExecStart={{ tinypilot_dir }}/venv/bin/python app/main.py
User=tinypilot
WorkingDirectory=/opt/tinypilot
ExecStart=/opt/tinypilot/venv/bin/python app/main.py
Environment=APP_SETTINGS_FILE=/home/tinypilot/app_settings.cfg
{% if tinypilot_enable_debug_logging %}
Environment=DEBUG=1
{% endif %}
Restart=always

[Install]
Expand Down

0 comments on commit 964afb7

Please sign in to comment.