1

I have a script in /etc/init.d that I'm trying to add echo statements to...but all of my changes seem to be ignored.

I'm guessing because the script itself is not actually run but that systemd is doing something behind the scenes to continue running the old version of the script. Is there a way to "load" these changes?

dr_
  • 29,602
wsaxton
  • 129

2 Answers2

6

No, there's not a way for systemd to load the changes you made to files in /etc/init.d because systemd is largely ignoring the files anyway. See the gory details at How does systemd use /etc/init.d scripts?.

Consider asking a different question about the specific problem you are attempting to solve by editing /etc/init.d files.

I could guess that perhaps you are looking for ExecStartPre= or ExecStartPost=. Read man systemd.service for other directives that you can use in your systemd service unit files.

  • This was the answer. To troubleshoot, I just copied the script outside of /etc/init.d, modified it, and ran it manually. – wsaxton Feb 28 '17 at 03:06
0

You're on the right tracks. You will need to reload systemd's context using the following command:

sudo systemctl daemon-reload

It was a lot easier in the SysV days :)

Ed Neville
  • 1,340
  • No, the old init scripts are largely ignored as answer linked in Jeff's comment explains. Reloading any part of systemd won't make changes appear to be active. – Mark Stosberg Feb 27 '17 at 21:44
  • Unfortunately, that didn't work: [vagrant@gitserver ~]$ sudo head /etc/init.d/gogs #!/bin/sh

    echo "ZZ" [vagrant@gitserver ~]$ sudo systemctl daemon-reload [vagrant@gitserver ~]$ sudo systemctl start gogs [vagrant@gitserver ~]$

    – wsaxton Feb 27 '17 at 21:46