This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
openbsd:rc.d [2020/06/12 01:49] drquest [Run HOPM as system daemon] |
openbsd:rc.d [2020/06/12 02:17] drquest [Daemon control and mangement system (rcctl)] |
||
---|---|---|---|
Line 8: | Line 8: | ||
The options are as follows: | 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. | + | -dnbsp;nbsp;nbsp;nbsp;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. | -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. | ||
Line 22: | Line 22: | ||
- | ===== Run HOPM as system daemon ===== | + | ===== Run a process as system daemon ===== |
- | * This topic shows how to run hopm as priviledged system daemon which enable it be started/stopped/enabled by rcctl daemon control system | + | * This topic shows how to run a simple process as 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" | + | * Here we'll use hopm process to explain how to launch it into system daemon. |
- | * We'll lauch the process by calling "rcctl start hopm" | + | * For this to work , we'll first install hopm as user hopm, group hopm as usual refer more of it here [[https://ircnow.org/kb/doku.php?id=openbsd:irc:hopm]] |
- | + | * Then we'll create a rc.d script in /etc/rc.d dir by name of "hopm" | |
- | ===== Pre-requisites ===== | + | * Then We'll lauch the process by calling "rcctl start hopm" with root priviledge |
- | * This topic shows how to run hopm as non priviledged system daemon which enable it be started/stopped/enabled by rcctl daemon control system | + | ===== Creating rc.d file for process (hopm) ===== |
- | * It is assumed you have ''[[openbsd:doas|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. | + | |
- | <code> | + | |
- | $ 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! | + | |
- | </code> | + | |
- | + | ||
- | Install the necessary ''wget'' package which is required for pulling files. ''gmake'' is required for compiling and installing. | + | |
- | <code> | + | |
- | $ doas pkg_add wget gmake | + | |
- | </code> | + | |
- | + | ||
- | Grab the latest [[https://github.com/ircd-hybrid/hopm/releases|hopm]]. As of writing, 1.1.6 is the latest. | + | |
- | <code> | + | |
- | $ 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" | + | |
- | </code> | + | |
- | + | ||
- | Decompress the downloaded tarball, after you navigate into its own home directory. | + | |
- | <code> | + | |
- | $ cd /home/hopm | + | |
- | $ doas -u hopm tar zxf hopm-1.1.6.tar.gz | + | |
- | </code> | + | |
- | + | ||
- | Navigate into the extracted path and run configure within it. | + | |
- | <code> | + | |
- | $ cd hopm-1.1.6 | + | |
- | $ doas -u hopm ./configure | + | |
- | </code> | + | |
- | + | ||
- | Run ''gmake'' as per instructed. Then ''gmake install'' which will install into its ''$HOME/hopm'' by default. | + | |
- | <code> | + | |
- | $ doas -u hopm gmake | + | |
- | $ doas -u hopm gmake install | + | |
- | </code> | + | |
- | + | ||
- | Copy ''hopm/etc/reference.conf'' as ''hopm/etc/hopm.conf'' and edit with **your own favourite text editor**. In my case I use ''vim''. | + | |
- | <code> | + | |
- | $ cd ../hopm/etc | + | |
- | $ doas -u hopm cp reference.conf hopm.conf | + | |
- | $ doas -u hopm vim hopm.conf | + | |
- | </code> | + | |
- | + | ||
- | 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. | + | |
- | <code> | + | |
- | $ cd ../bin | + | |
- | $ doas -u hopm hopm -dd | + | |
- | </code> | + | |
- | + | ||
- | ===== Creating rc.d file for hopm ===== | + | |
Now give following commands - | Now give following commands - | ||
<code> | <code> | ||
Line 120: | Line 34: | ||
doas nano hopm | doas nano hopm | ||
</code> | </code> | ||
- | In nano editor add the following code | + | In nano editor add the following code daemon should be set equal to "/path/to/daemon" |
<code> | <code> | ||
#!/bin/ksh | #!/bin/ksh | ||
Line 132: | Line 46: | ||
doas rcctl enable hopm | doas rcctl enable hopm | ||
</code> | </code> | ||
- | First command will start the hopm with root priviledge system daemon and second command | + | First command will start the processs(hopm) with root priviledge system daemon and second command will enable it to be restarted automatically at booting up. |
- | will enable it to be restarted automatically at booting up. | + | |
* 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. | * 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. |