Make and Unmake Sites, Automated; Single-Domain Version

This post is similar to Make and Unmake Sites, Automated with the difference that this is for a single-domain server created in Spinning up a single-domain web and email server.

Making a site in this version is a lot faster, as we already have the wildcard certificate for the domain we do not need to wait for CertBot to get a new one from Let’s Encrypt.

Let’s go over the sections of the script in detail first.

The above sets up our colors for the bash shell.

We ask the user for the subdomain, and append that to the domain.

Create the index.html file and set the ownership of the new folder to the www-data group.

Make the two config files for Apache.  One for the http connection, and the other for https.  The http forwards to the https, and we use HSTS.

Finally we reload Apache to bring the new subdomain online.

Here is the full make-site.sh file


Removing the subdomain is super easy.  We just delete the files and site root, after asking Apache to disable the subdomain.

The repository for this post can be found on GitLab here .

The repository for this post can be found on Lupe Code’s GitLab mirror here .