ramm 0.0.47 → 0.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bun.sh +6 -2
- package/dist/ramm.js +16 -5
- package/dist/types/base/base.d.ts +2 -2
- package/dist/types/packages.d.ts +2 -1
- package/package.json +1 -1
package/dist/bun.sh
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
if ! command -v unzip &> /dev/null; then
|
|
4
4
|
. /etc/os-release
|
|
5
|
+
|
|
6
|
+
if [[ "$ID_LIKE" == *"rhel"* ]]; then
|
|
7
|
+
sudo dnf install -y unzip
|
|
8
|
+
fi
|
|
5
9
|
|
|
6
10
|
if [[ "$ID" == "ubuntu" ]]; then
|
|
7
11
|
sudo apt update
|
|
@@ -10,10 +14,10 @@ if ! command -v unzip &> /dev/null; then
|
|
|
10
14
|
fi
|
|
11
15
|
|
|
12
16
|
if ! command -v bun &> /dev/null; then
|
|
13
|
-
echo "Installing..."
|
|
17
|
+
echo "Installing bun..."
|
|
14
18
|
|
|
15
19
|
curl -fsSL https://bun.sh/install | bash
|
|
16
20
|
ln -s "$HOME/.bun/bin/bun" /usr/local/bin/bun
|
|
17
21
|
else
|
|
18
|
-
echo "Already installed."
|
|
22
|
+
echo "Already installed bun."
|
|
19
23
|
fi
|
package/dist/ramm.js
CHANGED
|
@@ -81,8 +81,9 @@ var defaultContext = new Context({
|
|
|
81
81
|
userspace: false,
|
|
82
82
|
sudo: false
|
|
83
83
|
});
|
|
84
|
-
var execCommandRaw = async (command, { store = {}, signal, env, cwd, prefix = "" } = {}) => {
|
|
85
|
-
const
|
|
84
|
+
var execCommandRaw = async (command, { store = {}, signal, env, cwd, prefix = "" } = {}, ctx) => {
|
|
85
|
+
const finalCommand = ctx?.sudo ? `sudo ${command}` : command;
|
|
86
|
+
const spawnResult = spawn(["bash", "-c", finalCommand], {
|
|
86
87
|
stdin: "inherit",
|
|
87
88
|
stdout: "pipe",
|
|
88
89
|
stderr: "pipe",
|
|
@@ -106,7 +107,7 @@ var execCommandMayError = async (command, props) => {
|
|
|
106
107
|
printCommand(command);
|
|
107
108
|
return execCommandRaw(command, props);
|
|
108
109
|
};
|
|
109
|
-
var execCommand = async (command, props) => {
|
|
110
|
+
var execCommand = async (command, props, context) => {
|
|
110
111
|
const result = await execCommandMayError(command, props);
|
|
111
112
|
if (result.spawnResult.exitCode !== 0) {
|
|
112
113
|
console.error(`Error exit code: ${result.spawnResult.exitCode}`);
|
|
@@ -133,10 +134,19 @@ var {$: $2 } = globalThis.Bun;
|
|
|
133
134
|
|
|
134
135
|
// src/packages.ts
|
|
135
136
|
var {$ } = globalThis.Bun;
|
|
136
|
-
var
|
|
137
|
+
var dnf_os = ["rocky", "fedora", "alma"];
|
|
138
|
+
var installSystemPackage = async (packageName, context) => {
|
|
137
139
|
const osName = (await $`cat /etc/os-release | grep ^ID= | cut -d'=' -f2`.text()).trim();
|
|
140
|
+
const checkWhich = await $`which ${packageName}`;
|
|
141
|
+
if (checkWhich.exitCode !== 0) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
138
144
|
if (osName === "ubuntu") {
|
|
139
|
-
await
|
|
145
|
+
await execCommand(`apt-get install -y ${packageName}`, {}, context);
|
|
146
|
+
} else if (dnf_os.includes(osName)) {
|
|
147
|
+
await execCommand(`dnf install -y ${packageName}`, {}, context);
|
|
148
|
+
} else {
|
|
149
|
+
throw new Error(`Unsupported OS: ${osName}`);
|
|
140
150
|
}
|
|
141
151
|
};
|
|
142
152
|
|
|
@@ -300,6 +310,7 @@ var setupNftable = async ({
|
|
|
300
310
|
allowedIpV4,
|
|
301
311
|
allowedPorts
|
|
302
312
|
}) => {
|
|
313
|
+
await installSystemPackage("nftables");
|
|
303
314
|
const listTable = await execCommandMayError("nft list table inet ramm");
|
|
304
315
|
if (listTable.spawnResult.exitCode === 0) {
|
|
305
316
|
await execCommand("nft delete table inet ramm");
|
|
@@ -11,7 +11,7 @@ type ExecProps = {
|
|
|
11
11
|
prefix?: string;
|
|
12
12
|
signal?: AbortSignal;
|
|
13
13
|
} | void;
|
|
14
|
-
export declare const execCommandRaw: (command: string, { store, signal, env, cwd, prefix }?: ExecProps) => Promise<{
|
|
14
|
+
export declare const execCommandRaw: (command: string, { store, signal, env, cwd, prefix }?: ExecProps, ctx?: Context) => Promise<{
|
|
15
15
|
stderr: string;
|
|
16
16
|
stdout: string;
|
|
17
17
|
spawnResult: Subprocess<"inherit", "pipe", "pipe">;
|
|
@@ -21,7 +21,7 @@ export declare const execCommandMayError: (command: string, props: ExecProps) =>
|
|
|
21
21
|
stdout: string;
|
|
22
22
|
spawnResult: Subprocess<"inherit", "pipe", "pipe">;
|
|
23
23
|
}>;
|
|
24
|
-
export declare const execCommand: (command: string, props: ExecProps) => Promise<{
|
|
24
|
+
export declare const execCommand: (command: string, props: ExecProps, context?: Context) => Promise<{
|
|
25
25
|
stderr: string;
|
|
26
26
|
stdout: string;
|
|
27
27
|
spawnResult: Subprocess<"inherit", "pipe", "pipe">;
|
package/dist/types/packages.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Context } from "./context.ts";
|
|
2
|
+
export declare const installSystemPackage: (packageName: string, context?: Context) => Promise<void>;
|
package/package.json
CHANGED