aboutsummaryrefslogtreecommitdiffstats
path: root/roles/jails/06_hommabot
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2026-05-19 00:49:25 +0300
committerJan Tuomi <jan@jantuomi.fi>2026-05-19 00:55:21 +0300
commitb0578d2af1d6bfef7b86103a3f244c9112d06f98 (patch)
treec2165399785450e55d4996ef842c8ec0ad45d102 /roles/jails/06_hommabot
parentb38e910899bad2d6ae2049b599dcdd525420c53d (diff)
Remove packager, use ports fork
Diffstat (limited to 'roles/jails/06_hommabot')
-rw-r--r--roles/jails/06_hommabot/defaults/main.yml12
-rw-r--r--roles/jails/06_hommabot/handlers/main.yml5
-rw-r--r--roles/jails/06_hommabot/tasks/main.yml21
-rw-r--r--roles/jails/06_hommabot/templates/etc_crontab.j210
-rw-r--r--roles/jails/06_hommabot/templates/root_hommabot_deps.sh14
-rw-r--r--roles/jails/06_hommabot/templates/root_hommabot_env.j24
6 files changed, 29 insertions, 37 deletions
diff --git a/roles/jails/06_hommabot/defaults/main.yml b/roles/jails/06_hommabot/defaults/main.yml
index d12d40f..0b4b4f3 100644
--- a/roles/jails/06_hommabot/defaults/main.yml
+++ b/roles/jails/06_hommabot/defaults/main.yml
@@ -1,14 +1,8 @@
userland: "14.3-RELEASE"
pkg:
+ - node
- npm
-files:
- - src: root_hommabot_env.j2
- dest: /root/hommabot/.env
- mode: "0600"
- - src: root_hommabot_deps.sh
- dest: /root/hommabot/deps.sh
- mode: "0755"
- - src: etc_crontab.j2
- dest: /etc/crontab
+services:
+ - hommabot
diff --git a/roles/jails/06_hommabot/handlers/main.yml b/roles/jails/06_hommabot/handlers/main.yml
new file mode 100644
index 0000000..d291200
--- /dev/null
+++ b/roles/jails/06_hommabot/handlers/main.yml
@@ -0,0 +1,5 @@
+- name: Restart hommabot
+ shell: service hommabot status && service hommabot restart
+ register: _hb_restart
+ failed_when: false
+ changed_when: _hb_restart.rc == 0
diff --git a/roles/jails/06_hommabot/tasks/main.yml b/roles/jails/06_hommabot/tasks/main.yml
index 2abdaff..9b1ee5f 100644
--- a/roles/jails/06_hommabot/tasks/main.yml
+++ b/roles/jails/06_hommabot/tasks/main.yml
@@ -1,2 +1,23 @@
- import_role:
name: jail
+ tasks_from: jail_setup
+
+- name: Install hommabot from port
+ shell: cd /usr/local/my-ports/hommabot && make install
+ register: _hommabot_install
+ failed_when: "_hommabot_install.rc != 0 and 'already installed' not in _hommabot_install.stdout"
+ changed_when: "'already installed' not in _hommabot_install.stdout"
+
+- name: Deploy bot token file
+ copy:
+ content: "{{ hommabot_token }}"
+ dest: /usr/local/etc/hommabot.token
+ owner: root
+ group: wheel
+ mode: "0600"
+ no_log: true
+ notify: Restart hommabot
+
+- import_role:
+ name: jail
+ tasks_from: jail_launch
diff --git a/roles/jails/06_hommabot/templates/etc_crontab.j2 b/roles/jails/06_hommabot/templates/etc_crontab.j2
deleted file mode 100644
index 556d12a..0000000
--- a/roles/jails/06_hommabot/templates/etc_crontab.j2
+++ /dev/null
@@ -1,10 +0,0 @@
-# /etc/crontab - root's crontab for FreeBSD
-#
-#
-SHELL=/bin/sh
-PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
-#
-#minute hour mday month wday who command
-
-# Run hommabot every Monday at 9:00 AM
-0 9 * * 1 root /bin/sh -c "cd /root/hommabot && node index.js"
diff --git a/roles/jails/06_hommabot/templates/root_hommabot_deps.sh b/roles/jails/06_hommabot/templates/root_hommabot_deps.sh
deleted file mode 100644
index 25c0e56..0000000
--- a/roles/jails/06_hommabot/templates/root_hommabot_deps.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-
-set -eux
-cd /root/hommabot
-npm ci
-
-# We need to build the better-sqlite3.node file before running the app
-if [ ! -f build/better_sqlite3.node ]; then (
- mkdir -p build
- cd node_modules/better-sqlite3
- npm run build-release
- cp build/Release/better_sqlite3.node ../../build/better_sqlite3.node
-)
-fi
diff --git a/roles/jails/06_hommabot/templates/root_hommabot_env.j2 b/roles/jails/06_hommabot/templates/root_hommabot_env.j2
deleted file mode 100644
index c66c666..0000000
--- a/roles/jails/06_hommabot/templates/root_hommabot_env.j2
+++ /dev/null
@@ -1,4 +0,0 @@
-TELEGRAM_BOT_TOKEN="{{ hommabot_telegram_bot_token }}"
-SHEETS_SPREADSHEET_ID="{{ hommabot_sheets_spreadsheet_id }}"
-SHEETS_RANGE="{{ hommabot_sheets_range }}"
-G_SA_JSON_B64="{{ hommabot_g_sa_json_b64 }}"