run himawaripy as a user service

Existing users should first stop, disable, and remove the old system timer and service:

    $ sudo systemctl stop himawaripy@$USER.timer
    $ sudo systemctl disable himawaripy@$USER.timer
    $ sudo rm /etc/systemd/system/himawaripy@.*

If the system timer is present in the trusted unit file, remove it.
This commit is contained in:
Pig Monkey 2018-04-03 19:14:46 -07:00
parent 759d83c55f
commit 2ca8f11cc6
3 changed files with 16 additions and 9 deletions

View file

@ -10,32 +10,40 @@
state=link
- name: Push himawaripy service file
template: src=himawaripy.service.j2 dest=/etc/systemd/system/himawaripy@.service
template: src=himawaripy.service.j2 dest=/etc/systemd/user/himawaripy.service
notify:
- reload systemd config
- name: Push himawaripy timer file
template: src=himawaripy.timer.j2 dest=/etc/systemd/system/himawaripy@.timer
template: src=himawaripy.timer.j2 dest=/etc/systemd/user/himawaripy.timer
notify:
- reload systemd config
- restart himawaripy
- name: Enable and start himawaripy timer
service: name="himawaripy@{{ user.name }}.timer" enabled=yes state=started
systemd: name=himawaripy.timer user=yes enabled=yes state=started
become: yes
become_user: "{{ user.name }}"
environment:
XDG_RUNTIME_DIR: "/run/user/{{ user.uid }}"
when: himawaripy.run_on == "all"
- name: Remove himawaripy from trusted unit list
lineinfile: dest=/usr/local/etc/trusted_units
state=absent
line="himawaripy@{{ user.name }}.timer"
line="himawaripy.timer,user:{{ user.name }}"
when: himawaripy.run_on == "all"
- name: Disable himawaripy timer
service: name="himawaripy@{{ user.name }}.timer" enabled=no
systemd: name=himawaripy.timer user=yes enabled=no
become: yes
become_user: "{{ user.name }}"
environment:
XDG_RUNTIME_DIR: "/run/user/{{ user.uid }}"
when: himawaripy.run_on == "trusted"
- name: Add himawaripy to trusted unit list
lineinfile: dest=/usr/local/etc/trusted_units
state=present
line="himawaripy@{{ user.name }}.timer"
line="himawaripy.timer,user:{{ user.name }}"
when: himawaripy.run_on == "trusted"

View file

@ -1,8 +1,7 @@
# {{ ansible_managed }}
[Unit]
Description=Update desktop background with satellite imagery for user %I
Description=Update desktop background with satellite imagery
[Service]
Type=oneshot
ExecStart=/usr/local/bin/himawaripy {{ himawaripy.flags }}
User=%i

View file

@ -5,7 +5,7 @@ Description=Himawaripy satellite imagery timer
[Timer]
OnBootSec={{ himawaripy.run_boot_delay }}
OnUnitActiveSec={{ himawaripy.run_time }}
Unit=himawaripy@%i.service
Unit=himawaripy.service
[Install]
WantedBy=timers.target