Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Improve "registering" the maintenance.sh script #390

Closed
agross opened this issue Oct 14, 2023 · 7 comments
Closed

[Feature Request]: Improve "registering" the maintenance.sh script #390

agross opened this issue Oct 14, 2023 · 7 comments
Labels
enhancement It's not a bug, but it's worth an enhancement.

Comments

@agross
Copy link
Contributor

agross commented Oct 14, 2023

Description / Beschreibung

Instead of registering the maintenance script (/opt/scripts/maintenance.sh) as a Bash alias, symlink the script to /bin (in all variants like m, maint, maintenance).

Why?

  • docker exec <iob-container> maint yields "maint": executable file not found in $PATH
  • You need an interactive shell with a terminal attached to be able to execute the script, which makes the process more complicated than it needs to be: docker exec -t <iob-container> bash -ic maint

By symlinking the executable to e.g. /bin/maint in the Dockerfile running the maintenance script becomes trivial:

$ docker exec -u 1000:1000 <iob-container> maint
This script helps you manage your ioBroker container!
...
@agross agross added the enhancement It's not a bug, but it's worth an enhancement. label Oct 14, 2023
@buanet
Copy link
Owner

buanet commented Oct 14, 2023

Sounds good. Have you tried the new option to call the maintenance script with the help of iobroker command?
iob maint or iobroker mint
Is this working with docker exec?

Regards,
André

@agross
Copy link
Contributor Author

agross commented Oct 14, 2023

Is this working with docker exec?

It is, and it either does not check whether the command is executed with uid iobroker or it automatically changes to that user.

$ docker exec iobroker-app-1 iob maintenance
This script helps you manage your ioBroker container!
...

@buanet
Copy link
Owner

buanet commented Nov 3, 2023

This enhancement is included in v9.1.0-beta.1.
Feel free to test. :)

Regards,
André

@buanet buanet closed this as completed Nov 3, 2023
@agross
Copy link
Contributor Author

agross commented Nov 3, 2023

Thanks, working as intended.

Not sure why the symlink is not set up once in the Dockerfile, though. Does it really need to be re-setup on every start of the container?

On top of that, if the symlink already exists from a previous run, setting up the symlink again will fail. Since iobroker_startup.sh sets the errexit option I guess starting the container a second time might fail. Even if it doesn't fail because of Bash's option inheritance quirks, the container will log the error message below.

agross@pi ~
$ ln -s ~/.bashrc ~/foo

agross@pi ~
$ ln -s ~/.bashrc ~/foo
ln: failed to create symbolic link '/home/agross/foo': File exists

agross@pi ~
$ echo $?
1

@agross
Copy link
Contributor Author

agross commented Nov 3, 2023

I just noticed that symlinking is guarded by an if. Still, I don’t see why the container should set up things that can be handled during image creation.

@buanet
Copy link
Owner

buanet commented Nov 3, 2023

I just noticed that symlinking is guarded by an if. Still, I don’t see why the container should set up things that can be handled during image creation.

True. The if makes sure this runs only once...

The registering of the script is done to the startup procedure because it was the easiest way as this was implemented. 😄 Originally the script was undocumented and just to support my lazy side... It was not planned to make this available for public...

I'll put this on my list. It's a good idea to put this into the dockerfile.
Thank you.

Regards,
André

@buanet buanet reopened this Nov 3, 2023
@buanet
Copy link
Owner

buanet commented Nov 6, 2023

Done in v9.1.0-beta.2.
Thank you!

@buanet buanet closed this as completed Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement It's not a bug, but it's worth an enhancement.
Projects
None yet
Development

No branches or pull requests

2 participants