Template Variables (continued )

Hi guys

Having a small problem, I have a file in a skel directory that has to be copped each time a virtual server is created. The file contains several template variables. All of the variables are converted correctly except ${MYSQL_USER}. I noticed in the Template Variable Examples that there could be two methods and I have tried both without success (ignore the quotes below)

when I use “${MYSQL_USER}” I get “${MYSQL_USER}”

when I use “$MYSQL_USER” I get “1_USER”

I have been running further testing and if I add the variable above to the email created at the end of the “Create Virtual Server” process then all template variables are replaced correctly, for their values. It looks like this is a matter of order. Is there another way to get the ${MYSQL_USER} at the skel point in the process?

Thanks Allan

Status: 
Closed (fixed)

Comments

Ok, the problem here is that the $MYSQL_USER domain variable isn't worked out by Virtualmin until later in the creation process, after the /etc/skel copy has been done. The only work-around currently is to use ${USER} instead, which will be the same unless it is more than 16 characters long.

In the next Virtualmin release (3.81) I will fix this bug so that $MYSQL_USER can be used in skeleton files.

Thanks for the advice and thanks for the fix

Allan

Automatically closed -- issue fixed for 2 weeks with no activity.

I am posting this here because my next question is continuing this thread.

I note that at

http://www.virtualmin.com/documentation/id%2Ctemplate_variable_listing

it sais that

any custom fields will be available in variables named $FIELD_fieldname

Are custom fields available in skells directory?

And if they are how do I use them because none of the list below work?

$FIELD_fieldname ${FIELD_fieldname} $PARENT_DOMAIN_fieldname ${PARENT_DOMAIN_fieldname} $VIRTUALSERVER_fieldname ${VIRTUALSERVER_fieldname}

Thanks Allan

I am posting this here because my next question is continuing this thread.

I note that at

http://www.virtualmin.com/documentation/id%2Ctemplate_variable_listing

it sais that

any custom fields will be available in variables named $FIELD_fieldname

Are custom fields available in skells directory?

And if they are how do I use them because none of the list below work?

$FIELD_fieldname ${FIELD_fieldname} $PARENT_DOMAIN_fieldname ${PARENT_DOMAIN_fieldname} $VIRTUALSERVER_fieldname ${VIRTUALSERVER_fieldname}

Thanks Allan

Yes, they should work fine in files copied from /etc/skel .

Is any template substitution working in those files, like $DOM ? If not, do you have variable substitution enabled ?

Is any template substitution working in those files, like $DOM

Yes each of the following are being converted properly.

${DB} ${MYSQL_USER} ${PASS} ${OWNER}

If not, do you have variable substitution enabled ?

If you mean

Virtualmin> System Settings> Server Templates> Select the Templates> Edit template section: Home directory> Substitute variables in contents? Set to Yes

then yes.

Just to make sure I have the concept correct

I goto

Virtualmin> System Customization> Custom Fields>

and create custom fields like NumEmployees then where I want the variable replaced by the value entered when creating the virtual server, I put ${FIELD_NumEmployees} or ${VIRTUALSERVER_NumEmployees} and what I should get is the value entered in the custom field at the time the virtual server was created.

What I am getting is the variables itself.

${FIELD_NumEmployees} ${VIRTUALSERVER_NumEmployees}

Note the other variables that are being replaced correctly are in the same file.

I think I see it .. in the variable, the whole thing needs to be upper case, like ${FIELD_NUMEMPLOYEES}

Ahhh!

Yes you are correct. It now works.

Thanks For the help

Allan