jasmeowthecat
Small Deno Script to upload to my server not working due to not being able to be run on CentOS
All my clients run Ubuntu or Debian, and the script will not run on CentOS due to the problem of a GLIBC problem. I saw online you can run a docker container but I am majorly confused and not a coder in the slightest, I just need to solve this solution as soon as possible.
The script looks like the below:
[root@atl-sql jasmeowsystems-uploader]# /root/.deno/bin/deno run -A index.js
/root/.deno/bin/deno: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /root/.deno/bin/deno)
[root@atl-sql jasmeowsystems-uploader]# /root/.deno/bin/deno run -A index.js
/root/.deno/bin/deno: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /root/.deno/bin/deno)
import axios from "npm:axios";
import FormData from "npm:form-data";
const config = {
file: '/var/log/rclone/backup-log-$(date +"%d-%m-%Y").txt',
token: "TOKEN",
endpoint: "LINK"
};
async function getFile() {
const process = Deno.run({
cmd: ["bash", "-c", "echo " + config.file],
stdout: "piped",
});
const output = await process.output();
const outStr = new TextDecoder().decode(output);
process.close();
return outStr;
}
async function getName() {
const process = Deno.run({
cmd: ["bash", "-c", "echo backup-log-$(date +\"%d-%m-%Y\").txt"],
stdout: "piped",
});
const output = await process.output();
const outStr = new TextDecoder().decode(output);
process.close();
return outStr;
}
async function post() {
const fileName = (await getFile()).replace("\n", "");
try {
const file = Deno.readTextFileSync(fileName);
const name = (await getName()).replace("\n", "");
const form = new FormData();
form.append("token", config.token);
form.append("file", file, name);
axios
.request(config.endpoint, {
method: "POST",
maxBodyLength: Infinity,
headers: {
...form.getHeaders(),
},
data: form,
})
.then((response) => console.log(response.data));
} catch (e) {
console.log(e);
console.error("An error occured. This is normally due to the backup log file missing. Please confirm the log actually generated.");
Deno.exit(1);
}
}
post();
import axios from "npm:axios";
import FormData from "npm:form-data";
const config = {
file: '/var/log/rclone/backup-log-$(date +"%d-%m-%Y").txt',
token: "TOKEN",
endpoint: "LINK"
};
async function getFile() {
const process = Deno.run({
cmd: ["bash", "-c", "echo " + config.file],
stdout: "piped",
});
const output = await process.output();
const outStr = new TextDecoder().decode(output);
process.close();
return outStr;
}
async function getName() {
const process = Deno.run({
cmd: ["bash", "-c", "echo backup-log-$(date +\"%d-%m-%Y\").txt"],
stdout: "piped",
});
const output = await process.output();
const outStr = new TextDecoder().decode(output);
process.close();
return outStr;
}
async function post() {
const fileName = (await getFile()).replace("\n", "");
try {
const file = Deno.readTextFileSync(fileName);
const name = (await getName()).replace("\n", "");
const form = new FormData();
form.append("token", config.token);
form.append("file", file, name);
axios
.request(config.endpoint, {
method: "POST",
maxBodyLength: Infinity,
headers: {
...form.getHeaders(),
},
data: form,
})
.then((response) => console.log(response.data));
} catch (e) {
console.log(e);
console.error("An error occured. This is normally due to the backup log file missing. Please confirm the log actually generated.");
Deno.exit(1);
}
}
post();
6 replies