MYSQL_PASS is not substitute as MYSQL_USER and others vars in a file

I've a file in /etc/skel with templates vars to collect the configuration of the domain on creation. All the vars except MYSQL_PASS are substitute by the right content. It's working for the content of "Mail for domain"

It's important because you can't find again the password generated randomly in the UI like the main password. See the option: - System Settings - Server Templates - Edit Server Template - default template - MySQL database - MySQL password for new domains : Generate randomly

Example of file

DOM="${DOM}" IDNDOM="${IDNDOM}" USER="${USER}" GROUP="${GROUP}" PASS="${PASS}" IP="${IP}" OWNER="${OWNER}" EMAILTO="${EMAILTO}" HOME="${HOME}" ID="${ID}" PARENT="${PARENT}" UID="${UID}" GID="${GID}" PREFIX="${PREFIX}" QUOTA="${QUOTA}" UQUOTA="${UQUOTA}" BW_LIMIT="${BW_LIMIT}" BW_USAGE="${BW_USAGE}" RESELLER="${RESELLER}" DB="${DB}" MYSQL_USER="${MYSQL_USER}" MYSQL_PASS="${MYSQL_PASS}" RESELLER_DESC="${RESELLER_DESC}" DISABLED="${DISABLED}" DISABLED_WHY="${DISABLED_WHY}"

DIR="${DIR}" UNIX="${UNIX}" VIRT="${VIRT}" WEB="${WEB}" MAIL="${MAIL}" SSL="${SSL}" DNS="${DNS}" LOGROTATE="${LOGROTATE}" MYSQL="${MYSQL}" POSTGRES="${POSTGRES}" WEBALIZER="${WEBALIZER}" FTP="${FTP}" SPAM="${SPAM}" VIRUS="${VIRUS}" STATUS="${STATUS}"

And the result.....

DOM="mydomain.com" IDNDOM="mydomain.com" USER="mydomain.com" GROUP="mydomain.com" PASS="abcdefghijklmno" IP="10.10.10.10" OWNER="description" EMAILTO="contact@mydomain.com" HOME="/home/webs/mydomain.com" ID="144250798520758" PARENT="" UID="1011" GID="1009" PREFIX="mydomain.com" QUOTA="5242880" UQUOTA="5242880" BW_LIMIT="" BW_USAGE="${BW_USAGE}" RESELLER="" DB="mydomain_com" MYSQL_USER="mydomain.com" MYSQL_PASS="" RESELLER_DESC="${RESELLER_DESC}" DISABLED="" DISABLED_WHY="${DISABLED_WHY}"

DIR="1" UNIX="1" VIRT="0" WEB="1" MAIL="0" SSL="1" DNS="0" LOGROTATE="1" MYSQL="1" POSTGRES="1" WEBALIZER="1" FTP="0" SPAM="0" VIRUS="0" STATUS=""

My version : Vistualmin 4.18 gpl on Ubuntu 14.04

Status: 
Active

Comments

It works well when a script is executed after creating the server

script set here : - System Settings - Virtualmin Configuration - Actions upon server and user creation - Command to run after making changes to a server

So is your aim to create files in the user's home directory that contain the mysql password?

The reason this doesn't work is that Virtualmin first populates the home dir, and only chooses the random MySQL password later in the creation process.