diff --git a/distrib/bsd-rc/README.md b/distrib/bsd-rc/README.md new file mode 100644 index 00000000..b6cf10ca --- /dev/null +++ b/distrib/bsd-rc/README.md @@ -0,0 +1,29 @@ +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`. + +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`. + +## 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. 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" +