Submitted by dukejustice on Sat, 04/09/2016 - 13:34
Hi.
I found server tempalte substitution not working for server templates.
For MySQL password, I tried all of these variations I found across multiple old & new virtualmin support pages.
$PASS
${PASS}
$MYSQL_PASS
${MYSQL_PASS}
None of them work. I never get a password substituted for any of those.
Is there a fix for this?
Regards.
Marc
Status:
Active
Comments
Submitted by andreychek on Sat, 04/09/2016 - 13:44 Comment #1
Howdy -- which field in the Server Templates are you trying to use those variables in?
Submitted by dukejustice on Sat, 04/09/2016 - 19:02 Comment #2
Hello.
These are used into /etc/skel/file.txt (for example) with option "Substitute variables in contents" enabled. Then, I'm creating a new domain or subdomain.
All other variables I've used yet work just fine. But the MySQL password.
Any help would be appreciated.
Regards.
Marc
Submitted by dukejustice on Wed, 04/20/2016 - 10:24 Comment #3
Hello.
I was just wondering if there were any follow-ups on this bug report.
Thanks in advance.
Regards
Marc Arbour
Submitted by JamieCameron on Wed, 04/20/2016 - 22:07 Comment #4
I assume that the domain that this problem happens for has MySQL enabled?
Submitted by dukejustice on Sat, 04/23/2016 - 18:29 Comment #5
Hello Jamie.
Yes indeed it has. Sorry. I should have mentioned it.
New information : when creating a domain, variable ${PASS} outputs 1_PASS. All 3 others are outputting an empty string. In the case of a subdomain, all four output an empty string.
Thanks for your help.
Regards
Marc.
Submitted by JamieCameron on Sat, 04/23/2016 - 18:36 Comment #6
Can you post the actual template here, or at least the parts that reference those variables? ${PASS} being replaced by 1_PASS seems like it might be caused by an error in the substitution.
Submitted by dukejustice on Sun, 04/24/2016 - 06:25 Comment #7
Sorry to ask : how can I post the template? It's part of virtualmin and I haven't found any options to export it.
If you mean the file in which I'v placed the variable to be replaced, Here it is:
In this first example, there are 4 different variables. 3 of them work fine.
#!/bin/bash
timetolock=$(mysql -u${MYSQL_USER} -p${MYSQL_PASS} -se "select option_value from ${DB}.siteinfo__options where option_name='filesystem_unlocker_plugin_options'");
isitlockedalready=$(mysql -u${MYSQL_USER} -p${MYSQL_PASS} -se "select option_value from ${DB}.siteinfo__options where option_name='filesystem_unlocker_plugin_lock_state'");
if [ $timetolock -gt 0 ] && [ $isitlockedalready -eq 1 ]
then
find ${HOME}/public_html/ -type d -exec chmod 755 {} \; && find ${HOME}/public_html/ -type f -exec chmod 644 {} \;
mysql -u${MYSQL_USER} -p${MYSQL_PASS} -se "update ${DB}.siteinfo__options set option_value = 0 where option_name='filesystem_unlocker_plugin_lock_state'";
fi
if [ $timetolock -eq 0 ] && [ $isitlockedalready -eq 0 ]
then
find ${HOME}/public_html/ -type d -exec chmod 555 {} \; && find ${HOME}/public_html/ -type f -exec chmod 444 {} \;
mysql -u${MYSQL_USER} -p${MYSQL_PASS} -se "update ${DB}.siteinfo__options set option_value = 1 where option_name='filesystem_unlocker_plugin_lock_state'";
fi
if [ $timetolock -gt 0 ] && [ $isitlockedalready -eq 0 ]
then
mysql -u${MYSQL_USER} -p${MYSQL_PASS} -se "update ${DB}.siteinfo__options set option_value = option_value-1 where option_name='filesystem_unlocker_plugin_options'";
fi
domaine=$(mysql -u${MYSQL_USER} -p${MYSQL_PASS} -se "select option_value from ${DB}.siteinfo__options where option_name='siteurl'");
echo ${domaine:7} > ${HOME}/domaine.txt
echo $timetolock > ${HOME}/timetolock.txt
and part of another one is
define('DB_NAME', '${DB}');
define('DB_USER', '${MYSQL_USER}');
define('DB_PASSWORD', '$PASS' '${PASS}' '$MYSQL_PASS' '${MYSQL_PASS}');
As you can see in the second, I've tried all variations of the variable I've found on all virtualmin forums pages from the past.
Thank you in advance.
Marc
Submitted by andreychek on Sun, 04/24/2016 - 08:00 Comment #8
Jamie, just to clarify -- the variables he's using aren't in the Server Template config itself.
He has files in /etc/skel/ containing those variables, and the option "Substitute variables in contents" is enabled.
Other variables are working, it's only the password related ones he's having trouble with.
Submitted by dukejustice on Sun, 04/24/2016 - 10:50 Comment #9
Hello.
Good summation andreychek.
Have a nice week end!
Regards
Marc
Submitted by JamieCameron on Sun, 04/24/2016 - 11:20 Comment #10
Are you using hashed passwords there (in which Virtualmin doesn't store the domain's plain-text password)? You can check by running
grep hashpass /etc/webmin/virtual-server/config
- if the output ishashpass=1
, then you are.Submitted by andreychek on Sun, 04/24/2016 - 11:23 Comment #11
Jamie, he was mentioning that he wasn't able to use MySQL passwords either though, using ${MYSQL_PASS}.
Is there another MySQL password variable he should be using if hashed passwords are in use?
Submitted by JamieCameron on Sun, 04/24/2016 - 11:25 Comment #12
I just checked, and there's a bug that prevents MYSQL_PASS from being available during
/etc/skel
file copying :-( This will be fixed in the next release though.Submitted by dukejustice on Sun, 04/24/2016 - 14:03 Comment #13
Hello Jamie.
Thanks for the heads up.
I will await the next release.
Have an excellent day.
Regards.
Marc.
Submitted by andreychek on Sun, 04/24/2016 - 14:07 Comment #14
That next release will be out soon! We're actually putting the final touches on a release to support the new Ubuntu version, but that same release will resolve the issue you're experiencing.