Hi all again, I wanted to thank those that helped me out when I was first getting my head around Virtualmin @calport and @tpnsolutions. I was able to get the students sites setup as virtual servers and with a default page and all.
I was able to also get the API working in my favour as well. I have a script that I will share that might help somebody else in the future on batch creating websites on the fly.
This is a bash script takes a csv input file, that contains the following information
Name, StudentID, Password
This is a basic script with no error handling
Provided as is, use at own risk.
importstudents.sh ----------------------------------------------------------------- #!/bin/bash # Purpose: Import a spreadsheet to batch create student sites # Author: Jay Calvert # February 12 2021 # ------------------------------------------ INPUT=$1 OLDIFS=$IFS IFS=',' [ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; } while read studentname id password do #echo "Student Name : $studentname" #echo "ID : $id" #echo "Password : $password" #Generate the url domain=".<tld>" # replace with the domain name that the virtualsite will be a member of url="${id}${domain}" echo "URL : $url" # Create the site echo "Found Records " echo "----------------------" echo "Creating website and username for: $id" virtualmin create-domain --domain ${url} --unix --dir --web --quota 50000 --uquota 50000 --user ${id} --pass ${password} echo "Website Created for $studentname" echo "User setup: $id" echo "Domain created: $url" echo "Creating DNS Entry" # Add the entry into DNS echo -e "server <dnsserver>\nupdate add $url 86400 A <ipaddress>\nsend" | nsupdate echo "---------------------" done < $INPUT IFS=$OLDIFS
Change <tld>
with your top level domain name
Change <dnsserver>
to the DNS server you are writing the update to, in mycase it is a separate windows server on the same network.
Change <ipaddress>
to the ip address you are assigning the website to use.
To Run the command:
> # ./importstudents.sh students.csv
Hope this helps everybody in their similar tasks.