Automatically create Samba share upon Virtual Server creation

I run Virtualmin GPL on a development server and share files via Samba. Every time I add a new virtual server, I have to manually add the Samba share through Webmin->Servers->Samba Windows File Sharing->Edit Config File.

All I need to do is add [domain] path=/home/domain/public_html at the end of the file. Is there an easy way of automating this?

Thanks.

Operating system: Ubuntu
OS version: 20.04.1

In Virtualmin -> System Settings -> Virtualmin Configuration: Advanced you could use the ‘Command to run after making changes to a server’ box to execute a command or run a script to append an entry to your Samba config. You could use environmental variables such as VIRTUALSERVER_DOM, VIRTUALSERVER_IP, VIRTUALSERVER_USER, VIRTUALSERVER_HOME, VIRTUALSERVER_PASS, and more. Any variable found in the /etc/webmin/virtual-server/domains/$DOM file will be available as an environment variable. Also see https://www.virtualmin.com/documentation/developer/cli

3 Likes

Thanks, I’ll check it out.

… most modules which involve user management, like MySQL, Samba and etc, have an option to automatically synchronize its users upon new UNIX user creation :

Hi, thanks. At the moment, I don’t need to create any users. I have a dev.test domain and all sites are a sub-server so have the same user (dev). I want to be able to automatically create a share to the sub-servers public_html directory.

Oh, right sorry. I was thinking that it was new users, while you were asking about shares.

you can do it manually or write some simple bash script and run it to do it for you.

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