7

I want to have a custom service that I've placed into /lib/systemd/system start at boot, but th eonly way I know how at the moment is to run

systemctl enable myservice.service

but I would like to be able to do this without booting into the actual file system so that I can automate the deployment of this configuration.

ngart
  • 173
  • 1
  • 4
  • I assume that you have your Debian filesystem mounted somewhere? Can you simply run `chroot /mountpoint systemctl enable myservice.service`? – Zoredache May 29 '13 at 01:21
  • Or rather `systemd-nspawn -b -D /mountpoint` instead of `chroot` – but in this case symlinking will be sufficient. – Debilski Aug 25 '14 at 16:02

1 Answers1

5

What systemctl enable does is creates a symlink for the service you specify from the /lib/systemd/system folder to /etc/systemd/multi-user.target.wants, so you can simply do:

ln -s '/lib/systemd/system/myservice.service' '/etc/systemd/multi-user.target.wants/myservice.service'

j883376
  • 266
  • 3
  • 8