Replace systemd script with init script

Helmut Schneider jumper99 at gmx.de
Fri May 3 12:40:19 UTC 2024


Am 02.05.2024 um 16:37 schrieb Colin Law:
> On Wed, 1 May 2024 at 21:52, Helmut Schneider via ubuntu-users
> <ubuntu-users at lists.ubuntu.com> wrote:
>> I need to replace a systemd script with an init script. I know I can
>> remove the existing one by
>>
>> SERVICE=$MY_SERVICE
>> sudo systemctl disable $SERVICE
> 
> None of the rest should be necessary. Once you have disabled it then
> it will not run automatically.  An upgrade to the package should not
> re-enable it, that would be bad form.

I have:

helmut at mail2:~$ sudo service amavis status
× amavis.service - Interface between MTA and virus scanner/content filters
      Loaded: loaded (/etc/systemd/system/amavis.service; enabled; 
vendor preset: enabled)

I want:

helmut at mail2:~$ sudo service amavis status
○ amavis.service - LSB: Starts amavisd-new mailfilter
      Loaded: loaded (/etc/init.d/amavis; generated)

> I am intrigued as to why you want to do this.

I want amavis / other apps running chrooted and with systemd I cannot 
accomplish that without bind-mounting /run into the chroot. I tried 
every single directory in /run to bind-mount but it doesn't work. I 
always get

(!)Net::Server: 2024/05/03-09:54:15 Couldn't chroot to "/var/amavis": 
Operation not permitted

where "Net::Server" can be replaced with any application I want to run 
chroot'ed.

What DOES work though is if I start amavis et.al. via init script. E.g. 
in /etc/init.d/amavis:

start-stop-daemon --start --oknodo -c $User --chroot /var/amavis --user 
amavis --group amavis --exec $DAEMON --pidfile $THEPIDFILE --quiet -- -c 
$CLAMAVCONF --pid=$THEPIDFILE

works flawless.

I see no reason to mount everything in /run to the chroot environment 
and systemd-nspawn is OP for what I want.

 >> sudo systemctl disable $SERVICE

That unfortunatly doesn't help, it stops $SERVICE but does not replace 
the systemd script with the init script.





More information about the ubuntu-users mailing list