@inoku/lifedrive 0.4.0
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/README.md +27 -0
- package/bin/lifedrive.js +84 -0
- package/package.json +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# LifeDrive Installer
|
|
2
|
+
|
|
3
|
+
This public repository contains versioned LifeDrive installation assets built from the private LifeAlbum source repository.
|
|
4
|
+
|
|
5
|
+
On the Leither server, run:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx --yes @inoku/lifedrive
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Run the command from the Leither root, or identify it explicitly:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx --yes @inoku/lifedrive --leither-root /path/to/leither
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The npm package is a dependency-free launcher for the versioned GitHub Release installer. If npm is unavailable, use the release bootstrap directly:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
curl -fLO https://github.com/cfa532/lifedrive-installer/releases/latest/download/lifedrive-install.sh
|
|
21
|
+
chmod +x lifedrive-install.sh
|
|
22
|
+
./lifedrive-install.sh --leither-root /path/to/leither
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The bootstrap downloads `lifedrive-bundle.tar.gz`, verifies it against the SHA-256 file attached to the same GitHub Release, installs it below the selected Leither root, and runs the interactive SSH setup. All installer options after the npm package name pass through to that bootstrap.
|
|
26
|
+
|
|
27
|
+
Source code and design documentation are maintained separately. No private key, password, enrollment code, or node-specific application MID is included in these release assets.
|
package/bin/lifedrive.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const https = require("node:https");
|
|
6
|
+
const os = require("node:os");
|
|
7
|
+
const path = require("node:path");
|
|
8
|
+
const { pipeline } = require("node:stream");
|
|
9
|
+
const { spawnSync } = require("node:child_process");
|
|
10
|
+
|
|
11
|
+
const DEFAULT_INSTALLER_URL =
|
|
12
|
+
"https://github.com/cfa532/lifedrive-installer/releases/latest/download/lifedrive-install.sh";
|
|
13
|
+
const installerUrl = process.env.LIFEDRIVE_INSTALLER_URL || DEFAULT_INSTALLER_URL;
|
|
14
|
+
const maximumRedirects = 8;
|
|
15
|
+
|
|
16
|
+
function download(url, destination, redirects = 0) {
|
|
17
|
+
if (redirects > maximumRedirects) {
|
|
18
|
+
return Promise.reject(new Error("The installer download used too many redirects."));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
const request = https.get(
|
|
23
|
+
url,
|
|
24
|
+
{
|
|
25
|
+
headers: {
|
|
26
|
+
Accept: "application/octet-stream",
|
|
27
|
+
"User-Agent": "inoku-lifedrive-installer"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
response => {
|
|
31
|
+
const status = response.statusCode || 0;
|
|
32
|
+
if (status >= 300 && status < 400 && response.headers.location) {
|
|
33
|
+
response.resume();
|
|
34
|
+
resolve(download(new URL(response.headers.location, url).toString(), destination, redirects + 1));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (status !== 200) {
|
|
38
|
+
response.resume();
|
|
39
|
+
reject(new Error(`GitHub returned HTTP ${status || "unknown"}.`));
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const output = fs.createWriteStream(destination, { mode: 0o700 });
|
|
44
|
+
pipeline(response, output, error => (error ? reject(error) : resolve()));
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
request.setTimeout(30000, () => request.destroy(new Error("The installer download timed out.")));
|
|
48
|
+
request.on("error", reject);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function main() {
|
|
53
|
+
if (process.platform !== "linux" && process.platform !== "darwin") {
|
|
54
|
+
throw new Error("LifeDrive setup currently supports Linux and macOS Leither servers.");
|
|
55
|
+
}
|
|
56
|
+
if (!fs.existsSync("/bin/bash")) {
|
|
57
|
+
throw new Error("LifeDrive setup requires /bin/bash.");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const temporaryDirectory = fs.mkdtempSync(path.join(os.tmpdir(), "lifedrive-npx-"));
|
|
61
|
+
const installerPath = path.join(temporaryDirectory, "lifedrive-install.sh");
|
|
62
|
+
try {
|
|
63
|
+
process.stdout.write("Downloading the LifeDrive installer from GitHub...\n");
|
|
64
|
+
await download(installerUrl, installerPath);
|
|
65
|
+
fs.chmodSync(installerPath, 0o700);
|
|
66
|
+
|
|
67
|
+
const result = spawnSync("/bin/bash", [installerPath, ...process.argv.slice(2)], {
|
|
68
|
+
stdio: "inherit",
|
|
69
|
+
env: process.env
|
|
70
|
+
});
|
|
71
|
+
if (result.error) throw result.error;
|
|
72
|
+
if (typeof result.status === "number") process.exitCode = result.status;
|
|
73
|
+
else if (result.signal === "SIGINT") process.exitCode = 130;
|
|
74
|
+
else if (result.signal === "SIGTERM") process.exitCode = 143;
|
|
75
|
+
else process.exitCode = 1;
|
|
76
|
+
} finally {
|
|
77
|
+
fs.rmSync(temporaryDirectory, { recursive: true, force: true });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
main().catch(error => {
|
|
82
|
+
process.stderr.write(`LifeDrive installer stopped: ${error.message}\n`);
|
|
83
|
+
process.exitCode = 1;
|
|
84
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@inoku/lifedrive",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Install LifeDrive on a locally owned Leither server",
|
|
5
|
+
"bin": {
|
|
6
|
+
"lifedrive": "bin/lifedrive.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin/lifedrive.js"
|
|
10
|
+
],
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=18"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/cfa532/lifedrive-installer.git"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/cfa532/lifedrive-installer#readme",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/cfa532/lifedrive-installer/issues"
|
|
21
|
+
},
|
|
22
|
+
"license": "UNLICENSED",
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public",
|
|
25
|
+
"provenance": true
|
|
26
|
+
}
|
|
27
|
+
}
|