Compare commits

...

12 Commits

Author SHA1 Message Date
5gi
e2511e77e1 added the install of libbrotli-dev
for some reason it refuses to install without it
2024-03-10 14:38:06 -04:00
5gi
2ed63b080d Merge pull request 'Wrong production url... 💀' (#4) from 5gi/NginxInstaller:master into master
Reviewed-on: Steven/NginxInstaller#4
2023-12-21 16:26:32 -05:00
5gi ☑
3389142e00 Merge remote-tracking branch 'origin/master' 2023-12-21 16:25:46 -05:00
5gi ☑
a53beb587f Wrong Production URL 2023-12-21 16:25:34 -05:00
5gi
13afdbcea1 Merge pull request 'Added Version checking to verify that a version of NGINX exists. Adds nginx download page to cache. Also added a few check before sending requests to the API. No visual Changes' (#3) from 5gi/NginxInstaller:master into master
Reviewed-on: Steven/NginxInstaller#3
2023-12-21 16:16:43 -05:00
5gi
ebb49da74e Merge branch 'master' into master 2023-12-21 16:16:33 -05:00
5gi ☑
00e5c29393 Forgot to change it off debug. 2023-12-21 14:32:11 -05:00
5gi ☑
1653e2dfae Merge remote-tracking branch 'origin/master' 2023-12-21 14:30:53 -05:00
5gi ☑
af522307e8 Added Version checking to verify that a version of NGINX exists. Adds nginx download page to cache. Also added a few check before sending requests to the API. 2023-12-21 14:30:24 -05:00
5gi
530af2717f Merge pull request 'Modified scripts and added some tooltips. Made it so that NGINX version is required instead of URL.' (#2) from 5gi/NginxInstaller:master into master
Reviewed-on: Steven/NginxInstaller#2
2023-12-20 18:39:19 -05:00
5gi
8db5a839e6 Merge branch 'master' into master 2023-12-20 18:35:37 -05:00
5907e78a68 Merge pull request 'Changed font and added some centered elements. Fixed spacing (padding and margin)' (#1) from 5gi/NginxInstaller:master into master
Reviewed-on: Steven/NginxInstaller#1
2023-12-20 14:52:07 -05:00

44
app.js
View File

@@ -1,5 +1,8 @@
document.getElementById("submit").addEventListener("click", generateQuickCmd, false); document.getElementById("submit").addEventListener("click", generateQuickCmd, false);
const debug = false; // DISABLE FOR PRODUCTION
const baseURL = debug ? "http://localhost:8081/ngx" : "https://api.nevets.tech/ngx";
const service = "[Unit]\n" + const service = "[Unit]\n" +
"Description=The NGINX HTTP and reverse proxy server\n" + "Description=The NGINX HTTP and reverse proxy server\n" +
"After=syslog.target network-online.target remote-fs.target nss-lookup.target\n" + "After=syslog.target network-online.target remote-fs.target nss-lookup.target\n" +
@@ -28,30 +31,41 @@ const service = "[Unit]\n" +
// } // }
// const sleep = ms => new Promise(r => setTimeout(r, ms)); // const sleep = ms => new Promise(r => setTimeout(r, ms));
async function getHTML() {
return fetch("corsurl" + encodeURIComponent("https://nginx.org/download/"))
.then((response)=>response.body.toString())
.then((responseJson)=>{return responseJson});
}
async function generateQuickCmd() { async function generateQuickCmd() {
let nginxStr = document.getElementById("link").value; let nginxStr = document.getElementById("link").value;
// if (!st.toString().includes(extractNginxVersion(nginxStr))) {
// document.getElementById("script").innerHTML = "ERROR!? Do you have a valid verison of NGINX?" + "\n<span class=\"tooltiptext\" id=\"myTooltip\">Copy to clipboard</span>";
// return;
// }
if (nginxStr === "") { if (nginxStr === "") {
document.getElementById("script").innerHTML = "ERROR!? Did you leave the NGINX Verison field blank?" + "\n<span class=\"tooltiptext\" id=\"myTooltip\">Copy to clipboard</span>"; document.getElementById("script").innerHTML = "ERROR!? Did you leave the NGINX Verison field blank?" + "\n<span class=\"tooltiptext\" id=\"myTooltip\">Copy to clipboard</span>";
return; return;
} }
let reqData = "{" + if (extractNginxVersion(nginxStr)===null || extractNginxVersion(nginxStr).includes("null")) {
"\"content\":\"" + encodeURI(buildCmd()) + "\"" + document.getElementById("script").innerHTML = "ERROR!? Regex could not find the version in the input field!" + "\n<span class=\"tooltiptext\" id=\"myTooltip\">Copy to clipboard</span>";
"}"; return;
}
fetch("https://api.nevets.tech/ngx/create", {
let reqData = "{" +
"\"version\":\"" + encodeURIComponent(extractNginxVersion(nginxStr)) + "\"" + "}";
let continueCycle = true;
await fetch(baseURL + "/dhv", {
method: "POST",
body: reqData,
}).then(res => res.json().then(json => {
if (json.url.includes("false")) {
document.getElementById("script").innerHTML = "ERROR!? Do you have a valid verison of NGINX?" + "\n<span class=\"tooltiptext\" id=\"myTooltip\">Copy to clipboard</span>";
continueCycle = false;
}
}));
if (!continueCycle) {
return;
}
reqData = "{" +
"\"content\":\"" + encodeURI(buildCmd()) + "\"" +
"}";
fetch(baseURL + "/create", {
method: "POST", method: "POST",
body: reqData, body: reqData,
mode: "cors"
}).then(res => res.json().then(json => { }).then(res => res.json().then(json => {
document.getElementById("script").innerHTML = "curl -s " + json.url + " | bash" + "\n<span class=\"tooltiptext\" id=\"myTooltip\">Copy to clipboard</span>"; document.getElementById("script").innerHTML = "curl -s " + json.url + " | bash" + "\n<span class=\"tooltiptext\" id=\"myTooltip\">Copy to clipboard</span>";
})); }));
@@ -77,7 +91,7 @@ function buildCmd() {
" exit\n" + " exit\n" +
"fi\n\n" + "fi\n\n" +
"apt-get update\n" + "apt-get update\n" +
"apt-get install -y build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev wget git\n" + "apt-get install -y libbrotli-dev build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev wget git\n" +
"wget https://nginx.org/download/nginx-" + extractNginxVersion(nginxStr) + ".tar.gz\n" + "wget https://nginx.org/download/nginx-" + extractNginxVersion(nginxStr) + ".tar.gz\n" +
"tar -xzvf " + "nginx-" + extractNginxVersion(nginxStr) + ".tar.gz\n"; "tar -xzvf " + "nginx-" + extractNginxVersion(nginxStr) + ".tar.gz\n";
if (document.getElementById("extMod").checked === true) { if (document.getElementById("extMod").checked === true) {