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

Ability to run shell command instead/in addition to rcon commands. #2321

Open
Buco7854 opened this issue Aug 6, 2023 · 7 comments
Open

Ability to run shell command instead/in addition to rcon commands. #2321

Buco7854 opened this issue Aug 6, 2023 · 7 comments

Comments

@Buco7854
Copy link

Buco7854 commented Aug 6, 2023

Enhancement Type

Improve an existing feature

Describe the enhancement

Hello,
That would be really nice if we could have something like RCON_CMDS_STARTUP for shell so that we could for example add custom scripts in a volume and run them when some events are triggered.
I took a look to rcon-cmds-daemon.sh and I believe it could be easily adaptable for shell commands since it seems it just call the command prepended by rcon-cli.
Either we could add a secondary run_command function or just remove the prepend but it woudl kind of break compatibility so I guess first option is better.
Please let me know what you think about it and either way thanks for this wonderful image.

@itzg
Copy link
Owner

itzg commented Aug 6, 2023

That would certainly be quite doable. It feels like a security risk to allow arbitrary system commands to run; however, I can't pinpoint any particular exploit that couldn't already done by exec'ing into the container.

What are some examples of things you would want to script into those events? Arbitrary scripts would also have to make use of things pre-installed.

@Buco7854
Copy link
Author

Buco7854 commented Aug 6, 2023

That would certainly be quite doable. It feels like a security risk to allow arbitrary system commands to run; however, I can't pinpoint any particular exploit that couldn't already done by exec'ing into the container.

What are some examples of things you would want to script into those events? Arbitrary scripts would also have to make use of things pre-installed.

Well for example some kind of webhook when someone gets online for a friends server. that was my use case, but I mean anything can be done, just need the events and then it's up to anyone to develop whatever they feel like doing.

@Buco7854
Copy link
Author

Buco7854 commented Aug 6, 2023

It certainly is dependent on the container itself, but for example, Python is already pre-installed on quite a lot of them, and worst case we coudl use the startup event to run a script to install the dependencies.

@itzg
Copy link
Owner

itzg commented Aug 6, 2023

I am 100% on board with supporting webhooks. mc-image-helper can be enhanced in any way to streamline that.

It certainly is dependent on the container itself, but for example, Python is already pre-installed on quite a lot of them,

Well, in this case, this image
purposely hasn't installed python in order to try minimizing the image size.

and worst case we coudl use the startup event to run a script to install the dependencies.

That's starting to sound a little too arbitrary and makes me nervous. Besides, any extra packages installed will all go away on next container restart. It can take a minute or two to install packages -- that doesn't seem like an acceptable delay for event handling.

I will queue this up for considering webhook support, but even then I'd like to scope to a particular use case or two.

@Buco7854
Copy link
Author

Buco7854 commented Aug 6, 2023

I am 100% on board with supporting webhooks. mc-image-helper can be enhanced in any way to streamline that.

It certainly is dependent on the container itself, but for example, Python is already pre-installed on quite a lot of them,

Well, in this case, this image
purposely hasn't installed python in order to try minimizing the image size.

and worst case we coudl use the startup event to run a script to install the dependencies.

That's starting to sound a little too arbitrary and makes me nervous. Besides, any extra packages installed will all go away on next container restart. It can take a minute or two to install packages -- that doesn't seem like an acceptable delay for event handling.

I will queue this up for considering webhook support, but even then I'd like to scope to a particular use case or two.

Well I certainly see your point. Limiting it to webhooks seems fine for me. I guess receive event and then executing some command using rcon from outside for aditional data or would it send some actual data with the event ?

@itzg
Copy link
Owner

itzg commented Aug 7, 2023

Yeah, I'm thinking the webhook method (GET, POST, etc), URL, and body template string could be the input environment variables. That template can be JSON or whatever the receiver needs and substituted with certain variables: event type, player count, etc.

@Buco7854
Copy link
Author

Buco7854 commented Aug 7, 2023

Yeah, I'm thinking the webhook method (GET, POST, etc), URL, and body template string could be the input environment variables. That template can be JSON or whatever the receiver needs and substituted with certain variables: event type, player count, etc.

That seems like a good way, thanks for considering it 🙂.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants