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 trigger basic scripts #1113

Closed
AlexGuld opened this issue Jun 29, 2023 · 8 comments
Closed

Ability to trigger basic scripts #1113

AlexGuld opened this issue Jun 29, 2023 · 8 comments
Labels
✨ Feature A feature you'd like to be added

Comments

@AlexGuld
Copy link

Description

I would be really cool if it's possible to add a way to trigger basic scripts on the host. as an example: trigger a shutdown script to shutdown other servers/devices on the network. So the user creates a script on the host, and places it in a script folder that Homarr then discovers and makes available for the user to add as either a widget or an app.

Priority

Low (Nice-to-have)

@AlexGuld AlexGuld added the ✨ Feature A feature you'd like to be added label Jun 29, 2023
@manuel-rw
Copy link
Collaborator

That comes with possible security concerns. We should really be careful about stuff like that...

@AlexGuld
Copy link
Author

ohh right, that is of course an issue, where it could be used by malicious people to gain access, if not done correctly, if at all possible...

The idea was just to be able to shutdown/restart other equipment that is already controlled through ssh. Simply instead of having to open a terminal and login, issue command and close terminal, then just have buttons/apps that when pressed triggers the action in the background for easy management.

But understand if it's not easy to implement and/or add security risks that compromises Homarr and the host/network.

@ajnart
Copy link
Owner

ajnart commented Jul 3, 2023

ohh right, that is of course an issue, where it could be used by malicious people to gain access, if not done correctly, if at all possible...

The idea was just to be able to shutdown/restart other equipment that is already controlled through ssh. Simply instead of having to open a terminal and login, issue command and close terminal, then just have buttons/apps that when pressed triggers the action in the background for easy management.

But understand if it's not easy to implement and/or add security risks that compromises Homarr and the host/network.

I am not sure how possible this is. Can you turn off equipment on your PC with SSH inside of a container ?
Like the console inside of Homarr might not have access to your network devices since it's on it's own network (Docker)

But I'm pretty sure if you have minimal JavaScript knowledge I can help you make something like this.
Like have an URL that, when started, will turn on/off your servers

@ajnart
Copy link
Owner

ajnart commented Jul 3, 2023

How to make a script to On/Off your devices

  • Make an API in javascript to have something like localhost:4000/api/turnOff?deviceid={deviceId} (or turnOn)
  • Make the API a get request so that you can trigger it by opening the link
  • Make the page close itself with window.close() when the action is done
  • Add an app to homarr with the URL and an icon of a green / red button
  • Now when you click the link it will open the page, do the GET request to the api and then the page will close itself once done.

I hope these instructions are clear. I am pretty sure you can use ChatGPT to code the API even if you have very little code knowledge.

@AlexGuld
Copy link
Author

AlexGuld commented Jul 9, 2023

Nice, I will try that and see what it brings, and update here with my findings, perhaps others can make use of it.

@ajnart
Copy link
Owner

ajnart commented Jul 21, 2023

Did you manage to do it ?

@taos15
Copy link
Contributor

taos15 commented Jul 24, 2023

I think this inply that you are running an API server on the devices that you want to turn off> ## How to make a script to On/Off your devices

  • Make an API in javascript to have something like localhost:4000/api/turnOff?deviceid={deviceId} (or turnOn)

  • Make the API a get request so that you can trigger it by opening the link

  • Make the page close itself with window.close() when the action is done

  • Add an app to homarr with the URL and an icon of a green / red button

  • Now when you click the link it will open the page, do the GET request to the api and then the page will close itself once done.

I hope these instructions are clear. I am pretty sure you can use ChatGPT to code the API even if you have very little code knowledge.

@Meierschlumpf
Copy link
Collaborator

Moved to homarr-labs/homarr#2385

@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in Homarr Kanban Mar 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature A feature you'd like to be added
Projects
Status: ✅ Done
Development

No branches or pull requests

5 participants