-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathvite.sync.js
More file actions
42 lines (34 loc) · 1.23 KB
/
vite.sync.js
File metadata and controls
42 lines (34 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable no-console */
const Client = require('ssh2-sftp-client');
require('dotenv').config();
async function uploadFiles() {
const sftp = new Client();
try {
await sftp.connect({
host: process.env.SFTP_ROUTER,
port: 22,
username: process.env.SFTP_USERNAME,
password: process.env.SFTP_PASSWORD,
readyTimeout: 3000
});
console.log('Connected via SFTP.');
// Ensure directories exist
await sftp.mkdir('/jffs/addons/xrayui', true);
await sftp.mkdir('/jffs/scripts', true);
// Upload files
await sftp.fastPut('dist/index.asp', '/jffs/addons/xrayui/index.asp');
await sftp.fastPut('dist/app.js', '/jffs/addons/xrayui/app.js');
await sftp.fastPut('dist/xrayui', '/jffs/scripts/xrayui');
await sftp.fastPut('tools/adsblock/adsblock.sh', '/jffs/addons/xrayui/adsblock');
// Set executable permissions
await sftp.chmod('/jffs/scripts/xrayui', '755');
await sftp.chmod('/jffs/addons/xrayui/adsblock', '755');
console.log('Files uploaded and permissions set successfully.');
} catch (err) {
console.error('Error uploading files via SFTP:', err);
} finally {
sftp.end();
}
}
uploadFiles();