jasmeowthecat
jasmeowthecat16mo ago

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.
[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)
The script looks like the below:
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();
3 Replies
jasmeowthecat
jasmeowthecat16mo ago
All it does is go to the file, grabs it, and uploads it to my server. The code works fine on the Debian OS based side but not CentOS, and some clients can't switch due to incompatibility with other systems they run. I have attempted a force over for them but it's difficult as they are adamant. The point is, simple little thing where I run a server coded in deno, and the clients "upload" their backup log to my own server if that makes sense. There is nothing wrong with rclone, the tool itself, the actual server neither the deno code, it's just annoying as I am stuck trying to run it. I have seen recommendations to build it from source which I have zero idea how to do, and I just need a simple solution and finally gave up, coming to this Discord in the process. I am slowly going insane!
pyrote
pyrote16mo ago
I tried deno 1.32.5 on CentOS 8 Stream, there were no issues. On CentOS 7 I am getting the same glibc error. CentOS 8 is using glibc 2.28. CentOS 7 is glibc 2.17 CentOS 7 is still supported until June 30 2024 so I can understand why the clients don't want to upgrade. This discussion has some suggestions on either using docker or a script for compiling deno on CentOS 7. https://github.com/denoland/deno/issues/1658#issuecomment-632986792
GitHub
Release centos7 compatible binaries · Issue #1658 · denoland/deno
When trying to run deno on Centos 7, it fails: [maxim@maxim deno] $ target/release/deno tests/worker.js target/release/deno: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by target...
jasmeowthecat
jasmeowthecat11mo ago
I don't know how to do that though sadly. Moving this up so people see.