public_html folder owner and group messes up with "virtualmin create-domain" command

Just to let you know... when I use virtualmin create-domain on the command line, the public_html folder does not get created with the correct permissions or owner all the time... twice it had two different results..

First time, the group was set to nobody, so I had permission denied for the new website, and second there was no owner assigned to it, and the group was an ID rather than a name.

Both times I manually chown and chgrp but think it may be an issue to investigate.

Oh, one thing, the "virtualmin create-domain" command was called via a SSH connection from another server in a bash script... that ssh login would have been root, then it would have called the "virtualmin create-domain". Dont know if its related.




Howdy -- thanks for your report!

The domain(s) that you were creating, where they top-level Virtual Servers? Or were they Sub-Servers?

Hmm, I don't seem to be able to reproduce that... when I use create-domain on my test system here, the directories within that account are created with the correct user and group ownership.

Is there any chance we could take a look at your script that's creating those domains?

I'm curious if there's anything that it's doing differently from the test I tried that might be triggering the problem you're describing.

My office server holds this bash script and then connects to the destimation server to create the Virtualmin server, then connects to the source to move files and databases across.

Basically I want to move non-Virtualmin accounts into Virtualmin and this saves me a LOT of time fussing with manually transferring data and databases. I run the script, then when its done all I need to do is update config files (my next step is automate the updating of common config files, but probably wont bother with that).

set -e

New Site Settings


Source Server Details

source_server="" source_username="accountname" source_db="account_website"

Destination Server Details

dest_server="" dest_username="domainname" dest_db="domainname" dest_pass="123456789" dest_desc="Site Description" dest_sqlpass="987654321"


ssh root@"$dest_server" "virtualmin create-domain --domain $site_domain --pass $dest_pass --desc '$dest_desc' --unix --dir --webmin --web --mail --mysql --limits-from-plan --mysql-pass '$dest_sqlpass' --fwdto ''"


ssh root@"$source_server" "rsync -avz -e ssh --progress /home/$source_username/public_html/ root@$dest_server:/home/$dest_username/public_html/"


ssh root@"$source_server" "mysqldump $source_db > /home/$source_username/$source_db.sql"


ssh root@"$source_server" "scp /home/$source_username/$source_db.sql root@$dest_server:/home/$dest_username/$dest_username.sql"


ssh root@"$dest_server" "mysql $dest_db < /home/$dest_username/$dest_username.sql"

Oh you got markdown going on or something, its changed my script, maybe you can still make sense

The rsync wouldn't change the parent directory would it? Just occured to me. I put a slash after it assuming it will rsync everything inside

The rsync wouldn't change the parent directory would it? Just occured to me. I put a slash after it assuming it will rsync everything inside

In theory, Virtualmin should be treating all the files and directories within your homedir the same way.

So if one dir is wrong, they should all be wrong.

With that thought in mind -- as I read through your script, what you mentioned about rsync is the first thought that popped into my head, that the rsync may be changing the user/group permissions of the public_html folder.

One option would be to try performing the rsync as the user who owns the files... but then you'd need to use a password or have an SSH key setup for each of them.

Another option would be to add a chown to your script after the rsync runs, so that it automatically performs a chown afterwards.

Yes I was going to add a chown and chgrp anyway, the owner was not always the same as the virtualmin one (but sometimes was, weird).

I will also remove rsync as a test next time I do it, and manually run it after, see if it changes. I did not think of that when raising this issue sorry, should have done that first.

One thing... would be great if virtualmin had something like this built in! i.e. create a new server by pulling in files and databases from elsewhere! I know you have the CPanel import but I didnt want to do that, just bring in files and databases only. I read online some people had issues with cpanel imports and didnt want to risk it hence this basic script.

Virtualmin actually has an "import" feature already, which can be used if you have already manually created a user and maybe a DNS domain and Apache website. You can find it at Add Servers -> Import Virtual Server.

But thats if its on the same server isnt it? I am moving sites from another server.