Skip to content

Commit

Permalink
flatpaks: Include update timer & clean up Ansible
Browse files Browse the repository at this point in the history
Update flatpaks at 4:00am or 2min after boot
Combine multiple 'copy' steps into one step
  • Loading branch information
j1mc committed Jan 28, 2024
1 parent 7495a9e commit 89a494f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 15 deletions.
10 changes: 10 additions & 0 deletions ansible-silverblue/roles/flatpaks/files/flatpak-update.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Flatpak Automatic Update
Documentation=man:flatpak(1)
Wants=network-online.target
After=network-online.target

[Service]
Type=oneshot
ExecCondition=/bin/bash -c '[[ "$(busctl get-property org.freedesktop.NetworkManager /org/freedesktop/NetworkManager org.freedesktop.NetworkManager Metered | cut -c 3-)" == @(2|4) ]]'
ExecStart=/usr/bin/flatpak --system uninstall --unused -y --noninteractive ; /usr/bin/flatpak --system update -y --noninteractive ; /usr/bin/flatpak --system repair
12 changes: 12 additions & 0 deletions ansible-silverblue/roles/flatpaks/files/flatpak-update.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Flatpak Automatic Update Trigger
Documentation=man:flatpak(1)

[Timer]
RandomizedDelaySec=10m
OnBootSec=2m
OnCalendar=*-*-* 4:00:00
Persistent=true

[Install]
WantedBy=timers.target
33 changes: 18 additions & 15 deletions ansible-silverblue/roles/flatpaks/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,29 @@
group: root
mode: 0755

- name: Copy 'flatpak-setup.desktop' into the /etc/skel.d/.config/autostart directory
ansible.builtin.copy:
src: files/ansible-silverblue-oci-firstboot.sh
dest: /etc/profile.d/ansible-silverblue-oci-firstboot.sh
- name: Create flatpak installation script at /usr/bin/ansible-silverblue-flatpak
ansible.builtin.template:
src: templates/ansible-silverblue-flatpaks.jinja2
dest: /usr/bin/ansible-silverblue-flatpak
owner: root
group: root
mode: 0755

- name: Copy 'flatpak-setup.desktop' into the /etc/skel.d/.config/autostart directory
- name: Copy flatpak script and update service+timer files onto the host
ansible.builtin.copy:
src: files/flatpak-setup.desktop
dest: /etc/skel.d/.config/autostart/flatpak-setup.desktop
src: files/{{ item.name }}
dest: {{ item.path }}
owner: root
group: root
mode: 0755
mode: {{ item.mode }}
loop:
- {name: 'ansible-silverblue-oci-firstboot.sh', path '/etc/profile.d/ansible-silverblue-oci-firstboot.sh', mode: '0755'}
- [name: 'flatpak-setup.desktop', path: '/etc/skel.d/.config/autostart/flatpak-setup.desktop', mode: '0755 ']
- [name: 'flatpak-update.service', path: '/etc/systemd/system/flatpak-update.service', mode: '0644 ']
- [name: 'flatpak-update.timer', path: '/etc/systemd/system/flatpak-update.timer', mode: '0644 ']

- name: Create flatpak installation script at /usr/bin/ansible-silverblue-flatpak
ansible.builtin.template:
src: templates/ansible-silverblue-flatpaks.jinja2
dest: /usr/bin/ansible-silverblue-flatpak
owner: root
group: root
mode: 0755
- name: Enable the flatpak-update service
ansible.builtin.systemd_service:
name: flatpak-update.timer
enabled: true
daemon_reload: true

0 comments on commit 89a494f

Please sign in to comment.