From 37eb5f5804a5bc53ec7271e413c29163a1bc1560 Mon Sep 17 00:00:00 2001 From: Aljoscha Vollmerhaus Date: Thu, 9 Mar 2023 11:09:03 +0100 Subject: [PATCH 1/2] Add bsd-rc init script --- distrib/bsd-rc/README.md | 20 ++++++++++++++++++ distrib/bsd-rc/ergo | 45 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 distrib/bsd-rc/README.md create mode 100644 distrib/bsd-rc/ergo diff --git a/distrib/bsd-rc/README.md b/distrib/bsd-rc/README.md new file mode 100644 index 00000000..d01462f0 --- /dev/null +++ b/distrib/bsd-rc/README.md @@ -0,0 +1,20 @@ +Ergo init script for bsd-rc +=== + +Written for and tested using FreeBSD. + +Copy the `ergo` file from this folder to `/etc/rc.d/ergo`, +permissions should be `555`. + +You should create a system user for Ergo. +This script defaults to running Ergo as a user named `ergo`, +but that can be changed using `/etc/rc.conf`. + +Here are all `rc.conf` variables and their defaults: +- `ergo_enable`, defaults to `NO`. Whether to run `ergo` at system start. +- `ergo_user`, defaults to `ergo`. Run using this user. +- `ergo_group`, defaults to `ergo`. Run using this group. +- `ergo_chdir`, defaults to `/var/db/ergo`. Path to the working directory for the server. Should be writable for `ergo_user`. +- `ergo_conf`, defaults to `/usr/local/etc/ergo/ircd.yaml`. Config file path. Make sure `ergo_user` can read it. + +This script assumes ergo to be installed at `/usr/local/bin/ergo`. diff --git a/distrib/bsd-rc/ergo b/distrib/bsd-rc/ergo new file mode 100644 index 00000000..031cd2c1 --- /dev/null +++ b/distrib/bsd-rc/ergo @@ -0,0 +1,45 @@ +#!/bin/sh + +# PROVIDE: ergo +# REQUIRE: DAEMON +# KEYWORD: shutdown + +# +# Add the following lines to /etc/rc.conf to enable Ergo +# +# ergo_enable (bool): Set to YES to enable ergo. +# Default is "NO". +# ergo_user (user): Set user to run ergo. +# Default is "ergo". +# ergo_group (group): Set group to run ergo. +# Default is "ergo". +# ergo_config (file): Set ergo config file path. +# Default is "/usr/local/etc/ergo/config.yaml". +# ergo_chdir (dir): Set ergo working directory +# Default is "/var/db/ergo". + +. /etc/rc.subr + +name=ergo +rcvar=ergo_enable +desc="Ergo IRCv3 server" + +load_rc_config "$name" + +: ${ergo_enable:=NO} +: ${ergo_user:=ergo} +: ${ergo_group:=ergo} +: ${ergo_chdir:=/var/db/ergo} +: ${ergo_conf:=/usr/local/etc/ergo/ircd.yaml} + +# If you don't define a custom reload function, +# rc automagically sends SIGHUP to the process on reload. +# But you have to list reload as an extra_command for that. +extra_commands="reload" + +procname="/usr/local/bin/${name}" +command=/usr/sbin/daemon +command_args="-S -T ${name} ${procname} run --conf ${ergo_conf}" + +run_rc_command "$1" + From 04f8791dd6ba1f504444fad5e5b7620cc2db52bc Mon Sep 17 00:00:00 2001 From: Aljoscha Vollmerhaus Date: Thu, 9 Mar 2023 11:14:29 +0100 Subject: [PATCH 2/2] add sections + usage information to bsd-rc README --- distrib/bsd-rc/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/distrib/bsd-rc/README.md b/distrib/bsd-rc/README.md index d01462f0..b6cf10ca 100644 --- a/distrib/bsd-rc/README.md +++ b/distrib/bsd-rc/README.md @@ -3,6 +3,7 @@ Ergo init script for bsd-rc Written for and tested using FreeBSD. +## Installation Copy the `ergo` file from this folder to `/etc/rc.d/ergo`, permissions should be `555`. @@ -18,3 +19,11 @@ Here are all `rc.conf` variables and their defaults: - `ergo_conf`, defaults to `/usr/local/etc/ergo/ircd.yaml`. Config file path. Make sure `ergo_user` can read it. This script assumes ergo to be installed at `/usr/local/bin/ergo`. + +## Usage + +```shell +/etc/rc.d/ergo +``` +In addition to the obvious `start` and `stop` commands, this +script also has a `reload` command that sends `SIGHUP` to the Ergo process.