add himawaripy

This commit is contained in:
Pig Monkey 2017-04-09 12:34:59 -07:00
parent 8e93657da8
commit 676f9ce7d7
8 changed files with 101 additions and 0 deletions

View file

@ -297,6 +297,31 @@ PostgreSQL service is not added to `/usr/local/etc/trusted_units`.
Additional configuration options are set which improve performance but make the
database service inappropriate for production use.
## Himawaripy
[Himawaripy][28] is provided to fetch near-realtime photos of Earth from the
Japanese [Himawari 8][29] weather satellite and set them as the user's desktop
background via feh. This should provide early warning of the presence of any
Vogon constructor fleets appearing over the Eastern Hemisphere.
A systemd service unit and timer is installed, but not enabled or started by
default. Instead, the service is added to `/usr/local/etc/trusted_units`,
causing the NetworkManager trusted unit dispatcher to activate the service
whenever a connection is established to a trusted network. The service is
stopped whenever the network goes down or a connection is established to an
untrusted network.
To have the service activated at boot, change the `himawaripy.run_on` variable
from `trusted` to `all`.
If the `himawaripy.run_on` variable is set to anything other than `trusted` or
`all`, the service will never be activated.
By default the timer is scheduled to fetch a new image at 15 minute intervals.
This can be changed by modifying the `himawaripy.run_time` variable.
By completely removing the `himawaripy` variable, no related tasks will be run.
[1]: http://www.ansible.com
[2]: https://www.archlinux.org
@ -325,3 +350,5 @@ database service inappropriate for production use.
[25]: https://weechat.org/
[26]: https://git-annex.branchable.com/
[27]: http://www.postgresql.org/
[28]: https://github.com/boramalper/himawaripy
[29]: https://en.wikipedia.org/wiki/Himawari_8

View file

@ -184,3 +184,9 @@ udisks:
hostsctl:
url: https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
himawaripy:
run_time: 15min
run_boot_delay: 2min
run_on: trusted
flags: --auto-offset --level 4

View file

@ -67,6 +67,7 @@
- { role: bluetooth, tags: ['bluetooth'], when: "bluetooth is defined" }
- { role: wttr, tags: ['wttr'] }
- { role: hostsctl, tags: ['hostsctl'], when: "hostsctl is defined" }
- { role: himawaripy, tags: ['himawaripy'], when: "himawaripy is defined" }
vars_prompt:
- name: user_password
prompt: "Enter desired user password"

View file

@ -0,0 +1,4 @@
---
- name: restart himawaripy
service: name="himawaripy@{{ user.name }}.timer" state=restarted
when: himawaripy.run_on == "all"

View file

@ -0,0 +1,3 @@
---
dependencies:
- { role: systemd }

View file

@ -0,0 +1,41 @@
---
- name: Install himawaripy into virtual environment
pip: name=git+https://github.com/boramalper/himawaripy#egg=himawaripy
virtualenv=/usr/local/env/himawaripy
virtualenv_command=virtualenv3
- name: Link himawaripy to bin
file: src=/usr/local/env/himawaripy/bin/himawaripy
dest=/usr/local/bin/himawaripy
state=link
- name: Push himawaripy service file
template: src=himawaripy.service.j2 dest=/etc/systemd/system/himawaripy@.service
notify:
- reload systemd config
- name: Push himawaripy timer file
template: src=himawaripy.timer.j2 dest=/etc/systemd/system/himawaripy@.timer
notify:
- reload systemd config
- restart himawaripy
- name: Enable and start himawaripy timer
service: name="himawaripy@{{ user.name }}.timer" enabled=yes state=started
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"
when: himawaripy.run_on == "all"
- name: Disable himawaripy timer
service: name="himawaripy@{{ user.name }}.timer" enabled=no
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"
when: himawaripy.run_on == "trusted"

View file

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

View file

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