Hopm-NowWithInit
Ight this is Hopm,
(fancy subtitle): Now with init!
So ehh, I don't know how to write things professionally but:
<jrmu> ok can you put it on the wiki? You can create a new page or add a new page to the almanack, or add it to the end of https://wiki.ircnow.org/?n=Hopm.Install
<jrmu> maybe add a new section and keep the old content intact until you are 100% sure it is a full replacement
So first of all I'll give you the 1:1 without cleaning it up (not sorry) but be warned it will not work unless you use my weird HOPM build as well.
#!/bin/ksh daemon="/usr/local/bin/hopm" daemon_user="_hopm" daemon_flags="-c ../../../../etc/hopm -d" # Do not include .conf as per https://github.com/ircd-hybrid/hopm/blob/1.1.x/INSTALL.md . /etc/rc.d/rc.subr # I could write this a better place but I chose to do it here. # Reloading HOPM _WILL_ kill it. # Aparently theres a bug in HOPM so it has to run in debug mode. It might have something to do with my weird configure flags :) rc_cmd $1
You're going to want to place that in a file located at /etc/rc.d/hopm You must ensure root can read and execute that file.
Secondly a user named _hopm with the homedir builds the the HOPM program with the configure flags "--bindir=/usr/local/bin --prefix=/var/hopm/hopm --localstatedir=/var"
Your hopm conf is now located at /etc/hopm.conf (You have to create it yourself, see <insert jrmu's HOPM guide here>)
Ensure /var/log/scan.log and /var/log/hopm.log and /var/run/hopm.pid is readable and writeable by _hopm
And that should be it just `$ rcctl start hopm' and you'll be good to go, and if you're scared of crashes you can add `*/5 * * * * rcctl check hopm || rcctl start hopm' to roots crontab
Currently known bugs: reloading = crash and startup takes a while because of debug flag.
Heres an ansible task for the smart and lazy (make sure hopm.version is 1.1.10 or the current latest:
---
# Note to future contributer (probably just me): This file is getting long, I want to seperate its modules soon[tm].
- name: Create HOPM service account.
user:
name: _hopm
password: '*'
comment: "HOPM Daemon"
shell: "/sbin/nologin"
home: "/var/hopm"
- name: Does hopm-$relase exist?
stat:
name: "/var/hopm/hopm-{{ hopm.release }}"
register: does_hopm_release_exist
- name: Install dependency packages.
openbsd_pkg:
name: "{{ packages }}"
vars:
packages:
- gtar--
- gmake
tags: packages
- name: Build HOPM.
block:
- name: Download HOPM source code tar file.
get_url:
url: "https://github.com/ircd-hybrid/hopm/archive/refs/tags/{{ hopm.release }}.tar.gz"
dest: "/var/hopm/{{ hopm.release }}.tar.gz"
- name: Unarchive HOPM source code tar file.
unarchive:
src: "/var/hopm/{{ hopm.release }}.tar.gz"
dest: "/var/hopm/"
remote_src: true
- name: Delete HOPM source code tar file.
file:
name: "/var/hopm/{{ hopm.release }}.tar.gz"
state: absent
- name: $ ./configure
shell:
cmd: "/var/hopm/hopm-{{ hopm.release }}/configure --bindir=/usr/local/bin --prefix=/var/hopm/hopm --localstatedir=/var"
chdir: "/var/hopm/hopm-{{ hopm.release }}/"
- name: $ gmake # We _need_ to use gmake for unknown reason. Ask the HOPM devs.
shell:
cmd: "gmake"
chdir: "/var/hopm/hopm-{{ hopm.release }}/"
become: true
become_user: "_hopm"
when: not does_hopm_release_exist.stat.exists
- name: $ gmake install
shell:
cmd: "gmake install"
chdir: "/var/hopm/hopm-{{ hopm.release }}/"
when: not does_hopm_release_exist.stat.exists
- name: HOPM file prequsits.
file:
path: "{{ item }}"
owner: _hopm
group: wheel
mode: '644' # QUOTES ARE IMPORTENT FOR SANITY.
state: touch
loop:
- /var/log/scan.log
- /var/log/hopm.log
- /var/run/hopm.pid
when: not does_hopm_release_exist.stat.exists
- name: Copy rc.d/hopm
copy:
src: rc.d/hopm
dest: /etc/rc.d/hopm
owner: root
group: wheel
mode: '755' # Must be quoted like this!
- name: Copy hopm.conf (template).
template:
src: hopm.conf.j2
dest: /etc/hopm.conf
owner: _hopm
group: wheel
mode: 464
notify: Restart hopm
- name: Add HOPM to logrotation list.
blockinfile:
name: /etc/newsyslog.conf
block: |
# HOPM
/var/log/scan.log _hopm:wheel 644 3 * $D Z "pkill -USR1 hopm"
/var/log/hopm.log _hopm:wheel 644 3 * $D Z "pkill -USR1 hopm"
- name: Add HOPM autorestart to root's crontab.
cron:
minute: "*/5"
job: "rcctl check hopm || rcctl start hopm"
name: "irc_hopm_autorestart"
