Disable default index.html in Virtualmin GPL

Hello!

As of virtualmin 6.10 the (new?) feature of setting up a default landing page for new servers is causing some serious issues with my workflow. I have some level of automation taking place where a new server is created and wordpress is auto-installed for a client.

The inclusion of the default index.html takes priority over the index.php of the wordpress script which breaks the entire flow for the user.

Is there any way to stop this or to go back to the previous version of Virtualmin where this was not present?

I am also using a skeleton directory for some custom wordpress files, but not sure how to REMOVE this index.html from the directory as it’s not part of the skeleton directory.

Any help is greatly appreciated.

“Boo” to this update :frowning:

My temporary solution to solve this:

edit /usr/share/webmin/virtual-server/domain_setup.cgi

Commented out lines 487 - 504

There has got to be a better way. Is there a way to run some script after a server install to delete the index.html file in the home directory so I’m not modifying virtualmin files?

1 Like

https://www.virtualmin.com/documentation/developer/prepost

1 Like

I would just like to register our own “boo” to this update as well, and request that there be a way added to skip this new behavior. We’re in exactly the same boat as OP and, in addition to index.html being populated against our desires, it also removes the WordPress-specific index.php file that had previously been there (thanks to create_index_content()).

Otherwise, why bother with templates at all if you’re going to blow away stuff that the template does, and the “solution” is to reapply the affected files from the template with yet another script?

Also, it appears this does not work as described.

Script:

#!/bin/bash
if [ "$VIRTUALSERVER_ACTION" = "CREATE_DOMAIN" -a ! -z "$VIRTUALSERVER_HOME" ]; then
  cd $VIRTUALSERVER_HOME
  rm -f public_html/index.html
  cp -a /etc/skel-wp/public_html/index.php public_html/index.php
  chown $VIRTUALSERVER_USER:$VIRTUALSERVER_GROUP public_html/index.php
fi

Configuration:

Results:

[root@sandbox ~]# ll /home/pcgtest/public_html/index.*
-rw-r--r-- 1 pcgtest pcgtest 985717 Aug 12 13:01 /home/pcgtest/public_html/index.html
-rw-r--r-- 1 pcgtest pcgtest    405 Feb  6  2020 /home/pcgtest/public_html/index.php

The timestamp on index.php matches the template (/etc/skel-wp/public_html/index.php) exactly, so that’s definitely happening. I was executing long listings of the public_html/ folder in quick succession and it went from:

-rw-r--r--  1 pcgtest pcgtest   405 Aug 12 13:00 index.php

to:

-rw-r--r--  1 pcgtest pcgtest     0 Aug 12 13:01 index.html.webmintmp.14449
-rw-r--r--  1 pcgtest pcgtest   405 Feb  6  2020 index.php

to:

-rw-r--r--  1 pcgtest pcgtest 985717 Aug 12 13:01 index.html
-rw-r--r--  1 pcgtest pcgtest    405 Feb  6  2020 index.php

So you can see the copy of index.php happened… and index.html was populated after my post script ran. So it appears this isn’t a viable solution at all. :frowning:

Can you please take another look at this and let us know what the appropriate approach should be? Thanks!

@Ilia can you take a look at this? We shouldn’t be overriding existing indexes in /etc/skel, including index.php. And, if it’s running after the postcreate hook, that’s a bug. Post-script should happen after anything Virtualmin is doing. That’s the point of it.

The problem was the order DirectoryIndex is read. It always started with index.html and hit it first, even if index.php exists. That’s what is happening now, the files from /etc/skel are copied but Apache prefers existing index.html to index.php. The workaround would be is to tweak Apache DirectoryIndex directive. Linked patch will address this issue for new installs.

And, if it’s running after the postcreate hook, that’s a bug. Post-script should happen after anything Virtualmin is doing.

It appears that it is infact creating landing index.html after post script is run.

To be fair, I might have also misread this code in create_index_content and/or misremembered some testing wherein I thought index.php was being deleted, not just overridden:

# Remove any existing index.* files that might be used instead
local $dest = &public_html_dir($d);
if ($over) {
        local @indexes = grep { -f $_ } glob("$dest/index.*");
        if (@indexes) {
                &unlink_file(@indexes);
                }
        }

And, if it’s running after the postcreate hook, that’s a bug. Post-script should happen after anything Virtualmin is doing.

It appears that it is infact creating landing index.html after post script is run.

I’m glad to hear I’m not going crazy, and it’s good to know this will be getting addressed. Thanks!

Okay, is it really deleted? What do you actually see under ~/public_html after creating new virtual server? Is index.php file there, just as our landing index.html page?

Both files are there and, as you discussed, index.html is simply overriding index.php. The problem still exists that the post script runs before index.html gets created and, thus, is unable to delete it. (Yes, it would be easy enough to prefer index.php via DirectoryIndex but I’d still like to not leave public_html/ polluted when we’re already supplying our own data.)

This I could reproduce. I will see what we can do about it.

But I’d still like to not leave public_html/ polluted when we’re already supplying our own data

Yes, sure thing.

@Jamie Jamie, can we move this part to create_virtual_server() sub, to make sure the post-commands are really catching on it?

I just checked in a fix for this - basically, if an index.* files exist then we won’t over-write them when setting default content.

Okay, I understand now what was the initial intent. What if a user wanted to keep both (or more) files, and use Virtualmin landing page as a default fall back?

@Jamie Jamie, can we move this part to create_virtual_server() sub, to make sure the post-commands are really catching on it?

What about the fact that post-command is executed before coping skel files? Should that be fixed?

Yeah, the content creation should really be done inside create_virtaul_server. I’ll fix that.

Do you have a version number assigned yet that will incorporate these changes? I’d like to keep my eyes out for it so that we can test it with our clients. Thanks!

Yes, they should be in 6.12

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.