summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColeman McFarland <coleman@de.limited>2024-04-14 20:17:34 -0400
committerColeman McFarland <coleman@de.limited>2024-04-14 20:17:34 -0400
commitf9ff75e1d38f43afe28953b7503aae59ad13eb6c (patch)
treef2425d0cdfee69b199b455c525fab612b3a33d98
parent2a41ec04bd665bedcd2ff289ca91071c819406bb (diff)
Add config and openbsd rcctl script
-rw-r--r--main.cpp21
-rw-r--r--meson.build7
-rw-r--r--pkg/openbsd/rc.d/chatops18
3 files changed, 37 insertions, 9 deletions
diff --git a/main.cpp b/main.cpp
index ea4a3ef..4febcb9 100644
--- a/main.cpp
+++ b/main.cpp
@@ -211,6 +211,17 @@ void conn_handler(xmpp_conn_t *conn,
}
int main(int argc, char **argv) {
+
+ char *pass;
+ if ((pass = getenv("CHATOPS_PASSWORD")) == nullptr) {
+ printf("must set CHATOPS_PASSWORD\n");
+ exit(2);
+ }
+ char *jid;
+ if ((jid = getenv("CHATOPS_JID")) == nullptr) {
+ jid = (char *)"devil@de.limited";
+ }
+
xmpp_ctx_t *ctx;
xmpp_conn_t *conn;
xmpp_log_t *log;
@@ -226,15 +237,7 @@ int main(int argc, char **argv) {
conn = xmpp_conn_new(ctx);
xmpp_conn_set_flags(conn, XMPP_CONN_FLAG_ENABLE_COMPRESSION);
- char *pass;
- if ((pass = getenv("CHATOPS_PASSWORD")) == nullptr) {
- printf("must set CHATOPS_PASSWORD\n");
- exit(2);
- }
- char *jid;
- if ((jid = getenv("CHATOPS_JID")) == nullptr) {
- jid = (char *)"devil@de.limited";
- }
+
xmpp_conn_set_jid(conn, jid);
xmpp_conn_set_pass(conn, pass);
diff --git a/meson.build b/meson.build
index 23ecd05..38f1de3 100644
--- a/meson.build
+++ b/meson.build
@@ -10,3 +10,10 @@ srcs = ['main.cpp', 'bot.cpp']
chatops = executable('chatops', srcs, install : true, dependencies : deps)
test('test', chatops)
+
+if host_machine.system() == 'openbsd'
+ chatops_script = files('pkg/openbsd/rc.d/chatops')
+ install_data(chatops_script,
+ install_dir : '/etc/rc.d',
+ install_mode : 'rwxr-xr-x')
+endif \ No newline at end of file
diff --git a/pkg/openbsd/rc.d/chatops b/pkg/openbsd/rc.d/chatops
new file mode 100644
index 0000000..d232bdb
--- /dev/null
+++ b/pkg/openbsd/rc.d/chatops
@@ -0,0 +1,18 @@
+#!/bin/ksh
+
+daemon="/usr/local/bin/chatops"
+daemon_flags="" # Add any flags if needed
+#daemon_user="_chatops" # Run the daemon under a specific user
+
+. /etc/rc.d/rc.subr
+
+rc_reload=NO # Set this if your daemon does not support reloading
+
+#pexp="/usr/local/bin/chatops" # Process name to look for
+
+# Read environment variables from a file
+if [ -f /etc/chatops/env ]; then
+ . /etc/chatops/env
+fi
+
+rc_cmd $1