slub / ocrd_controller

Path to network implementation of OCR-D
MIT License
6 stars 3 forks source link

start-sshd.sh script is executed multiple times when starting the controller #34

Closed markusweigelt closed 8 months ago

markusweigelt commented 9 months ago

When the container is restarted without being removed, the start-sshd.sh script runs again.

The problem is that all configurations are appended to the configuration files, such as /.ssh/authorized_keys, /.ssh/rc, etc.

bertsky commented 9 months ago

Indeed! That is despite Dockerfile(5)'s documentation for CMD stating

The CMD instruction sets the command to be executed when running a container from an image.

Obviously, in fact CMD is executed when starting a container, which is subtly different.

bertsky commented 9 months ago

So what we have to do is check (in all these cases) if the file has already been written to last time.

markusweigelt commented 9 months ago

Perhaps here, simply checking for the existence of the file would suffice.

bertsky commented 9 months ago

perhaps here, simply checking for the existence of the file would suffice.

In the case of /.ssh/rc – yes, but for authorized_keys and passwd – no.

markusweigelt commented 9 months ago

Ok, but we can use /.ssh/rc as base condition to check if start-sshd.sh has already run. So, I think explicitly checking the other files is not necessary.

bertsky commented 9 months ago

Oh, right!