Created
February 6, 2019 17:50
-
-
Save zone117x/54ed58d51f41360df5ab446f5694298e to your computer and use it in GitHub Desktop.
ErbjQE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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="[email protected]"> | |
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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