[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
howtos:slackware_admin:runit [2019/01/31 11:57 (UTC)] – Introduced a solution for DE and the finish script chrisabelahowtos:slackware_admin:runit [2019/05/30 12:34 (UTC)] chrisabela
Line 10: Line 10:
  
 To read on the benefits of runit, see here: http://smarden.org/runit/benefits.html To read on the benefits of runit, see here: http://smarden.org/runit/benefits.html
 +
 +Unless otherwise stated, all commands in this article are to be run by root.
  
 ===== 2. Use runit with traditional init ===== ===== 2. Use runit with traditional init =====
Line 81: Line 83:
 If you followed the previous chapter, then stop runsvdir and reverse all the changes that you made on your system. If you followed the previous chapter, then stop runsvdir and reverse all the changes that you made on your system.
  
-Remove the last line from ''/etc/inittab''+So, remove the last line from ''/etc/inittab''
  
 <code> <code>
Line 87: Line 89:
 </code> </code>
  
-Reboot:+And reboot:
  
 <code> <code>
Line 188: Line 190:
 The traditional init reads ''/etc/inittab'' file to see how to run the system. It runs the ''/etc/rc.d/rc.S'' script and runs it. If set in the default runlevel 3, it follows it with ''/etc/rc.d/rc.M''. In runit the initialisation script is located in ''/etc/runit/1'' for all runlevels. By default ''/etc/runit/2'' is restricted to the TTY services.  The traditional init reads ''/etc/inittab'' file to see how to run the system. It runs the ''/etc/rc.d/rc.S'' script and runs it. If set in the default runlevel 3, it follows it with ''/etc/rc.d/rc.M''. In runit the initialisation script is located in ''/etc/runit/1'' for all runlevels. By default ''/etc/runit/2'' is restricted to the TTY services. 
  
-The script ''/etc/rc.d/rc.6'' is the rebooting script for the traditional init, while ''/etc/rc.d/rc.0'' (symlinked to former) is the halting script. In runit, these scripts are called by ''/etc/runit/3''+The script ''/etc/rc.d/rc.6'' is the rebooting script for the traditional init, while ''/etc/rc.d/rc.0'' (symlinked to the former) is the halting script. In runit, these scripts are called by ''/etc/runit/3''
  
 Note that the shutdown command provided by sysvinit package will not work in runit. To reboot you enter Note that the shutdown command provided by sysvinit package will not work in runit. To reboot you enter
Line 225: Line 227:
 </code> </code>
  
-In order to let the non-privileged user (say user chrisrun itchange the ownership of the service directory+As a non-priviliged user (say user bob), create some directories:
  
 <code> <code>
-chmod -R chris.users /etc/sv/example+mkdir -/home/bob/runit/logs
 </code> </code>
  
-As non-priviliged user, create some directories +Then edit ''/home/bob/runit/service.sh'' script that simulates a (finicky) service in a convenient directory; say 
- +
-<code> +
-mkdir -p /home/chris/runit/logs +
-</code> +
- +
-Then edit a script that simulates a (finicky) service in a convenient directory; say +
  
 <code> <code>
Line 254: Line 250:
  
 <code> <code>
-chmod +x /home/chris/runit/service.sh+chmod +x /home/bob/runit/service.sh
 </code> </code>
  
Line 260: Line 256:
  
 <code> <code>
-/home/chris/runit/service.sh+/home/bob/runit/service.sh
 </code> </code>
  
-Edit a file called ''/etc/sv/example/run'' and give it executable permissions+Log in back as root and edit a file called ''/etc/sv/example/run'' and give it executable permissions:
  
 <code> <code>
 #!/bin/sh -e #!/bin/sh -e
 exec 2>&1 exec 2>&1
-exec chpst -u chris /home/chris/runit/service.sh+exec chpst -u bob /home/bob/runit/service.sh
 </code> </code>
  
Line 285: Line 281:
 </code> </code>
  
-and edit another file under it also called ''/etc/sv/example/log/run''+and edit another file under italso called ''/etc/sv/example/log/run''
    
 <code> <code>
 #!/bin/sh #!/bin/sh
-exec chpst -u chris svlogd -tt /home/chris/runit/logs+exec chpst -u bob svlogd -tt /home/bob/runit/logs
 </code> </code>
  
Line 298: Line 294:
 </code> </code>
  
-Run the sv service to ensure that it works:+Run the service to ensure that it works:
  
 <code> <code>
Line 311: Line 307:
  
 Watch how your "service" works, crashes, but it is recovered by runit: Watch how your "service" works, crashes, but it is recovered by runit:
 +
 +As your non-privilged user:
  
 <code> <code>
-tail -f /home/chris/logs/current +tail -f /home/bob/runit/logs/current 
 </code> </code>
 +
 +Hit CTRL+C to exit.
 +
 +Finally, login back as root and let bob take the ownership of the whole ''/etc/sv/example/'' directory:
 +
 +<code>
 +chown -R bob.users /etc/sv/example/
 +</code>
 +
 +Now bob can manage this service with the ''sv'' command. Note that in most cases, services should belong to root, and only to root.
  
 ===== 7.  Managing Services with sv ===== ===== 7.  Managing Services with sv =====
Line 357: Line 365:
  
 Each of these is a shortcut, for 'up', 'down', and 'terminate', respectively. Only the first letter of each word is recognised. Each of these is a shortcut, for 'up', 'down', and 'terminate', respectively. Only the first letter of each word is recognised.
-More verbose forms of the above+ 
 +More verbose forms of the above:
  
 <code> <code>
-sv start sshd+sv start example
  
-sv stop sshd+sv stop example
  
-sv restart sshd+sv restart example
 </code> </code>
  
Line 528: Line 537:
 <!-- Please do not modify anything below, except adding new tags.--> <!-- Please do not modify anything below, except adding new tags.-->
 {{tag>init runit}} {{tag>init runit}}
- 
- 
 howtos:slackware_admin:runit ()