IRCNow

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
openbsd:rc.d [2020/06/11 14:25]
drquest [Daemon control and mangement system (rcctl)]
openbsd:rc.d [2020/06/12 02:21] (current)
drquest [Daemon control and mangement system (rcctl)]
Line 4: Line 4:
 The /etc/rc.d directory contains shell scripts to start, stop, and reconfigure daemon programs (“services”). 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. +**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.** 
-<p>+
 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.+-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.+-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: Each such script responds to the following actions:
  
-start          -Start the service, if not already running. +start...........-Start the service, if not already running.\\ 
-stop          -Stop the service. +stop...........-Stop the service.\\ 
-reload ​     -Tell the daemon to reload its configuration. +reload.......-Tell the daemon to reload its configuration.\\ 
-restart ​     -Perform a stop, then a start. +restart.......-Perform a stop, then a start.\\ 
-check       ​-Return 0 if the daemon is running or 1 if it is not. +check.........-Return 0 if the daemon is running or 1 if it is not.\\
-</p>+
  
  
  
-===== Run HOPM as system daemon ===== +===== Run a process  ​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 +  * 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 "doas -u hopm 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 properlyIf you do not have this configured properly and are interfacing with your server as root, you are asking ​for trouble! +Now give following commands -
-  * 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>​ <​code>​
-doas adduser +doas  ​cd ​/etc/rc.d 
-Use option ``-silent''​ if you don't want to see all warnings and questions. +doas  nano hopm
- +
-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>​ </​code>​
- +In nano editor add the following code daemon should be set equal to "/​path/​to/​daemon"​
-Install ​the necessary ''​wget''​ package which is required for pulling files. ''​gmake''​ is required for compiling and installing.+
 <​code>​ <​code>​
-doas pkg_add wget gmake+#​!/​bin/​ksh 
 +daemon="/​home/​hopm/​hopm/​bin/​hopm"​ 
 +. /​etc/​rc.d/​rc.subr 
 +rc_cmd ​$1
 </​code>​ </​code>​
- +save the file and run the following command.
-Grab the latest [[https://​github.com/​ircd-hybrid/​hopm/​releases|hopm]]. As of writing, 1.1.6 is the latest.+
 <​code>​ <​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"​+doas rcctl start hopm 
 +doas rcctl enable ​hopm
 </​code>​ </​code>​
 +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.
  
-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>​ 
- 
-===== Troubleshooting ===== 
-Getting hopm configured right can be tricky. So, here are some few hints and tips. 
- 
-  * Ideally, for the initial testing/​trialling phase, you do not want hopm to be running in the background. This is especially true if you aren't familiar with UNIX. To workaround this, you can run hopm with -d, e.g. 
-<​code>​ 
-$ ./hopm -d 
-</​code>​ 
-You can specify the -d however many times needed but its usefulness typically stops after the second "​d",​ 
-<​code>​ 
-$ ./hopm -dd 
-</​code>​ 
-Also see [[https://​github.com/​ircd-hybrid/​hopm/​blob/​master/​README|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.   * 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.