-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ftp.ts
24 lines (19 loc) · 762 Bytes
/
ftp.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import fs from 'fs';
import { normalize } from 'path';
import { escapeQuotes } from '../../../modules/escape-quotes.js';
import { REQUIRED_USER } from '../../../types/users.js';
import { rootSVPS } from '../../../modules/root.js';
export const setFTP = (user: REQUIRED_USER) => {
if (!user?.ftp) return [] as string[];
const user_conf = fs
.readFileSync(normalize(`${rootSVPS}/resources/ftp/user.conf`), 'utf-8')
.replace(/{!PATH}/gm, user.ftp.directory)
.replace(/{!MASK}/gm, user.ftp.mask);
const commands: string[] = [
`echo ${escapeQuotes(user_conf)} | sudo tee /etc/vsftpd/user_config_dir/${
user.name
} > /dev/null`,
];
commands.push(`sudo echo "${user.name}" | tee -a /etc/vsftpd.userlist`);
return commands;
};