summaryrefslogtreecommitdiff
path: root/roles
diff options
context:
space:
mode:
authorDmitry Ilvokhin <d@ilvokhin.com>2026-02-07 17:47:16 +0000
committerDmitry Ilvokhin <d@ilvokhin.com>2026-02-07 21:19:50 +0000
commitdfff28513622f659430ef064322cfa701513feb0 (patch)
tree2c9457db3635c3ee1f748ba5d21c5ba8e8538109 /roles
parentf34ef9c98c3b24d170d178f381aaf8ed50b1c729 (diff)
downloadinfra-dfff28513622f659430ef064322cfa701513feb0.tar.gz
infra-dfff28513622f659430ef064322cfa701513feb0.tar.bz2
infra-dfff28513622f659430ef064322cfa701513feb0.zip
Add run-flatbot wrapper script
Goal is to keep all URLs in one place (file), because I forget to modify multiple files, when make changes.
Diffstat (limited to 'roles')
-rw-r--r--roles/flatbot/files/config1
-rw-r--r--roles/flatbot/files/flatbot.service3
-rwxr-xr-xroles/flatbot/files/run-flatbot27
-rw-r--r--roles/flatbot/files/urls7
-rw-r--r--roles/flatbot/tasks/main.yml8
5 files changed, 42 insertions, 4 deletions
diff --git a/roles/flatbot/files/config b/roles/flatbot/files/config
index 80983bb..ca71055 100644
--- a/roles/flatbot/files/config
+++ b/roles/flatbot/files/config
@@ -1,2 +1,3 @@
FLATBOT_TELEGRAM_CHAT_ID=-1001856540467
FLATBOT_STATE=/var/lib/flatbot/state.json
+FLATBOT_URLS=/etc/flatbot/urls
diff --git a/roles/flatbot/files/flatbot.service b/roles/flatbot/files/flatbot.service
index 1dd6028..3b669d7 100644
--- a/roles/flatbot/files/flatbot.service
+++ b/roles/flatbot/files/flatbot.service
@@ -6,8 +6,7 @@ After=network.target
Type=oneshot
EnvironmentFile=/etc/flatbot/token
EnvironmentFile=/etc/flatbot/config
-EnvironmentFile=/etc/flatbot/urls
-ExecStart=/usr/bin/flatbot -state ${FLATBOT_STATE} -once ${GREENWICH} ${CLERKENWELL}
+ExecStart=/usr/local/bin/run-flatbot ${FLATBOT_STATE} ${FLATBOT_URLS}
[Install]
WantedBy=default.target
diff --git a/roles/flatbot/files/run-flatbot b/roles/flatbot/files/run-flatbot
new file mode 100755
index 0000000..1d8869d
--- /dev/null
+++ b/roles/flatbot/files/run-flatbot
@@ -0,0 +1,27 @@
+#! /usr/bin/env bash
+
+# Simple wrapper script to read URLs from configuration file.
+
+if [ "$#" -ne 2 ]; then
+ echo "Illegal number of parameters" 1>&2
+ exit 1
+fi
+
+state=$1
+urlsfile=$2
+
+urls=""
+
+while IFS= read -r line;
+do
+ case "$line" in
+ ""|\#*)
+ continue
+ ;;
+ *)
+ urls="${urls} ${line}"
+ ;;
+ esac
+done < $urlsfile
+
+exec /usr/bin/flatbot -state $state -once ${urls}
diff --git a/roles/flatbot/files/urls b/roles/flatbot/files/urls
index 7b5c523..99005e7 100644
--- a/roles/flatbot/files/urls
+++ b/roles/flatbot/files/urls
@@ -1,2 +1,5 @@
-GREENWICH=https://www.rightmove.co.uk/property-for-sale/find.html?minBedrooms=2&propertyTypes=detached,semi-detached,terraced&sortType=2&areaSizeUnit=sqft&channel=BUY&index=0&tenureTypes=FREEHOLD,SHARE_OF_FREEHOLD&maxPrice=900000&radius=0.5&locationIdentifier=STATION^6122&maxDaysSinceAdded=7
-CLERKENWELL=https://www.rightmove.co.uk/property-for-sale/find.html?minBedrooms=2&sortType=2&areaSizeUnit=sqft&channel=BUY&index=0&maxPrice=900000&radius=0.5&locationIdentifier=STATION^3431&maxDaysSinceAdded=7
+# Greenwich
+https://www.rightmove.co.uk/property-for-sale/find.html?minBedrooms=2&propertyTypes=detached,semi-detached,terraced&sortType=2&areaSizeUnit=sqft&channel=BUY&index=0&tenureTypes=FREEHOLD,SHARE_OF_FREEHOLD&maxPrice=900000&radius=0.5&locationIdentifier=STATION^6122&maxDaysSinceAdded=7
+
+# Clerkenwell
+https://www.rightmove.co.uk/property-for-sale/find.html?minBedrooms=2&sortType=2&areaSizeUnit=sqft&channel=BUY&index=0&maxPrice=900000&radius=0.5&locationIdentifier=STATION^3431&maxDaysSinceAdded=7
diff --git a/roles/flatbot/tasks/main.yml b/roles/flatbot/tasks/main.yml
index a15fab8..48d1083 100644
--- a/roles/flatbot/tasks/main.yml
+++ b/roles/flatbot/tasks/main.yml
@@ -34,6 +34,14 @@
group: root
mode: u+rw,g-r,o-r
+- name: Copy flatbot run wrapper
+ ansible.builtin.copy:
+ src: files/run-flatbot
+ dest: /usr/local/bin/run-flatbot
+ owner: root
+ group: root
+ mode: u+rwx,g+r,o+r
+
- name: Configure flatbot service
ansible.builtin.copy:
src: '{{ item }}'