Submitted by wocul on Mon, 09/08/2014 - 12:02
Custom commands are very flexible to set up custom sets of commands that may require dynamic state, it would be pretty cool if custom commands could be set up via the cron job module, i.e. by registering the command to be scheduled/invoked via cron.
This could be a first step towards supporting multi-stage migrations
Status:
Active
Comments
Submitted by JamieCameron on Mon, 09/08/2014 - 12:14 Comment #1
I don't quite get what you are asking here, sorry .. do you mean a custom command that doesn't get execute right away?
Submitted by wocul on Mon, 09/08/2014 - 14:54 Comment #2
right, a custom command that is set up via the usual "forms" for dynamic values, but that is scheduled to run later on via cron.
The point being that I am looking for a way to provide the infrastructure to build more complex functionality on top of existing webmin building blocks, such as multi-stage server migrations that involve checking some condition (e.g. TTL, rsync synchronization, mySQL replication), for which I'd then only need to be able to "chain" a handful of commands together, i.e. where another command may be scheduled/executed depending on the exit code of the previous command.
We've been discussing the basic idea at: http://www.virtualmin.com/node/31977
And given the feedback you've been providing, it would make sense to build such functionality on top of existing modules, like the custom commands module and the cron module.
Such a cron job would then use a webmin-specific wrapper script (or just pipes) to execute commands and pass the exit code back to the webmin/custom command module, so that it can decide whether to re-schedule a certain command (e.g. dig/TTL DNS check), or whether the next step/stage of the chain (e.g. server migration) can be initiated.
Similarly, existing functionality could be unified and re-implemented on top of this functionality, e.g. the backup system. So I am trying to think in building blocks to allow power users to develop more complex functionality on top of the webmin infrastructure.
Over time, people could help grow a library of their own custom commands, including "sets" of custom commands that are linked together in a conditional manner.
Thanks
Submitted by JamieCameron on Mon, 09/08/2014 - 15:15 Comment #3
You could in theory have a command be run in the future using the
at
command. Something like :at +3h virtualmin modify-web --domain $dom ....
This will return immediately, but schedule execution of the command for 3 hours from now.
Submitted by wocul on Mon, 09/08/2014 - 17:23 Comment #4
ok, but this involves creating the whole job via the shell, i.e. there's no built-in method to fill in the fields of a custom command and schedule it for later ? That is the kind of functionality I'm looking for, and exposing this to the web GUI would be kinda useful, because I am hoping to chain together several custom commands based on the exit code of the previous command.
Thanks
Submitted by JamieCameron on Mon, 09/08/2014 - 20:00 Comment #5
I'm still not quite clear what you are trying to do here, sorry.
However, a single custom command can run multiple shell commands separate by
;
Or you can use
&&
to only run the next command if the previous one succeeds.Submitted by wocul on Mon, 09/08/2014 - 20:50 Comment #6
Sorry for being apparently so unclear (and thanks for the lecture on shell scripting!)
But I would like to:
I am aware that I can accomplish this from bash/sh - but the point is that custom commands are useful, they're exposed via the webmin web GUI, but they aren't accessible via the webmin/cron UI.
Thus, the whole point is to define a few custom commands with well-defined parameters and allow those to be invoked via the cron panel to populate each field and then add the corresponding command to the crontab.
Like I mentioned previously, the mid-term idea is to use these features in combination, so that multi-stage server migrations can be automated by running a chain of custom commands that may be re-registered in a recurring fashion, until a certain condition is true (e.g. DNS/TTL check) to trigger the next stage of the process.
I am aware that you guys tend to suggest using either shell scripts directly, or even writing Perl - but the whole point of this is to use webmin, so that webmin is aware of what is done, not via some "black box" shell script that it knows nothing about.
Once custom commands can be registered to be invoked via cron, we could grow a library of useful commands and use this library to build more complex functionality on top and chain those together.
The point is not that we can accomplish the same thing via shell/perl scripts - the issue is that we want to be able to reuse webmin's UI, so that more complex processes can be implemented - imagine migrating a LAMP website with 3 domains, including 1500 gb of files, and 500 mb of mySQL data.
For the time being, there is no workflow available to automate this kind of process, short of writing a custom script for each website - however, once these building blocks are in place, we'd have the infrastructure to allow arbitrary websites to be migrated using a library of "primitives" that are merely customized via the webmin UI.
Submitted by JamieCameron on Tue, 09/09/2014 - 19:18 Comment #7
Ok, I think I see what you are getting at here - however, this kind of "app builder" isn't really on our roadmap currently. You may be better off writing a small Webmin module that calls the Virtualmin API functions, or schedules them to execute via cron. The amount of Perl scripting involved isn't that bad ..