Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save MVKozlov/4e35a2fef1d867c1e79b9b2af4db6f4c to your computer and use it in GitHub Desktop.

Select an option

Save MVKozlov/4e35a2fef1d867c1e79b9b2af4db6f4c to your computer and use it in GitHub Desktop.
Convert SysV Init scripts to Systemd Unit File

Let's say the SysV Init Script is called foo (the file /etc/init.d/foo):

  1. Start the service through Systemd: systemctl start foo

  2. systemd-sysv-generator will generate this file /run/systemd/generator.late/foo.service, copy this file to /etc/systemd/system by running: cp /run/systemd/generator.late/foo.service /etc/systemd/system/foo.service

  3. Edit /etc/systemd/system/foo.service by running systemctl edit foo.service, add in the following line to foo.servie (this makes the service installable)

    [Install]
    WantedBy=multi-user.target
    
  4. Enable the server: systemd enable foo.service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment