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 revision Previous revision
Next revision
Previous revision
howtos:general_admin:openrc [2018/09/14 15:33 (UTC)]
aaditya add section for errors faced
howtos:general_admin:openrc [2018/11/07 09:51 (UTC)] (current)
aaditya [Migrating from /etc/init.d to /etc/openrc/init.d] add left out diff of /etc/rc.conf
Line 2: Line 2:
 ====== OpenRC ====== ====== OpenRC ======
  
-OpenRC is a dependency based init system ​that works with the system provided init program, normally ///​sbin/​init// ​(which is svsvinit in Slackware). It is not a replacement for /sbin/init.+OpenRC is a dependency based service management ​system. It works with the system provided init program, normally ///​sbin/​init//​.
  
 ====== Features ====== ====== Features ======
  
-OpenRC provides a number of features ​touted as innovative by recent init systems ​like systemd or upstart, such as hardware initiated initscript run or cgroups support, without requiring large layout changes ​to accommodate radically different designs and dependencies.+OpenRC provides a number of features like hardware initiated initscript run and cgroups support, without requiring large layout changes.
  
 ====== Installation ====== ====== Installation ======
Line 13: Line 13:
  
 The /etc/init.d directory (a symlink to ///​etc/​rc.d/​init.d//​) will need to be moved: The /etc/init.d directory (a symlink to ///​etc/​rc.d/​init.d//​) will need to be moved:
-  # mv /etc/init.d /etc/init.d.bak+  # mv /etc/init.d /etc/init.d-bkp
  
 ===== Installing ===== ===== Installing =====
Line 34: Line 34:
  
 It may show a warning about deprecated support for ///​etc/​mtab//​ as a file, and how to correct it: It may show a warning about deprecated support for ///​etc/​mtab//​ as a file, and how to correct it:
-  # cp /etc/mtab /etc/mtab.bak+  # cp /etc/mtab /etc/mtab.bkp
   # ln -snf /​proc/​self/​mounts /etc/mtab   # ln -snf /​proc/​self/​mounts /etc/mtab
   ​   ​
Line 133: Line 133:
  
   # rc-service sshd start   # rc-service sshd start
 +
 +====== openrc-init ======
 +
 +Since version **0.25**, openrc provides //​openrc-init//​ which can be used to boot the system.
 +
 +This allows switching between OpenRC and other init systems, for example sysvinit, just by changing boot parameters.
 +
 +To use it,
 +
 +=== Revert inittab changes done ===
 +
 +  cp /​etc/​inittab /​etc/​inittab-openrc.bkp
 +  mv /​etc/​inittab.sysvinit /​etc/​inittab
 +  ​
 +=== Setup the agetty services ===
 +
 +  # main tty
 +  ln -s /​etc/​init.d/​agetty /​etc/​init.d/​agetty.tty1
 +  /​sbin/​rc-update add agetty.tty1 default
 +    ​
 +  cp /​etc/​conf.d/​agetty /​etc/​conf.d/​agetty.tty1
 +  echo '​agetty_options="​--noclear"'​ >> /​etc/​conf.d/​agetty.tty1
 +  ​
 +  # additional ttys
 +  for i in {2..6}; do
 +    ln -s /​etc/​init.d/​agetty /​etc/​init.d/​agetty.tty${i}
 +    /​sbin/​rc-update add agetty.tty${i} default
 +  done
 +  ​
 +  # serial tty (for servers)
 +  ln -s /​etc/​init.d/​agetty /​etc/​init.d/​agetty.ttyS0
 +  /​sbin/​rc-update add agetty.ttyS0 default
 +  ​
 +  cp /​etc/​conf.d/​agetty /​etc/​conf.d/​agetty.ttyS0
 +  echo '​agetty_options="​--noclear"'​ >> /​etc/​conf.d/​agetty.ttyS0
 +
 +=== Update boot parameters ===
 +
 +Add the following to your boot parameters (via ///​etc/​lilo.conf//​ for lilo or ///​etc/​default/​grub//​ for grub):
 +  init=/​sbin/​openrc-init
 +
 +=== Shutdown/​reboot ===
 +
 +To shutdown or reboot, one will need to use **openrc-shutdown**. To shutdown from a desktop environment using ConsoleKit2,​ check out this [[https://​github.com/​ConsoleKit2/​ConsoleKit2/​pull/​113|PR]].
 +
 +For more info, check out the [[https://​wiki.gentoo.org/​wiki/​OpenRC#​openrc-init|Gentoo wiki]].
 +
 +====== Migrating from /etc/init.d to /​etc/​openrc/​init.d ======
 +
 +OpenRC 0.39+, as //​**planned**//​ to shipped via SBo, changes the service and configuration directory to ///​etc/​openrc//​ instead of ///etc//.
 +
 +This is being done to maintain greater compatibility with a vanilla Slackware install.
 +
 +Existing services will need to be migrated, details below on how it can be done.
 +
 +=== 1. Install openrc-0.39.2 and openrc-services-20181107 ===
 +
 +These packages ship the configuration and service files in ///​etc/​openrc//​.
 +
 +=== 2. Migrate existing services ===
 +
 +This involves 4 steps:
 +
 +  # migrate existing services
 +  for service in /​etc/​init.d/​*;​ do
 +    svcname=$(basename "​$service"​)
 +    if [ ! -e "/​etc/​openrc/​init.d/​${svcname}"​ ]; then
 +      if [ -f "/​etc/​init.d/​${svcname}"​ ] && grep -q openrc "/​etc/​init.d/​${svcname}";​ then
 +        cp -v "/​etc/​init.d/​${svcname}"​ "/​etc/​openrc/​init.d/​${svcname}"​
 +      elif [ -L "/​etc/​init.d/​${svcname}"​ ]; then
 +        # check if symlink is of a service
 +        service_target=$(readlink -f "​$service"​)
 +        service_target_name=$(basename "​$service_target"​)
 +        if [ $(dirname "​$service_target"​) = "/​etc/​init.d"​ ]; then
 +          ln -sv "/​etc/​openrc/​init.d/​${service_target_name}"​ "/​etc/​openrc/​init.d/​${svcname}"​
 +        fi
 +      fi
 +    fi
 +  done
 +  ​
 +  # enable existing services
 +  for runlevel in /​etc/​runlevels/​*;​ do
 +    for service in ${runlevel}/​*;​ do
 +      svcname=$(basename "​$service"​)
 +      rvlname=$(basename "​$runlevel"​)
 +      if [ ! -e /​etc/​openrc/​runlevels/​${rvlname}/​${svcname} ] && [ -e /​etc/​openrc/​init.d/​${svcname} ]; then
 +        ln -sv /​etc/​openrc/​init.d/​${svcname} /​etc/​openrc/​runlevels/​${rvlname}/​${svcname}
 +      fi
 +    done
 +  done
 +  ​
 +  # check config changes
 +  for file in /​etc/​conf.d/​*;​ do
 +    filename=$(basename "​$file"​)
 +    extension="​${filename##​*.}"​
 +    if [ "​$extension"​ = orig ] || [ "​$extension"​ == new ]; then
 +      continue ​ # dont need to check extra
 +    fi
 +    if [ -e "/​etc/​conf.d/​${filename}"​ ] && [ -e "/​etc/​openrc/​conf.d/​${filename}"​ ]; then
 +      diff -Nupr "/​etc/​conf.d/​${filename}"​ "/​etc/​openrc/​conf.d/​${filename}"​
 +    fi
 +  done
 +  # main config file
 +  diff -Nupr /​etc/​rc.conf /​etc/​openrc/​rc.conf
 +  ​
 +  # check local.d changes
 +  for file in /​etc/​local.d/​*;​ do
 +    filename=$(basename "​$file"​)
 +    if [ ! -e "/​etc/​openrc/​local.d/​${filename}"​ ]; then
 +      cp -v "/​etc/​local.d/​${filename}"​ "/​etc/​openrc/​local.d/​${filename}"​
 +    elif [ -e "/​etc/​local.d/​${filename}"​ ] && [ -e "/​etc/​openrc/​local.d/​${filename}"​ ]; then
 +      # show changes
 +      diff -Nupr "/​etc/​local.d/​${filename}"​ "/​etc/​openrc/​local.d/​${filename}"​
 +    fi
 +  done
 +
 +Config changes found above can be updated by hand or copy pasted in new location.
 +
 +=== 3. Check and reboot ===
 +
 +Verify if ''​rc-status''​ is showing all services (it may show them as stopped).
 +
 +Reboot and check whether things are working expected, make changes as necessary.
 +
 +The old files and folders can be renamed (or removed).
 +
 +  mv /etc/init.d /​etc/​init.d-openrc-bkp
 +  mv /etc/conf.d /​etc/​conf.d-openrc-bkp
 +  mv /​etc/​local.d /​etc/​local.d-openrc-bkp
 +  mv /​etc/​runlevels /​etc/​runlevels-openrc-bkp
 +  mv /​etc/​rc.conf /​etc/​rc.conf-openrc.bkp
 +
 +Finally, any changes done to the default Slackware system can be reverted:
 +
 +  mv /​etc/​init.d-bkp /etc/init.d
  
 ====== Troubleshooting ====== ====== Troubleshooting ======
Line 170: Line 305:
 ==== Errors while booting ==== ==== Errors while booting ====
  
-After installing or updating the **openrc-services** packages, ​you may get errors like:+After installing or updating the **openrc-services** packages, ​one may get errors like:
  
    * checkpath: owner `netdata:​netdata'​ not found    * checkpath: owner `netdata:​netdata'​ not found

In Other Languages
QR Code
QR Code howtos:general_admin:openrc (generated for current page)