Last updated: 2024-08-28 20:39:04
The below sensitive variables must be defined for these scripts to operate. Create a /.env file with the correct values for the following variables:
In /.env
:
Variable | Description |
---|---|
SERVER |
Virtual machine public IP |
SERVER_NAME |
Domain name (set with correct DNS settings defined) |
USER |
Name for the user that will replace ubuntu for administration |
SSH_KEY |
Path to the private SSH key |
CF_API_TOKEN |
CloudFlare API token with the assigned domain's DNS editing permissions |
ZONE_ID |
The zone id of the assigned domain name |
RECORD_ID |
The DNS record ID number that needs updating on restart |
RECORD_NAME |
The DNS record name number that needs updating on restart |
/settings.sh will then source your /.env file and export it's variable values to it's runtime environment for the scripts to use. /settings.sh also defines some non-sensitive variables vales that the scripts may use.
./setup.sh -h
` in terminal and read ./setup.sh's help options.USER=deploy ./setup.sh
in terminal (without arguments runs all units & steps).
you must define USER variable in terminal commands with the username that you wish
to create on the server and run deployment from, otherwise USER will be set to your
local machine's user name!.
USER=deploy ./deploy.sh
in terminal to execute the deploy script.
again, you must define USER in the terminal execute command (set as the same user
that you setup in setup.sh).
You must have an index.html file in the same directory as the deploy.sh script
file - this is the HTML file that you are deploying to the server.
To serve via HTTPS, you must manually configure the server to do so, by doing the following:
Cert; scp -i ~/path/to/your/ssh-keypair.pem ~/path/to/your/ssl_certificate.crt [email protected]:/home/ubuntu
Key; scp -i ~/path/to/your/ssh-keypair.pem ~/path/to/your/ssl_certificate_key.key [email protected]:/home/ubuntu
i.e., sudo mv ~/ssl_certificate.crt /etc/nginx/ssl/ssl_certificate.crt
i.e., sudo mv ~/ssl_certificate_key.key /etc/nginx/ssl/ssl_certificate_key.key
sudo chmod 600 /etc/nginx/ssl/ssl_certificate_key.key
sudo chown www-data:www-data /etc/nginx/ssl/ssl_certificate_key.key
See example of a server context setup for SSL in this repo; 'nginx/sites-available/default'
curl -X GET "https://api.cloudflare.com/client/v4/zones" -H "Authorization: Bearer YOUR_API_TOKEN" -H "Content-Type: application/json"
curl -X GET "https://api.cloudflare.com/client/v4/zones/YOUR_ZONE_ID/dns_records" -H "Authorization: Bearer YOUR_API_TOKEN" -H "Content-Type: application/json"
systemctl status dns_update.service
to check that the systemd service has been created (it should be loaded
and enabled, but inactive because it only runs on restart). If the systemd service was created successfully, then the DNS records will
now be automatically updated via Cloudflare's API on each server restart.