Skip to content

Commit

Permalink
cloud: fix EACCES
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Sep 3, 2023
1 parent effadb1 commit 20ed523
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
4 changes: 2 additions & 2 deletions plugins/cloud/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/cloud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@
"@types/nat-upnp": "^1.1.2",
"@types/node": "^20.4.5"
},
"version": "0.1.34"
"version": "0.1.35"
}
31 changes: 17 additions & 14 deletions plugins/cloud/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -798,35 +798,38 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
this.console.log('starting cloudflared');
this.cloudflared = await backOff(async () => {
const pluginVolume = process.env.SCRYPTED_PLUGIN_VOLUME;
const version = 'v1';
const cloudflareD = path.join(pluginVolume, 'cloudflare.d', `${process.platform}-${process.arch}-${version}`);
mkdirSync(cloudflareD, {
recursive: true,
})
process.chdir(cloudflareD);
const version = 2;
const cloudflareD = path.join(pluginVolume, 'cloudflare.d', `v${version}`, `${process.platform}-${process.arch}`);

if (!fs.existsSync(cloudflared.bin)) {
if (process.platform === 'darwin' && process.arch === 'arm64') {
mkdirSync(path.dirname(cloudflared.bin), {
recursive: true,
})
const tmp = `${cloudflared.bin}.tmp`;
rmSync(tmp, {
for (let i = 0; i <= version; i++) {
const cloudflareD = path.join(pluginVolume, 'cloudflare.d', `v${version}`);
rmSync(cloudflareD, {
force: true,
recursive: true,
});
}
if (process.platform === 'darwin' && process.arch === 'arm64') {
const bin = path.join(cloudflareD, cloudflared.bin);
mkdirSync(path.dirname(bin), {
recursive: true,
});
const tmp = `${bin}.tmp`;

const stream = await axios('https://github.com/scryptedapp/cloudflared/releases/download/2023.8.2/cloudflared-darwin-arm64', {
responseType: 'stream',
});
const write = stream.data.pipe(fs.createWriteStream(cloudflared.bin));
const write = stream.data.pipe(fs.createWriteStream(tmp));
await once(write, 'close');
renameSync(tmp, cloudflared.bin);
fs.chmodSync(cloudflared.bin, 0o777)
fs.chmodSync(cloudflared.bin, 0o0755)
}
else {
await cloudflared.install(cloudflared.bin);
}
}
process.chdir(cloudflareD);

const secureUrl = `https://127.0.0.1:${this.securePort}`;
const args: any = {};
if (this.storageSettings.values.cloudflaredTunnelToken) {
Expand Down

0 comments on commit 20ed523

Please sign in to comment.