IRCNow

This is an old revision of the document!


Daemon control and mangement system (rcctl)

The rcctl utility can enable or disable a base system service or a base system or package daemon in rc.conf.local or display its configuration and status. For a daemon, it can also change the command line arguments, the user to run as, the rc.d action timeout or call its rc.d daemon control script.

The /etc/rc.d directory contains shell scripts to start, stop, and reconfigure daemon programs (“services”).

Services installed from packages may be started at boot time in the order specified by the pkg_scripts variable from rc.conf the order will be reversed during shutdown. Services comprising OpenBSD base are started by rc.

The options are as follows:

-d………Setting this option will print the function names as they are called and prevent the rc.subr framework from redirecting stdout and stderr to /dev/null. This is used to allow debugging of failed actions.

-f………This option only affects the start action. It will forcibly start the daemon whatever value daemon_flags is set to. If daemon_flags is set to “NO”, execution will continue with the script's own defaults unless other flags are specified.

Each such script responds to the following actions:

start………..-Start the service, if not already running.
stop………..-Stop the service.
reload…….-Tell the daemon to reload its configuration.
restart…….-Perform a stop, then a start.
check………-Return 0 if the daemon is running or 1 if it is not.

Run HOPM as system daemon

  • This topic shows how to run hopm as non priviledged system daemon which enable it be started/stopped/enabled by rcctl daemon control system
  • For this to work , we'll first install hopm as user hopm, group hopm as usual and create a rc.d script /etc/rc.d dir by name of “hopm”
  • We'll lauch the process by calling “doas -u hopm rcctl start hopm”

Pre-requisites

  • This topic shows how to run hopm as non priviledged system daemon which enable it be started/stopped/enabled by rcctl daemon control system
  • It is assumed you have doas configured properly. If you do not have this configured properly and are interfacing with your server as root, you are asking for trouble!
  • It is assumed you have ran adduser before. If not, you can run it and the majority of the defaults are fine.
  • It is also assumed you have your own favourite text editor. If you do not have a favourite text editor, I recommend installing nano via doas pkg_add nano. You must know how to use your favourite text editor as I won't cover you on how to use it.

Installation

Create hopm as its own user.

$ doas adduser
Use option ``-silent'' if you don't want to see all warnings and questions.

Reading /etc/shells
Check /etc/master.passwd
Check /etc/group

Ok, let's go.
Don't worry about mistakes. There will be a chance later to correct any input.
Enter username []: hopm
Enter full name []: hopm
Enter shell bash csh jk_chrootsh ksh nologin sh [ksh]: nologin
Uid [1002]: 65532
Login group hopm [hopm]:  
Login group is ``hopm''. Invite hopm into other groups: guest no 
[no]: 
Login class authpf bgpd daemon default pbuild staff unbound znc 
[default]: daemon
Enter password []: 
Disable password logins for the user? (y/n) [n]: y

Name:        hopm
Password:    ****
Fullname:    hopm
Uid:         65532
Gid:         65532 (hopm)
Groups:      hopm 
Login Class: daemon
HOME:        /home/hopm
Shell:       /sbin/nologin
OK? (y/n) [y]: 
Added user ``hopm''
Copy files from /etc/skel to /home/hopm
Add another user? (y/n) [y]: n
Goodbye!

Install the necessary wget package which is required for pulling files. gmake is required for compiling and installing.

$ doas pkg_add wget gmake

Grab the latest hopm. As of writing, 1.1.6 is the latest.

$ doas -u hopm wget "https://github.com/ircd-hybrid/hopm/archive/1.1.6.tar.gz" -O "/home/hopm/hopm-1.1.6.tar.gz"

Decompress the downloaded tarball, after you navigate into its own home directory.

$ cd /home/hopm
$ doas -u hopm tar zxf hopm-1.1.6.tar.gz

Navigate into the extracted path and run configure within it.

$ cd hopm-1.1.6
$ doas -u hopm ./configure

Run gmake as per instructed. Then gmake install which will install into its $HOME/hopm by default.

$ doas -u hopm gmake
$ doas -u hopm gmake install

Copy hopm/etc/reference.conf as hopm/etc/hopm.conf and edit with your own favourite text editor. In my case I use vim.

$ cd ../hopm/etc
$ doas -u hopm cp reference.conf hopm.conf
$ doas -u hopm vim hopm.conf

Make necessary adjustments within the hopm.conf to suit your server/network configuration. Save and exit out of your own favourite text editor. In the first few running instances, I would enable debug mode to see if there were any issues with the configuration.

$ cd ../bin
$ doas -u hopm hopm -dd

Creating rc.d file for hopm

Now give following commands -

doas -u hopm cd /etc/rc.d
doas -u hopm nano hopm

Also see here

  • Syntax errors when hopm is running in foreground. This is either the result of missing brackets where needed in config file, or that the file has DOS encodings. See https://github.com/ircd-hybrid/hopm/issues/22#issuecomment-301276082 here. The missing brackets where it was needed may come from the previous section, compared to the line/s where it is indicated by hopm when executed.