I want to build a simple webpage which should work as a remote control. For instance, when the user click a button on the page, a certain bash command will be executed in the server.
May I get some suggestion of how to start? Some key words to search or example project will be appreciated.
A little dangerous to have a web interface for bash commands, but still…
You just need to create a plugin with some custom actions or tasks that call PHP’s
The admin plugin however has lots of ajax calls that are happening when you click things (like clear cache), so you can dig into the admin plugin to see how those are processed.
As @rhuk points out, an interface for direct commands is inadvisable unless expressly for system administrators who know exactly what they are doing. Even then, they should be using a regular terminal via SSH. Rather, you want buttons that send preset commands to the server via an API, which are validated and authorized on both ends.
Depending on how tightly you couple this with Grav, you’ll want an API (like REST) to execute when a call is made to something like /api/command/flush. You’ll create and test these commands in PHP as POST-requests, then afterwards write the interface for them. I am working on a Laravel-project doing something similar currently, which handles the API-part marvelously easily. The interface is written with VueJS, and together they make authorization and validation easy to create and maintain.
As much as I love Grav, I think you are headed down the wrong path. Grav is for managing content; it looks like you just need a page or two with buttons. Look into php frameworks like Slim or Laravel, or just use plain PHP. If you are just getting started, you should code this in plain PHP and move the code into a framework if you find you need it. Unlike Ruby and Python, you do not need a framework with PHP.