Hi Jamie and Co,
We have a bash script ran after domain modification. The script itself is adding the user (when the added server is toplevel) to a different Cgroup depending on the virtual-server plan. So we get the plan IDs with the following command:
B=$(virtualmin list-plans |grep "plan name"|awk '{print$1}') - this should set plan ID in variable $B
Actually the after couple of checks the script delete (when parent domain is deleted) add (when parent domain is created ) or replace (when plan is changed) one line per user in the /etc/cgrules.conf and reload cgred service.
We use this script for maybe half a year but at some point (probably after vm update) it stop working as it should.
To find out what is going wrong I have added a log to the script and found something very strange.
If I add test domain from the VM UI this variable is set like it should - so everything fine. but if I add domain using the API this variable is not set I get empty result.
The question is how create domain API command is connected to "virtualmin list-plans" command line command and why during domain create it doesn't work.
The actual result of the command virtualmin list-plans is:
X-Frame-Options: SAMEORIGIN Content-Security-Policy: script-src 'self' 'unsafe-inline' 'unsafe-eval'; frame-src 'self'; child-src 'self' Content-type: text/html; Charset=UTF-8 <!doctype html public "-//W3C//DTD HTML 3.2 Final//EN"> <html> <head> <link rel='stylesheet' type='text/css' href='/unauthenticated/reset-fonts-grids-base.css'> <link rel='stylesheet' type='text/css' href='/unauthenticated/virtual-server-style.css' /> <!--[if IE]> <style type="text/css"> table.formsection, table.ui_table, table.loginform { border-collapse: collapse; } </style> <![endif]--> <script> var rowsel = new Array(); </script> <script type='text/javascript' src='/unauthenticated/sorttable.js'></script> <meta http-equiv="Content-Type" content="text/html; Charset=UTF-8"> <title>Security Warning</title> <script type='text/javascript'> window.defaultStatus="USER(changed) logged into Webmin 1.810 on s10.XXXXXXXXXXXg.com (CentOS Linux 6.8)"; </script> </head> <body bgcolor=#ffffff link=#376ebd vlink=#376ebd text=#000000> <table class='header' width=100%><tr> <td id='headln2l' width=15% valign=top align=left></td> <td id='headln2c' align=center width=70%><font size=+2>Security Warning</font></td> <td id='headln2r' width=15% valign=top align=right></td></tr></table> <b>Warning!</b> Webmin has detected that the program <tt>http://</tt> was linked to from an unknown URL, which appears to be outside the Webmin server. This may be an attempt to trick your server into executing a dangerous command.<p> Make sure your browser is configured to send referrer information so that it can be verified by Webmin.<p> Alternately, you can configure Webmin to allow links from unknown referers by :<ul><li>Login as <tt>root</tt>, and edit the <tt>/etc/webmin/config</tt> file.<li>Find the line <tt>referers_none=1</tt> and change it to <tt>referers_none=0</tt>.<li>Save the file.</ul><p> <p> <br> </body></html> <\code> the command outside the script is working properly. If there is a different way to do this please advice. It will be good if we can make this with a virtualmin plugin.
Comments
Submitted by george.asenov on Mon, 09/19/2016 - 09:30 Comment #1
Submitted by JamieCameron on Mon, 09/19/2016 - 10:24 Comment #2
The problem may be that when Virtualmin API commands are called from your script which is called from the UI, they still think they're running in the UI when really they aren't.
At the top of your script, try adding the following lines :
export SCRIPT_NAME=
export MINISERV_CONFIG=
Submitted by george.asenov on Tue, 09/20/2016 - 01:38 Comment #3
Hi Jamie.
With this lines at the top the script work as it should.
Submitted by JamieCameron on Tue, 09/20/2016 - 19:44 Comment #4
Ok, great!
Submitted by JamieCameron on Tue, 09/20/2016 - 19:44 Comment #5