Compare commits
2 commits
fedc15a1d7
...
d1f171abf0
Author | SHA1 | Date | |
---|---|---|---|
d1f171abf0 | |||
7911bc0d7d |
7 changed files with 87 additions and 0 deletions
2
authorized_keys/foobar.keys
Normal file
2
authorized_keys/foobar.keys
Normal file
|
@ -0,0 +1,2 @@
|
|||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUIAkaRsvb6cD1XIGF80JpMH1mYE9XhCgptOkt9AfloZQlO7Ds5XeCwJk5/TsoidTcb/0yFUov8SMwaIVtrFfkNUqqeAsfm3luJ4JwOXeCwrXD6W7c5Wqg/FGNH0eZr0kEnxpNS10L72+oNBQgnlSNjqWS29lEmXApKQ3IKy6aP9cMwEh25fsH/2G7mHsZX2UMPK0tZPC6MPxY5P9PWLIulUpsX96c6OcAvGYIvsCnecsVsTdhK36w4Z/t7XoLFz5X6k3eXT7gG4SMGuBixjroTUhumWzgJJ6T1Nn/eESe7Im8krlzO/0hG/F8uBy3s04TAJuXFmygvtC4YLyq91U5
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICyKprIcR81+RFSBxU3iyW4vd0ctr0q1Pqifzxbro+0C
|
1
authorized_keys/nelus.keys
Normal file
1
authorized_keys/nelus.keys
Normal file
|
@ -0,0 +1 @@
|
|||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOgVGmzDmhJE1fUYqSHK6CiwctqTgHG6P3N1QY0lJ2vb nielsbeekhuis@MacBook-Air-van-Niels.local
|
37
roles/photos/tasks/bambulab-fetch.yaml
Normal file
37
roles/photos/tasks/bambulab-fetch.yaml
Normal file
|
@ -0,0 +1,37 @@
|
|||
---
|
||||
- name: Install dependencies
|
||||
apt:
|
||||
name: curl
|
||||
|
||||
- name: Install fetch script
|
||||
template:
|
||||
src: bambulab-fetch.sh
|
||||
dest: /opt/bambulab-fetch.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
|
||||
- name: Install service
|
||||
template:
|
||||
src: bambulab-fetch.service
|
||||
dest: /etc/systemd/system/bambulab-fetch.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify: daemon reload
|
||||
|
||||
- name: Install timer
|
||||
template:
|
||||
src: bambulab-fetch.timer
|
||||
dest: /etc/systemd/system/bambulab-fetch.timer
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify: daemon reload
|
||||
|
||||
- name: Enable timer
|
||||
systemd:
|
||||
name: bambulab-fetch
|
||||
state: started
|
||||
enabled: yes
|
||||
daemon_reload: true
|
|
@ -4,3 +4,6 @@
|
|||
|
||||
- tags: photos_mqtt
|
||||
import_tasks: photos2mqtt.yaml
|
||||
|
||||
- tags: bambulab-fetch
|
||||
import_tasks: bambulab-fetch.yaml
|
||||
|
|
10
roles/photos/templates/bambulab-fetch.service
Normal file
10
roles/photos/templates/bambulab-fetch.service
Normal file
|
@ -0,0 +1,10 @@
|
|||
# {{ ansible_managed }}
|
||||
|
||||
[Unit]
|
||||
Description=BambuLab Timelapse Fetcher
|
||||
|
||||
[Service]
|
||||
ExecStart=/opt/bambulab-fetch.sh
|
||||
Type=oneshot
|
||||
User=wip
|
||||
Group=wip
|
26
roles/photos/templates/bambulab-fetch.sh
Normal file
26
roles/photos/templates/bambulab-fetch.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
# {{ ansible_managed }}
|
||||
|
||||
set -eu
|
||||
|
||||
host={{ bambulab_host }}
|
||||
pass={{ bambulab_key }}
|
||||
dir={{ photos_path }}
|
||||
|
||||
files=$(curl -ksl "ftps://bblp:$pass@$host:990/timelapse/" | grep ^video_)
|
||||
|
||||
for file in $files; do
|
||||
# $file is formatted like 'video_2024-06-27_22-50-12.mp4'
|
||||
echo $file
|
||||
|
||||
day=$(echo $file | sed -nr 's/^video_([0-9]+)-([0-9]+)-([0-9]+)_.*/\1\2\3/p')
|
||||
time=$(echo $file | sed -nr 's/^video_[^_]+_([^\.]+)\.mp4/\1/p')
|
||||
ofile="$dir/$day/bambu_timelapse_$time.mp4"
|
||||
echo $ofile
|
||||
|
||||
if [ ! -e "$ofile" ]; then
|
||||
mkdir -p "$(dirname $ofile)"
|
||||
curl -ks "ftps://bblp:$pass@$host:990/timelapse/$file" -o "$ofile"
|
||||
fi
|
||||
done
|
8
roles/photos/templates/bambulab-fetch.timer
Normal file
8
roles/photos/templates/bambulab-fetch.timer
Normal file
|
@ -0,0 +1,8 @@
|
|||
[Unit]
|
||||
Description=Run every 15 minutes
|
||||
|
||||
[Timer]
|
||||
OnCalendar=*:5/10
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
Loading…
Add table
Reference in a new issue