Skip to content

Instantly share code, notes, and snippets.

@zone117x
Created February 6, 2019 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zone117x/54ed58d51f41360df5ab446f5694298e to your computer and use it in GitHub Desktop.
Save zone117x/54ed58d51f41360df5ab446f5694298e to your computer and use it in GitHub Desktop.
ErbjQE
<h4>Input</h4>
<label for="domain">Domain name: </label><input id="domain" type="text" placeholder="example.com">
<br>
<label for="email">Email: </label><input id="email" type="text" placeholder="example@test.com">
<br>
<br>
<input id="cert-valid" type="radio" name="cert-group" checked>
<label for="cert-valid">Request valid SSL cert</label>
<br>
<input id="cert-staging" type="radio" name="cert-group">
<label for="cert-staging">Request staging SSL cert</label>
<br>
<br>
<br>
<hr>
<h4>Output</h4>
<textarea id="output" rows="20" cols="100" readonly></textarea>
function getOutput(domain, staging, email) {
return `{
"ignition": { "version": "2.2.0" },
"systemd": {
"units": [
{
"dropins": [
{
"contents": "[Service]\nExecStartPost=/bin/sh /gaia/docker/nginx/certbot/letsencrypt.sh",
"name": "10-gaia-hub.ssl"
}
],
"name": "gaia-hub.service"
}
]
},
"storage": {
"files": [{
"filesystem": "root",
"path": "/etc/environment",
"mode": 420,
"contents": {
"source": "data:text/plain;charset=utf-8,DOMAIN%3D${domain}%0D%0ASTAGING%3D${staging}%0D%0AEMAIL%3D${email}"
}
}]
}
}`;
}
function updateOutput() {
const domain = document.getElementById('domain').value;
const staging = document.getElementById('cert-valid').checked ? '0' : '1';
const email = document.getElementById('email').value;
document.getElementById('output').innerHTML = getOutput(domain, staging, email);
}
[...document.getElementsByTagName('input')].forEach(el => {
el.addEventListener('change', () => updateOutput());
el.addEventListener('keypress', () => updateOutput());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment