Skip to content

Commit f906102

Browse files
authored
feat: add AWS and arm64 support (#8)
* chore: update packages * chore: remove blank issue template * ci: exit on `1` when the return isn't `true` * feat: arm64 architecture support * feat: AWS support * ci: fix bad finish * ci: fix bad finish * ci: fix bad finish * ci: fix bad finish * ci: fix bad finish * ci: fix bad finish
1 parent 0b3f1ba commit f906102

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+478
-897
lines changed

.github/ISSUE_TEMPLATE/blank-📄.md

-7
This file was deleted.

.github/workflows/ci.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ jobs:
6666
- name: 🧪 Testing Service - Upload
6767
run: npm run tests:upload
6868

69-
- name: 🧪 Testing Service - Virtual Hosts
70-
run: npm run tests:virtual-hosts
69+
# Temporarily removing due to limited storage space for GitHub Actions.
70+
# - name: 🧪 Testing Service - Virtual Hosts
71+
# run: npm run tests:virtual-hosts
7172

7273
- name: ✅ Finishing
7374
run: npm run tests:reset >/dev/null 2>&1 || true

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ const svps = new SVPS({
6161
},
6262
});
6363

64+
/** For AWS */
65+
const svps = new SVPS({
66+
access: {
67+
host: '***.amazonaws.com',
68+
username: 'ubuntu',
69+
privateKey: fs.readFileSync('./your_rsa.pem'),
70+
},
71+
});
72+
6473
/** Available methods
6574
* svps.mount
6675
* svps.commands

package-lock.json

+115-613
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
"svps": "bin/index.js"
88
},
99
"dependencies": {
10-
"@types/ssh2": "^1.11.13",
10+
"@types/ssh2": "^1.11.14",
1111
"ssh2": "^1.14.0"
1212
},
1313
"devDependencies": {
14-
"@types/node": "^20.4.5",
15-
"@typescript-eslint/eslint-plugin": "^6.2.0",
16-
"@typescript-eslint/parser": "^6.2.0",
17-
"eslint": "^8.46.0",
18-
"eslint-import-resolver-typescript": "^3.5.5",
19-
"eslint-plugin-import": "^2.28.0",
14+
"@types/node": "^20.8.4",
15+
"@typescript-eslint/eslint-plugin": "^6.7.5",
16+
"@typescript-eslint/parser": "^6.7.5",
17+
"eslint": "^8.51.0",
18+
"eslint-import-resolver-typescript": "^3.6.1",
19+
"eslint-plugin-import": "^2.28.1",
2020
"packages-update": "^1.2.1",
21-
"prettier": "^3.0.0",
22-
"typescript": "^5.1.6"
21+
"prettier": "^3.0.3",
22+
"typescript": "^5.2.2"
2323
},
2424
"scripts": {
2525
"build": "rm -rf ./bin ./lib ./tests && npx tsc",

resources/sources-list/18.04-arm.list

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
deb http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe multiverse
2+
deb http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe multiverse
3+
deb http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted universe multiverse
4+
deb http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse

resources/sources-list/20.04-arm.list

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
deb http://ports.ubuntu.com/ubuntu-ports/ focal main restricted universe multiverse
2+
deb http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe multiverse
3+
deb http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted universe multiverse
4+
deb http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse

resources/sources-list/22.04-arm.list

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
deb http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe multiverse
2+
deb http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe multiverse
3+
deb http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
4+
deb http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse

resources/sources-list/23.04-arm.list

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
deb http://ports.ubuntu.com/ubuntu-ports/ lunar main restricted universe multiverse
2+
deb http://ports.ubuntu.com/ubuntu-ports/ lunar-updates main restricted universe multiverse
3+
deb http://ports.ubuntu.com/ubuntu-ports/ lunar-backports main restricted universe multiverse
4+
deb http://ports.ubuntu.com/ubuntu-ports/ lunar-security main restricted universe multiverse

src/lib/modules/basic-permissions.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ export const basicPermissions = async (options: {
88
const { remote, user, group } = options;
99

1010
if (user && group) {
11-
await catchExec(`chown -R ${user}:${group} "${remote}"`);
12-
await catchExec(`chmod -R 0775 "${remote}"`);
11+
await catchExec(`sudo chown -R ${user}:${group} "${remote}"`);
12+
await catchExec(`sudo chmod -R 0775 "${remote}"`);
1313
} else if (user) {
14-
await catchExec(`chown -R ${user}: "${remote}"`);
15-
await catchExec(`chmod -R 0755 "${remote}"`);
14+
await catchExec(`sudo chown -R ${user}: "${remote}"`);
15+
await catchExec(`sudo chmod -R 0755 "${remote}"`);
1616
} else if (group) {
17-
await catchExec(`chown -R :${group} "${remote}"`);
18-
await catchExec(`chmod -R 0775 "${remote}"`);
17+
await catchExec(`sudo chown -R :${group} "${remote}"`);
18+
await catchExec(`sudo chmod -R 0775 "${remote}"`);
1919
}
2020
};

src/lib/modules/commands.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ export const setCommands = async (options: {
6161

6262
const initialCommands = [
6363
/** Resolving `dpkg` and `apt` */
64-
'rm -rf /var/lib/apt/lists/lock',
65-
'rm -rf /var/lib/dpkg/lock',
66-
'rm -rf /var/lib/dpkg/lock-frontend',
67-
'rm -rf /var/cache/apt/archives/lock',
68-
'echo "Y" | dpkg --configure -a',
69-
'echo "debconf debconf/frontend select Noninteractive" | debconf-set-selections',
64+
'sudo rm -rf /var/lib/apt/lists/lock',
65+
'sudo rm -rf /var/lib/dpkg/lock',
66+
'sudo rm -rf /var/lib/dpkg/lock-frontend',
67+
'sudo rm -rf /var/cache/apt/archives/lock',
68+
'echo "Y" | sudo dpkg --configure -a',
69+
'echo "debconf debconf/frontend select Noninteractive" | sudo debconf-set-selections',
7070
];
7171

7272
if (verbose) console.log('# Initial Commands', '\n', initialCommands);

src/lib/modules/configs/node.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@ import { NODE } from '../../types/node.js';
22
import { MOUNT } from '../../types/mount.js';
33

44
export const setNode = (configs: MOUNT): Required<NODE> | null => {
5-
if (!configs?.node || typeof configs?.node !== 'object') return null;
5+
if (!configs?.node) return null;
6+
7+
const defaults: Required<NODE> = {
8+
version: 18,
9+
packages: [],
10+
};
11+
12+
if (configs.node === true) return defaults;
613

714
return {
815
version:
916
configs?.node && typeof configs.node.version === 'number'
1017
? configs.node.version
11-
: 18,
18+
: defaults.version,
1219
packages:
1320
configs?.node && Array.isArray(configs.node.packages)
1421
? configs.node.packages
15-
: [],
22+
: defaults.packages,
1623
};
1724
};

src/lib/modules/configs/php.ts

+38-28
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,53 @@ import { PHP } from '../../types/php.js';
22
import { MOUNT } from '../../types/mount.js';
33

44
export const setPHP = (configs: MOUNT): Required<PHP> | null => {
5-
if (!configs?.php || typeof configs?.php !== 'object') return null;
5+
if (!configs?.php) return null;
66

7-
return {
7+
const defaults: Required<PHP> = {
8+
version: 8.2,
9+
modules: [
10+
'cli',
11+
'common',
12+
'bz2',
13+
'curl',
14+
'gmp',
15+
'readline',
16+
'sqlite3',
17+
'xml',
18+
'bcmath',
19+
'gd',
20+
'imagick',
21+
'imap',
22+
'intl',
23+
'json',
24+
'mbstring',
25+
'mysql',
26+
'opcache',
27+
'soap',
28+
'tidy',
29+
'xmlrpc',
30+
'xsl',
31+
'zip',
32+
],
33+
composer: true,
34+
};
35+
36+
if (configs.php === true) return defaults;
37+
38+
const php: Required<PHP> = {
839
version:
940
configs?.php && typeof configs.php?.version === 'number'
1041
? configs.php.version
11-
: 8.2,
42+
: defaults.version,
1243
modules:
1344
configs?.php && Array.isArray(configs.php?.modules)
1445
? configs.php.modules
15-
: [
16-
'cli',
17-
'common',
18-
'bz2',
19-
'curl',
20-
'gmp',
21-
'readline',
22-
'sqlite3',
23-
'xml',
24-
'bcmath',
25-
'gd',
26-
'imagick',
27-
'imap',
28-
'intl',
29-
'json',
30-
'mbstring',
31-
'mysql',
32-
'opcache',
33-
'soap',
34-
'tidy',
35-
'xmlrpc',
36-
'xsl',
37-
'zip',
38-
],
46+
: defaults.modules,
3947
composer:
4048
configs?.php && typeof configs.php?.composer === 'boolean'
4149
? configs.php.composer
42-
: true,
50+
: defaults.composer,
4351
};
52+
53+
return php;
4454
};

src/lib/modules/configs/users.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { MOUNT } from '../../types/mount.js';
22
import { REQUIRED_USER } from '../../types/users.js';
33
import { forceArray } from '../force-array.js';
44

5-
export const setUsers = (configs: MOUNT) => {
5+
export const setUsers = (configs: MOUNT): REQUIRED_USER[] | null => {
66
if (!configs?.users) return null;
77

88
const mapUsers = forceArray(configs.users) as REQUIRED_USER[];

src/lib/tasks/index.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const createSVPS = () => {
2929

3030
return class SVPS {
3131
constructor(options: {
32-
/** Set the SSH access for one or more VPS */
32+
/** Set the SSH access */
3333
access: ACCESS;
3434
}) {
3535
access = options.access;
@@ -93,13 +93,13 @@ const createSVPS = () => {
9393
const invalidVirtualHosts: VIRTUAL_HOST[] = [];
9494
const deployedVirtualHosts: VIRTUAL_HOST[] = [];
9595
const commands = [
96-
'echo "debconf debconf/frontend select Noninteractive" | debconf-set-selections',
97-
'mkdir -p /var/containers/images /var/containers/compositions /var/containers/domains /var/containers/databases',
98-
'chmod 0755 /var/containers',
99-
'chmod 0700 /var/containers/images',
100-
'chmod 0700 /var/containers/compositions',
101-
'chmod 0750 /var/containers/databases',
102-
'chmod 0755 /var/containers/domains',
96+
'echo "debconf debconf/frontend select Noninteractive" | sudo debconf-set-selections',
97+
'sudo mkdir -p /var/containers/images /var/containers/compositions /var/containers/domains /var/containers/databases',
98+
'sudo chmod 0755 /var/containers',
99+
'sudo chmod 0700 /var/containers/images',
100+
'sudo chmod 0700 /var/containers/compositions',
101+
'sudo chmod 0750 /var/containers/databases',
102+
'sudo chmod 0755 /var/containers/domains',
103103
];
104104

105105
if (!virtualHosts) {
@@ -146,11 +146,11 @@ const createSVPS = () => {
146146
...commands,
147147
`echo "${sh.startTitle}Proxy Port: ${virtualHost.domain} on port ${virtualHost.port}${sh.endTitle}"`,
148148
...createProxy(virtualHost),
149-
'systemctl reload apache2',
149+
'sudo systemctl reload apache2',
150150
sh.done,
151151
]);
152152
});
153-
commands.push('systemctl restart apache2');
153+
commands.push('sudo systemctl restart apache2');
154154
}
155155

156156
/** Basic Virtual Hosts Servers */
@@ -165,7 +165,7 @@ const createSVPS = () => {
165165
...createBasicVirtualHost(virtualHost),
166166
]);
167167
});
168-
commands.push('systemctl restart apache2');
168+
commands.push('sudo systemctl restart apache2');
169169
}
170170

171171
if (deployedVirtualHosts.length === 0)

src/lib/tasks/steps/apache.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ export default (configs: MOUNT) => {
1515

1616
const commands = [
1717
`echo "${sh.startTitle}Setting up Apache2${sh.endTitle}"`,
18-
'apt-get update',
19-
'apt-get install apache2 -y',
20-
'mkdir -p /var/www',
21-
'rm -rf /var/www/html',
22-
'mkdir -p /var/www/host',
18+
'sudo apt-get update',
19+
'sudo apt-get install apache2 -y',
20+
'sudo mkdir -p /var/www',
21+
'sudo rm -rf /var/www/html',
22+
'sudo mkdir -p /var/www/host',
2323
`echo "${sh.startTitle}Setting up Rewrite Virtual Hosts${sh.endTitle}"`,
2424
`echo ${escapeQuotes(
2525
fs.readFileSync(normalize(default_000), 'utf-8')
26-
)} | cat > /etc/apache2/sites-available/000-default.conf`,
27-
'a2enmod proxy proxy_http rewrite headers expires',
26+
)} | sudo tee /etc/apache2/sites-available/000-default.conf > /dev/null`,
27+
'sudo a2enmod proxy proxy_http rewrite headers expires',
2828
];
2929

3030
if (!apache.accessFromIP) {
@@ -36,19 +36,19 @@ export default (configs: MOUNT) => {
3636
...[
3737
`echo ${escapeQuotes(
3838
fs.readFileSync(normalize(htaccess), 'utf-8')
39-
)} | cat > /var/www/host/.htaccess`,
39+
)} | sudo tee /var/www/host/.htaccess > /dev/null`,
4040
`echo ${escapeQuotes(
4141
fs.readFileSync(normalize(_403), 'utf-8')
42-
)} | cat > /var/www/host/403.html`,
43-
'chmod 0755 /var/www/host',
42+
)} | sudo tee /var/www/host/403.html > /dev/null`,
43+
'sudo chmod 0755 /var/www/host',
4444
],
4545
]);
4646
}
4747

4848
Object.assign(commands, [
4949
...commands,
50-
'systemctl restart apache2',
51-
'systemctl reload apache2',
50+
'sudo systemctl restart apache2',
51+
'sudo systemctl reload apache2',
5252
sh.done,
5353
]);
5454

src/lib/tasks/steps/apt.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import sh from '../../modules/sh.js';
22

33
export default () => [
44
`echo "${sh.startTitle}Preparing the Environment${sh.endTitle}"`,
5-
'apt-get update',
6-
'DEBIAN_FRONTEND="noninteractive" apt -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade 2>/dev/null',
7-
'apt-get autoremove -y --purge',
8-
'apt-get clean -y',
9-
'apt-get autoclean -y',
5+
'sudo apt-get update',
6+
'DEBIAN_FRONTEND="noninteractive" sudo apt -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade 2>/dev/null',
7+
'sudo apt-get autoremove -y --purge',
8+
'sudo apt-get clean -y',
9+
'sudo apt-get autoclean -y',
1010
sh.done,
1111
];

src/lib/tasks/steps/certificate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default (configs: MOUNT) => {
1818

1919
const commands = [
2020
'echo "Generating Open SSL RSA Certificate..."',
21-
`--catch openssl req -x509 -nodes -days ${certificate.days} -new -newkey rsa:${certificate.rsa} -keyout /etc/ssl/private/cert.pem -out /etc/ssl/private/cert.pem -subj "/C=${country}/ST=${state}/L=${location}/O=${organization}/OU=${organizationUnit}/CN=${commonName}"`,
21+
`--catch sudo openssl req -x509 -nodes -days ${certificate.days} -new -newkey rsa:${certificate.rsa} -keyout /etc/ssl/private/cert.pem -out /etc/ssl/private/cert.pem -subj "/C=${country}/ST=${state}/L=${location}/O=${organization}/OU=${organizationUnit}/CN=${commonName}"`,
2222
sh.done,
2323
];
2424

src/lib/tasks/steps/crontab.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@ export default (configs: MOUNT, VPS: ACCESS) => {
1515
const crons = escapeQuotes(fs.readFileSync(normalize(crontab.path), 'utf-8'));
1616
const commands = [
1717
`echo "${sh.startTitle}Setting up cron jobs for '${VPS.username}'${sh.endTitle}"`,
18-
'mkdir -p /var/spool/cron/crontabs/',
19-
'apt-get update',
20-
'apt-get install -y cron',
21-
`echo ${crons} | ${append ? 'tee -a' : 'cat >'} /var/spool/cron/crontabs/${
18+
'sudo mkdir -p /var/spool/cron/crontabs/',
19+
'sudo apt-get update',
20+
'sudo apt-get install -y cron',
21+
`echo ${crons} | sudo tee${append ? ' -a' : ''} /var/spool/cron/crontabs/${
2222
VPS.username
23-
}`,
23+
} > /dev/null`,
2424
];
2525

26-
if (!append) commands.push(`echo ${crons}`);
27-
26+
commands.push(`echo ${crons}`);
2827
commands.push(sh.done);
2928

3029
return commands;

0 commit comments

Comments
 (0)