@le-space/rootfs 0.4.5 → 0.6.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 +3 -3
- package/index.d.ts +3 -3
- package/index.js +9 -9
- package/package.json +4 -4
- package/reference/{orbitdb-relay-pinner → orbitdb-relay}/contract.json +10 -10
- package/reference/{orbitdb-relay-pinner → orbitdb-relay}/rootfs/Dockerfile.rootfs +1 -0
- package/reference/{orbitdb-relay-pinner → orbitdb-relay}/rootfs/build-rootfs-image.sh +55 -43
- package/reference/{orbitdb-relay-pinner → orbitdb-relay}/rootfs/build-rootfs.sh +16 -16
- package/reference/{orbitdb-relay-pinner/rootfs/orbitdb-relay-pinner-autotls-refresh.py → orbitdb-relay/rootfs/orbitdb-relay-autotls-refresh.py} +7 -7
- package/reference/orbitdb-relay/rootfs/orbitdb-relay-autotls-refresh.service +24 -0
- package/reference/{orbitdb-relay-pinner/rootfs/orbitdb-relay-pinner-bootstrap-refresh.py → orbitdb-relay/rootfs/orbitdb-relay-bootstrap-refresh.py} +3 -3
- package/reference/orbitdb-relay/rootfs/orbitdb-relay-bootstrap-refresh.service +13 -0
- package/reference/{orbitdb-relay-pinner/rootfs/orbitdb-relay-pinner-bootstrap-refresh.timer → orbitdb-relay/rootfs/orbitdb-relay-bootstrap-refresh.timer} +2 -2
- package/reference/orbitdb-relay/rootfs/orbitdb-relay-bootstrap.conf +2 -0
- package/reference/orbitdb-relay/rootfs/orbitdb-relay-bootstrap.service +21 -0
- package/reference/{orbitdb-relay-pinner/rootfs/orbitdb-relay-pinner-bootstrap.sh → orbitdb-relay/rootfs/orbitdb-relay-bootstrap.sh} +12 -12
- package/reference/{orbitdb-relay-pinner/rootfs/orbitdb-relay-pinner-configure.sh → orbitdb-relay/rootfs/orbitdb-relay-configure.sh} +12 -12
- package/reference/{orbitdb-relay-pinner/rootfs/orbitdb-relay-pinner-describe.py → orbitdb-relay/rootfs/orbitdb-relay-describe.py} +1 -1
- package/reference/{orbitdb-relay-pinner/rootfs/orbitdb-relay-pinner-setup-server.py → orbitdb-relay/rootfs/orbitdb-relay-setup-server.py} +8 -8
- package/reference/uc-go-peer/rootfs/build-rootfs-image.sh +8 -1
- package/reference/orbitdb-relay-pinner/rootfs/orbitdb-relay-pinner-autotls-refresh.service +0 -24
- package/reference/orbitdb-relay-pinner/rootfs/orbitdb-relay-pinner-bootstrap-refresh.service +0 -13
- package/reference/orbitdb-relay-pinner/rootfs/orbitdb-relay-pinner-bootstrap.conf +0 -2
- package/reference/orbitdb-relay-pinner/rootfs/orbitdb-relay-pinner-bootstrap.service +0 -21
- /package/reference/{orbitdb-relay-pinner → orbitdb-relay}/rootfs/publish-store-message.mjs +0 -0
- /package/reference/{orbitdb-relay-pinner → orbitdb-relay}/rootfs/read-rootfs-contract.mjs +0 -0
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Shared rootfs contract parsing, reference profile assets, and build helpers.
|
|
|
7
7
|
- typed parsing and validation of rootfs contract JSON
|
|
8
8
|
- shell-env mapping compatible with the existing UC rootfs builder
|
|
9
9
|
- copied `uc-go-peer` reference contract and guest asset set
|
|
10
|
-
- copied `orbitdb-relay
|
|
10
|
+
- copied `orbitdb-relay` reference contract and guest asset set,
|
|
11
11
|
including the delayed first-start, setup endpoint, Caddy, and AutoTLS flow
|
|
12
12
|
|
|
13
13
|
## Reference assets
|
|
@@ -16,5 +16,5 @@ Current shared reference profiles live under:
|
|
|
16
16
|
|
|
17
17
|
- `reference/uc-go-peer/contract.json`
|
|
18
18
|
- `reference/uc-go-peer/rootfs/*`
|
|
19
|
-
- `reference/orbitdb-relay
|
|
20
|
-
- `reference/orbitdb-relay
|
|
19
|
+
- `reference/orbitdb-relay/contract.json`
|
|
20
|
+
- `reference/orbitdb-relay/rootfs/*`
|
package/index.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ declare function referenceProfileRootfsDir(profile: string): string;
|
|
|
51
51
|
type RootfsBuildDriver = 'auto' | 'host' | 'docker';
|
|
52
52
|
interface RootfsBuildOptions {
|
|
53
53
|
projectDir: string;
|
|
54
|
-
|
|
54
|
+
orbitdbRelayDir?: string;
|
|
55
55
|
alephDir?: string;
|
|
56
56
|
outDir?: string;
|
|
57
57
|
contractPath?: string;
|
|
@@ -78,7 +78,7 @@ interface RootfsBuildPlan {
|
|
|
78
78
|
contract: RootfsContract;
|
|
79
79
|
contractPath: string;
|
|
80
80
|
projectDir: string;
|
|
81
|
-
|
|
81
|
+
orbitdbRelayDir?: string;
|
|
82
82
|
alephDir: string;
|
|
83
83
|
outDir: string;
|
|
84
84
|
driver: RootfsBuildDriver;
|
|
@@ -170,7 +170,7 @@ interface RootfsExecutionPlanOptions {
|
|
|
170
170
|
referenceRootfsDir?: string;
|
|
171
171
|
projectMountPath?: string;
|
|
172
172
|
rootfsMountPath?: string;
|
|
173
|
-
|
|
173
|
+
orbitdbRelayMountPath?: string;
|
|
174
174
|
dockerImageTag?: string;
|
|
175
175
|
}
|
|
176
176
|
declare function createHostRootfsExecutionPlan(plan: RootfsBuildPlan, options?: RootfsExecutionPlanOptions): RootfsExecutionPlan;
|
package/index.js
CHANGED
|
@@ -187,7 +187,7 @@ function sourceSubdirectory(contract) {
|
|
|
187
187
|
}
|
|
188
188
|
function createRootfsBuildPlan(contract, options) {
|
|
189
189
|
const projectDir = path.resolve(options.projectDir);
|
|
190
|
-
const
|
|
190
|
+
const orbitdbRelayDir = options.orbitdbRelayDir?.trim() ? path.resolve(options.orbitdbRelayDir) : void 0;
|
|
191
191
|
const subdirectory = sourceSubdirectory(contract);
|
|
192
192
|
const defaultAlephDir = subdirectory ? path.join(projectDir, subdirectory, "aleph") : projectDir;
|
|
193
193
|
const alephDir = path.resolve(options.alephDir ?? defaultAlephDir);
|
|
@@ -210,7 +210,7 @@ function createRootfsBuildPlan(contract, options) {
|
|
|
210
210
|
contract,
|
|
211
211
|
contractPath,
|
|
212
212
|
projectDir,
|
|
213
|
-
|
|
213
|
+
orbitdbRelayDir,
|
|
214
214
|
alephDir,
|
|
215
215
|
outDir,
|
|
216
216
|
driver: options.driver ?? "auto",
|
|
@@ -223,7 +223,7 @@ function createRootfsBuildPlan(contract, options) {
|
|
|
223
223
|
ipfsAddUrl: options.ipfsAddUrl?.trim() || "https://ipfs.aleph.cloud/api/v0/add",
|
|
224
224
|
ipfsGatewayUrl: options.ipfsGatewayUrl?.trim() || "https://ipfs.aleph.cloud/ipfs",
|
|
225
225
|
alephApiHost: options.alephApiHost?.trim() || "https://api.aleph.im",
|
|
226
|
-
alephMessageWaitAttempts: positiveInteger(options.alephMessageWaitAttempts,
|
|
226
|
+
alephMessageWaitAttempts: positiveInteger(options.alephMessageWaitAttempts, 120),
|
|
227
227
|
alephMessageWaitDelaySeconds: positiveInteger(options.alephMessageWaitDelaySeconds, 5),
|
|
228
228
|
alephPinAttempts: positiveInteger(options.alephPinAttempts, 4),
|
|
229
229
|
alephPinDelaySeconds: positiveInteger(options.alephPinDelaySeconds, 10),
|
|
@@ -259,8 +259,8 @@ function rootfsBuildShellEnv(plan) {
|
|
|
259
259
|
IPFS_GATEWAY_WAIT_ATTEMPTS: String(plan.ipfsGatewayWaitAttempts),
|
|
260
260
|
IPFS_GATEWAY_WAIT_DELAY_SECONDS: String(plan.ipfsGatewayWaitDelaySeconds)
|
|
261
261
|
};
|
|
262
|
-
if (plan.
|
|
263
|
-
env.
|
|
262
|
+
if (plan.orbitdbRelayDir) {
|
|
263
|
+
env.ORBITDB_RELAY_DIR = plan.orbitdbRelayDir;
|
|
264
264
|
}
|
|
265
265
|
return env;
|
|
266
266
|
}
|
|
@@ -420,7 +420,7 @@ function createDockerRootfsExecutionPlan(plan, options = {}) {
|
|
|
420
420
|
const referenceRootfsDir = resolveReferenceRootfsDir(plan.contract, options.referenceRootfsDir);
|
|
421
421
|
const projectMountPath = options.projectMountPath ?? "/workspace/project";
|
|
422
422
|
const rootfsMountPath = options.rootfsMountPath ?? "/workspace/shared-rootfs";
|
|
423
|
-
const
|
|
423
|
+
const orbitdbRelayMountPath = options.orbitdbRelayMountPath ?? "/workspace-orbitdb-relay";
|
|
424
424
|
const dockerImageTag = options.dockerImageTag ?? `${plan.contract.id}-rootfs-builder:local`;
|
|
425
425
|
const containerProjectDir = projectMountPath;
|
|
426
426
|
const containerContractPath = containerContractPathForFile(plan.contractPath, plan.projectDir, projectMountPath);
|
|
@@ -445,9 +445,9 @@ function createDockerRootfsExecutionPlan(plan, options = {}) {
|
|
|
445
445
|
if (contractRelative.startsWith("..") || path2.isAbsolute(contractRelative)) {
|
|
446
446
|
volumeMounts.push("-v", `${plan.contractPath}:${containerContractPath}:ro`);
|
|
447
447
|
}
|
|
448
|
-
if (plan.
|
|
449
|
-
runEnv.
|
|
450
|
-
volumeMounts.push("-v", `${plan.
|
|
448
|
+
if (plan.orbitdbRelayDir) {
|
|
449
|
+
runEnv.ORBITDB_RELAY_DIR = orbitdbRelayMountPath;
|
|
450
|
+
volumeMounts.push("-v", `${plan.orbitdbRelayDir}:${orbitdbRelayMountPath}:ro`);
|
|
451
451
|
}
|
|
452
452
|
return {
|
|
453
453
|
mode: "docker",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@le-space/rootfs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Shared rootfs contract parsing, reference profile assets, and build helpers.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
|
-
"url": "https://github.com/NiKrause/
|
|
20
|
+
"url": "https://github.com/NiKrause/relay-button"
|
|
21
21
|
},
|
|
22
|
-
"homepage": "https://github.com/NiKrause/
|
|
22
|
+
"homepage": "https://github.com/NiKrause/relay-button",
|
|
23
23
|
"bugs": {
|
|
24
|
-
"url": "https://github.com/NiKrause/
|
|
24
|
+
"url": "https://github.com/NiKrause/relay-button/issues"
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"id": "orbitdb-relay
|
|
4
|
-
"displayName": "OrbitDB Relay
|
|
3
|
+
"id": "orbitdb-relay",
|
|
4
|
+
"displayName": "OrbitDB Relay",
|
|
5
5
|
"source": {
|
|
6
6
|
"repository": "external",
|
|
7
7
|
"subdirectory": "."
|
|
8
8
|
},
|
|
9
9
|
"rootfs": {
|
|
10
|
-
"profile": "orbitdb-relay
|
|
10
|
+
"profile": "orbitdb-relay",
|
|
11
11
|
"installMode": "prebaked",
|
|
12
|
-
"installDir": "/opt/orbitdb-relay
|
|
13
|
-
"binaryPath": "/usr/local/bin/orbitdb-relay
|
|
14
|
-
"dataDir": "/var/lib/orbitdb-relay
|
|
15
|
-
"envFile": "/etc/default/orbitdb-relay
|
|
12
|
+
"installDir": "/opt/orbitdb-relay",
|
|
13
|
+
"binaryPath": "/usr/local/bin/orbitdb-relay",
|
|
14
|
+
"dataDir": "/var/lib/orbitdb-relay",
|
|
15
|
+
"envFile": "/etc/default/orbitdb-relay"
|
|
16
16
|
},
|
|
17
17
|
"services": {
|
|
18
|
-
"bootstrap": "orbitdb-relay-
|
|
19
|
-
"main": "orbitdb-relay
|
|
20
|
-
"autotlsRefresh": "orbitdb-relay-
|
|
18
|
+
"bootstrap": "orbitdb-relay-bootstrap.service",
|
|
19
|
+
"main": "orbitdb-relay.service",
|
|
20
|
+
"autotlsRefresh": "orbitdb-relay-autotls-refresh.service"
|
|
21
21
|
},
|
|
22
22
|
"ports": [
|
|
23
23
|
{
|
|
@@ -8,7 +8,7 @@ ROOTFS_CONTRACT_FILE="${ROOTFS_CONTRACT_FILE:-}"
|
|
|
8
8
|
ROOTFS_PROFILE="${ROOTFS_PROFILE:-}"
|
|
9
9
|
ROOTFS_INSTALL_MODE="${ROOTFS_INSTALL_MODE:-}"
|
|
10
10
|
PY_LIBP2P_DIR="${PY_LIBP2P_DIR:-${REPO_DIR}/py-libp2p}"
|
|
11
|
-
|
|
11
|
+
ORBITDB_RELAY_DIR="${ORBITDB_RELAY_DIR:-}"
|
|
12
12
|
UNIVERSAL_CONNECTIVITY_DIR="${UNIVERSAL_CONNECTIVITY_DIR:-}"
|
|
13
13
|
OUT_DIR="${OUT_DIR:-${APP_DIR}/dist-rootfs}"
|
|
14
14
|
HOST_UID="${HOST_UID:-}"
|
|
@@ -17,6 +17,16 @@ BASE_URL="${BASE_URL:-https://cloud.debian.org/images/cloud/bookworm/latest/debi
|
|
|
17
17
|
BASE_IMAGE="${OUT_DIR}/debian-12-genericcloud-amd64.qcow2"
|
|
18
18
|
IMAGE_SIZE="${IMAGE_SIZE:-${ROOTFS_IMAGE_SIZE:-20G}}"
|
|
19
19
|
ROOTFS_SPARSIFY="${ROOTFS_SPARSIFY:-1}"
|
|
20
|
+
ROOTFS_SPARSIFY_TMPDIR=""
|
|
21
|
+
|
|
22
|
+
cleanup() {
|
|
23
|
+
if [ -n "${ROOTFS_SPARSIFY_TMPDIR}" ] && [ -d "${ROOTFS_SPARSIFY_TMPDIR}" ]; then
|
|
24
|
+
chmod -R u+w "${ROOTFS_SPARSIFY_TMPDIR}" 2>/dev/null || true
|
|
25
|
+
rm -rf "${ROOTFS_SPARSIFY_TMPDIR}"
|
|
26
|
+
fi
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
trap cleanup EXIT
|
|
20
30
|
|
|
21
31
|
require() {
|
|
22
32
|
command -v "$1" >/dev/null 2>&1 || {
|
|
@@ -32,13 +42,13 @@ require tar
|
|
|
32
42
|
|
|
33
43
|
load_rootfs_contract() {
|
|
34
44
|
[ -n "${ROOTFS_CONTRACT_FILE}" ] || return 0
|
|
35
|
-
require
|
|
45
|
+
require node
|
|
36
46
|
[ -f "${ROOTFS_CONTRACT_FILE}" ] || {
|
|
37
47
|
echo "Rootfs contract does not exist: ${ROOTFS_CONTRACT_FILE}" >&2
|
|
38
48
|
exit 1
|
|
39
49
|
}
|
|
40
50
|
|
|
41
|
-
eval "$(
|
|
51
|
+
eval "$(node "${SCRIPT_DIR}/read-rootfs-contract.mjs" "${ROOTFS_CONTRACT_FILE}")"
|
|
42
52
|
|
|
43
53
|
if [ -n "${ROOTFS_PROFILE}" ] && [ "${ROOTFS_PROFILE}" != "${ROOTFS_CONTRACT_PROFILE}" ]; then
|
|
44
54
|
echo "ROOTFS_PROFILE=${ROOTFS_PROFILE} conflicts with contract profile ${ROOTFS_CONTRACT_PROFILE}" >&2
|
|
@@ -77,27 +87,27 @@ case "${ROOTFS_PROFILE}" in
|
|
|
77
87
|
exit 1
|
|
78
88
|
fi
|
|
79
89
|
;;
|
|
80
|
-
orbitdb-relay
|
|
81
|
-
IMAGE="${OUT_DIR}/aleph-orbitdb-relay
|
|
82
|
-
APP_TAR="${OUT_DIR}/orbitdb-relay
|
|
90
|
+
orbitdb-relay)
|
|
91
|
+
IMAGE="${OUT_DIR}/aleph-orbitdb-relay.qcow2"
|
|
92
|
+
APP_TAR="${OUT_DIR}/orbitdb-relay.tar"
|
|
83
93
|
if [ -z "${ROOTFS_INSTALL_MODE}" ]; then
|
|
84
94
|
ROOTFS_INSTALL_MODE="prebaked"
|
|
85
95
|
fi
|
|
86
|
-
if [ -z "${
|
|
87
|
-
echo "ROOTFS_PROFILE=orbitdb-relay
|
|
96
|
+
if [ -z "${ORBITDB_RELAY_DIR}" ]; then
|
|
97
|
+
echo "ROOTFS_PROFILE=orbitdb-relay requires ORBITDB_RELAY_DIR=/path/to/orbitdb-relay" >&2
|
|
88
98
|
exit 1
|
|
89
99
|
fi
|
|
90
|
-
if [ ! -d "${
|
|
91
|
-
echo "Missing orbitdb-relay
|
|
100
|
+
if [ ! -d "${ORBITDB_RELAY_DIR}" ]; then
|
|
101
|
+
echo "Missing orbitdb-relay directory: ${ORBITDB_RELAY_DIR}" >&2
|
|
92
102
|
exit 1
|
|
93
103
|
fi
|
|
94
|
-
if [ ! -d "${
|
|
95
|
-
echo "Missing orbitdb-relay
|
|
96
|
-
echo "Build orbitdb-relay
|
|
104
|
+
if [ ! -d "${ORBITDB_RELAY_DIR}/dist" ]; then
|
|
105
|
+
echo "Missing orbitdb-relay dist directory: ${ORBITDB_RELAY_DIR}/dist" >&2
|
|
106
|
+
echo "Build orbitdb-relay before creating this rootfs image." >&2
|
|
97
107
|
exit 1
|
|
98
108
|
fi
|
|
99
109
|
if [ "${ROOTFS_INSTALL_MODE}" = "thin" ]; then
|
|
100
|
-
echo "ROOTFS_PROFILE=orbitdb-relay
|
|
110
|
+
echo "ROOTFS_PROFILE=orbitdb-relay now requires ROOTFS_INSTALL_MODE=prebaked." >&2
|
|
101
111
|
echo "The runtime is installed into the image, then configured with mapped ports before first start." >&2
|
|
102
112
|
exit 1
|
|
103
113
|
fi
|
|
@@ -144,7 +154,7 @@ case "${ROOTFS_PROFILE}" in
|
|
|
144
154
|
;;
|
|
145
155
|
*)
|
|
146
156
|
echo "Unsupported ROOTFS_PROFILE: ${ROOTFS_PROFILE}" >&2
|
|
147
|
-
echo "Expected one of: py-libp2p, orbitdb-relay
|
|
157
|
+
echo "Expected one of: py-libp2p, orbitdb-relay, uc-go-peer, uc-rust-peer" >&2
|
|
148
158
|
exit 1
|
|
149
159
|
;;
|
|
150
160
|
esac
|
|
@@ -205,9 +215,9 @@ case "${ROOTFS_PROFILE}" in
|
|
|
205
215
|
|
|
206
216
|
virt-customize "${py_customize_args[@]}"
|
|
207
217
|
;;
|
|
208
|
-
orbitdb-relay
|
|
218
|
+
orbitdb-relay)
|
|
209
219
|
tar \
|
|
210
|
-
-C "${
|
|
220
|
+
-C "${ORBITDB_RELAY_DIR}" \
|
|
211
221
|
-cf "${APP_TAR}" \
|
|
212
222
|
dist \
|
|
213
223
|
deploy \
|
|
@@ -220,35 +230,35 @@ case "${ROOTFS_PROFILE}" in
|
|
|
220
230
|
|
|
221
231
|
orbitdb_customize_args=(
|
|
222
232
|
-a "${IMAGE}"
|
|
223
|
-
--mkdir /opt/orbitdb-relay
|
|
224
|
-
--mkdir /var/lib/orbitdb-relay
|
|
225
|
-
--mkdir /etc/systemd/system/orbitdb-relay
|
|
233
|
+
--mkdir /opt/orbitdb-relay
|
|
234
|
+
--mkdir /var/lib/orbitdb-relay
|
|
235
|
+
--mkdir /etc/systemd/system/orbitdb-relay.service.d
|
|
226
236
|
--copy-in "${APP_TAR}:/opt"
|
|
227
|
-
--copy-in "${SCRIPT_DIR}/orbitdb-relay-
|
|
228
|
-
--copy-in "${SCRIPT_DIR}/orbitdb-relay-
|
|
229
|
-
--copy-in "${SCRIPT_DIR}/orbitdb-relay-
|
|
230
|
-
--copy-in "${SCRIPT_DIR}/orbitdb-relay-
|
|
231
|
-
--copy-in "${SCRIPT_DIR}/orbitdb-relay-
|
|
232
|
-
--copy-in "${SCRIPT_DIR}/orbitdb-relay-
|
|
233
|
-
--copy-in "${SCRIPT_DIR}/orbitdb-relay-
|
|
234
|
-
--copy-in "${SCRIPT_DIR}/orbitdb-relay-
|
|
235
|
-
--copy-in "${SCRIPT_DIR}/orbitdb-relay-
|
|
236
|
-
--copy-in "${SCRIPT_DIR}/orbitdb-relay-
|
|
237
|
-
--copy-in "${SCRIPT_DIR}/orbitdb-relay-
|
|
238
|
-
--run-command "tar -xf /opt/$(basename "${APP_TAR}") -C /opt/orbitdb-relay
|
|
239
|
-
--run-command "chmod 0755 /usr/local/sbin/orbitdb-relay-
|
|
240
|
-
--run-command "chmod 0755 /usr/local/sbin/orbitdb-relay-
|
|
241
|
-
--run-command "chmod 0755 /usr/local/sbin/orbitdb-relay-
|
|
242
|
-
--run-command "chmod 0755 /usr/local/sbin/orbitdb-relay-
|
|
243
|
-
--run-command "chmod 0755 /usr/local/sbin/orbitdb-relay-
|
|
244
|
-
--run-command "chmod 0755 /usr/local/sbin/orbitdb-relay-
|
|
245
|
-
--run-command "cp /opt/orbitdb-relay
|
|
246
|
-
--run-command "INSTALL_DIR=/opt/orbitdb-relay
|
|
237
|
+
--copy-in "${SCRIPT_DIR}/orbitdb-relay-bootstrap.sh:/usr/local/sbin"
|
|
238
|
+
--copy-in "${SCRIPT_DIR}/orbitdb-relay-configure.sh:/usr/local/sbin"
|
|
239
|
+
--copy-in "${SCRIPT_DIR}/orbitdb-relay-bootstrap-refresh.py:/usr/local/sbin"
|
|
240
|
+
--copy-in "${SCRIPT_DIR}/orbitdb-relay-autotls-refresh.py:/usr/local/sbin"
|
|
241
|
+
--copy-in "${SCRIPT_DIR}/orbitdb-relay-setup-server.py:/usr/local/sbin"
|
|
242
|
+
--copy-in "${SCRIPT_DIR}/orbitdb-relay-describe.py:/usr/local/sbin"
|
|
243
|
+
--copy-in "${SCRIPT_DIR}/orbitdb-relay-bootstrap.service:/etc/systemd/system"
|
|
244
|
+
--copy-in "${SCRIPT_DIR}/orbitdb-relay-bootstrap-refresh.service:/etc/systemd/system"
|
|
245
|
+
--copy-in "${SCRIPT_DIR}/orbitdb-relay-bootstrap-refresh.timer:/etc/systemd/system"
|
|
246
|
+
--copy-in "${SCRIPT_DIR}/orbitdb-relay-autotls-refresh.service:/etc/systemd/system"
|
|
247
|
+
--copy-in "${SCRIPT_DIR}/orbitdb-relay-bootstrap.conf:/etc/systemd/system/orbitdb-relay.service.d"
|
|
248
|
+
--run-command "tar -xf /opt/$(basename "${APP_TAR}") -C /opt/orbitdb-relay"
|
|
249
|
+
--run-command "chmod 0755 /usr/local/sbin/orbitdb-relay-bootstrap.sh"
|
|
250
|
+
--run-command "chmod 0755 /usr/local/sbin/orbitdb-relay-configure.sh"
|
|
251
|
+
--run-command "chmod 0755 /usr/local/sbin/orbitdb-relay-bootstrap-refresh.py"
|
|
252
|
+
--run-command "chmod 0755 /usr/local/sbin/orbitdb-relay-autotls-refresh.py"
|
|
253
|
+
--run-command "chmod 0755 /usr/local/sbin/orbitdb-relay-setup-server.py"
|
|
254
|
+
--run-command "chmod 0755 /usr/local/sbin/orbitdb-relay-describe.py"
|
|
255
|
+
--run-command "cp /opt/orbitdb-relay/deploy/orbitdb-relay.service /etc/systemd/system/orbitdb-relay.service"
|
|
256
|
+
--run-command "INSTALL_DIR=/opt/orbitdb-relay DATA_DIR=/var/lib/orbitdb-relay ENV_FILE=/etc/default/orbitdb-relay SERVICE_USER=orbitdb-relay /usr/local/sbin/orbitdb-relay-bootstrap.sh"
|
|
247
257
|
)
|
|
248
258
|
|
|
249
259
|
orbitdb_customize_args+=(
|
|
250
|
-
--run-command "systemctl enable orbitdb-relay-
|
|
251
|
-
--run-command "systemctl enable orbitdb-relay
|
|
260
|
+
--run-command "systemctl enable orbitdb-relay-bootstrap.service"
|
|
261
|
+
--run-command "systemctl enable orbitdb-relay.service"
|
|
252
262
|
--run-command "rm -f /opt/$(basename "${APP_TAR}")"
|
|
253
263
|
)
|
|
254
264
|
|
|
@@ -333,8 +343,10 @@ esac
|
|
|
333
343
|
if [ "${ROOTFS_SPARSIFY}" = "1" ] && command -v virt-sparsify >/dev/null 2>&1; then
|
|
334
344
|
SPARSE_IMAGE="${IMAGE%.qcow2}.sparse.qcow2"
|
|
335
345
|
rm -f "${SPARSE_IMAGE}"
|
|
346
|
+
ROOTFS_SPARSIFY_TMPDIR="$(mktemp -d "${OUT_DIR}/virt-sparsify-tmp.XXXXXX")"
|
|
336
347
|
echo "Sparsifying and compressing ${IMAGE}..."
|
|
337
|
-
|
|
348
|
+
echo "Using ${ROOTFS_SPARSIFY_TMPDIR} for virt-sparsify scratch space"
|
|
349
|
+
TMPDIR="${ROOTFS_SPARSIFY_TMPDIR}" virt-sparsify --check-tmpdir=continue --compress "${IMAGE}" "${SPARSE_IMAGE}"
|
|
338
350
|
mv "${SPARSE_IMAGE}" "${IMAGE}"
|
|
339
351
|
fi
|
|
340
352
|
|
|
@@ -14,7 +14,7 @@ CHANNEL="${CHANNEL:-ALEPH-CLOUDSOLUTIONS}"
|
|
|
14
14
|
SKIP_UPLOAD="${SKIP_UPLOAD:-0}"
|
|
15
15
|
SKIP_BUILD="${SKIP_BUILD:-0}"
|
|
16
16
|
IPFS_ADD_URL="${IPFS_ADD_URL:-https://ipfs.aleph.cloud/api/v0/add}"
|
|
17
|
-
|
|
17
|
+
ORBITDB_RELAY_DIR="${ORBITDB_RELAY_DIR:-}"
|
|
18
18
|
UNIVERSAL_CONNECTIVITY_DIR="${UNIVERSAL_CONNECTIVITY_DIR:-}"
|
|
19
19
|
|
|
20
20
|
require() {
|
|
@@ -61,9 +61,9 @@ case "${ROOTFS_PROFILE}" in
|
|
|
61
61
|
ROOTFS_INSTALL_MODE="thin"
|
|
62
62
|
fi
|
|
63
63
|
;;
|
|
64
|
-
orbitdb-relay
|
|
65
|
-
IMAGE_BASENAME="aleph-orbitdb-relay
|
|
66
|
-
DEFAULT_ROOTFS_VERSION="orbitdb-relay-
|
|
64
|
+
orbitdb-relay)
|
|
65
|
+
IMAGE_BASENAME="aleph-orbitdb-relay.qcow2"
|
|
66
|
+
DEFAULT_ROOTFS_VERSION="orbitdb-relay-v0.1.0"
|
|
67
67
|
if [ -z "${ROOTFS_INSTALL_MODE}" ]; then
|
|
68
68
|
ROOTFS_INSTALL_MODE="prebaked"
|
|
69
69
|
fi
|
|
@@ -84,7 +84,7 @@ case "${ROOTFS_PROFILE}" in
|
|
|
84
84
|
;;
|
|
85
85
|
*)
|
|
86
86
|
echo "Unsupported ROOTFS_PROFILE: ${ROOTFS_PROFILE}" >&2
|
|
87
|
-
echo "Expected one of: py-libp2p, orbitdb-relay
|
|
87
|
+
echo "Expected one of: py-libp2p, orbitdb-relay, uc-go-peer, uc-rust-peer" >&2
|
|
88
88
|
exit 1
|
|
89
89
|
;;
|
|
90
90
|
esac
|
|
@@ -117,12 +117,12 @@ resolve_rootfs_version() {
|
|
|
117
117
|
return
|
|
118
118
|
fi
|
|
119
119
|
|
|
120
|
-
if [ "${ROOTFS_PROFILE}" = "orbitdb-relay
|
|
121
|
-
local orbitdb_package_json="${
|
|
120
|
+
if [ "${ROOTFS_PROFILE}" = "orbitdb-relay" ] && [ -n "${ORBITDB_RELAY_DIR}" ]; then
|
|
121
|
+
local orbitdb_package_json="${ORBITDB_RELAY_DIR}/package.json"
|
|
122
122
|
if [ -f "${orbitdb_package_json}" ] && command -v node >/dev/null 2>&1; then
|
|
123
123
|
local orbitdb_version
|
|
124
124
|
orbitdb_version="$(
|
|
125
|
-
node -e "const fs=require('node:fs');const payload=JSON.parse(fs.readFileSync(process.argv[1],'utf8'));const version=typeof payload.version==='string'?payload.version.trim():'';if(!version)process.exit(1);console.log('orbitdb-relay-
|
|
125
|
+
node -e "const fs=require('node:fs');const payload=JSON.parse(fs.readFileSync(process.argv[1],'utf8'));const version=typeof payload.version==='string'?payload.version.trim():'';if(!version)process.exit(1);console.log('orbitdb-relay-v'+version.replace(/^v/,''));" "${orbitdb_package_json}"
|
|
126
126
|
)" || orbitdb_version=""
|
|
127
127
|
|
|
128
128
|
if [ -n "${orbitdb_version}" ]; then
|
|
@@ -185,17 +185,17 @@ build_with_docker() {
|
|
|
185
185
|
local orbitdb_env=()
|
|
186
186
|
local uc_mount=()
|
|
187
187
|
local uc_env=()
|
|
188
|
-
if [ "${ROOTFS_PROFILE}" = "orbitdb-relay
|
|
189
|
-
if [ -z "${
|
|
190
|
-
echo "ROOTFS_PROFILE=orbitdb-relay
|
|
188
|
+
if [ "${ROOTFS_PROFILE}" = "orbitdb-relay" ]; then
|
|
189
|
+
if [ -z "${ORBITDB_RELAY_DIR}" ]; then
|
|
190
|
+
echo "ROOTFS_PROFILE=orbitdb-relay requires ORBITDB_RELAY_DIR=/path/to/orbitdb-relay" >&2
|
|
191
191
|
exit 1
|
|
192
192
|
fi
|
|
193
|
-
if [ ! -d "${
|
|
194
|
-
echo "Missing orbitdb-relay
|
|
193
|
+
if [ ! -d "${ORBITDB_RELAY_DIR}" ]; then
|
|
194
|
+
echo "Missing orbitdb-relay directory: ${ORBITDB_RELAY_DIR}" >&2
|
|
195
195
|
exit 1
|
|
196
196
|
fi
|
|
197
|
-
orbitdb_mount=(-v "${
|
|
198
|
-
orbitdb_env=(-e
|
|
197
|
+
orbitdb_mount=(-v "${ORBITDB_RELAY_DIR}:/workspace-orbitdb-relay:ro")
|
|
198
|
+
orbitdb_env=(-e ORBITDB_RELAY_DIR=/workspace-orbitdb-relay)
|
|
199
199
|
fi
|
|
200
200
|
if [ "${ROOTFS_PROFILE}" = "uc-rust-peer" ]; then
|
|
201
201
|
if [ -z "${UNIVERSAL_CONNECTIVITY_DIR}" ]; then
|
|
@@ -247,7 +247,7 @@ required_port_forwards_json() {
|
|
|
247
247
|
fi
|
|
248
248
|
|
|
249
249
|
case "${ROOTFS_PROFILE}" in
|
|
250
|
-
orbitdb-relay
|
|
250
|
+
orbitdb-relay)
|
|
251
251
|
cat <<'EOF'
|
|
252
252
|
"requiredPortForwards": [
|
|
253
253
|
{ "port": 22, "tcp": true, "udp": false, "purpose": "SSH" },
|
|
@@ -8,17 +8,17 @@ import urllib.request
|
|
|
8
8
|
from typing import Iterable
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
ENV_FILE = os.environ.get("ENV_FILE", "/etc/default/orbitdb-relay
|
|
12
|
-
READY_FILE = os.environ.get("READY_FILE", "/etc/default/orbitdb-relay
|
|
11
|
+
ENV_FILE = os.environ.get("ENV_FILE", "/etc/default/orbitdb-relay")
|
|
12
|
+
READY_FILE = os.environ.get("READY_FILE", "/etc/default/orbitdb-relay.ready")
|
|
13
13
|
AUTOTLS_READY_FILE = os.environ.get(
|
|
14
|
-
"AUTOTLS_READY_FILE", "/etc/default/orbitdb-relay
|
|
14
|
+
"AUTOTLS_READY_FILE", "/etc/default/orbitdb-relay.autotls-ready"
|
|
15
15
|
)
|
|
16
|
-
AUTOTLS_ZONE_FILE = os.environ.get("AUTOTLS_ZONE_FILE", "/etc/default/orbitdb-relay
|
|
17
|
-
AUTOTLS_HOSTS_FILE = os.environ.get("AUTOTLS_HOSTS_FILE", "/etc/default/orbitdb-relay
|
|
16
|
+
AUTOTLS_ZONE_FILE = os.environ.get("AUTOTLS_ZONE_FILE", "/etc/default/orbitdb-relay.autotls-zone")
|
|
17
|
+
AUTOTLS_HOSTS_FILE = os.environ.get("AUTOTLS_HOSTS_FILE", "/etc/default/orbitdb-relay.autotls-hosts")
|
|
18
18
|
AUTOTLS_CADDY_READY_FILE = os.environ.get(
|
|
19
|
-
"AUTOTLS_CADDY_READY_FILE", "/etc/default/orbitdb-relay
|
|
19
|
+
"AUTOTLS_CADDY_READY_FILE", "/etc/default/orbitdb-relay.caddy-ready"
|
|
20
20
|
)
|
|
21
|
-
SERVICE_NAME = os.environ.get("SERVICE_NAME", "orbitdb-relay
|
|
21
|
+
SERVICE_NAME = os.environ.get("SERVICE_NAME", "orbitdb-relay.service")
|
|
22
22
|
CADDY_SERVICE = os.environ.get("CADDY_SERVICE", "caddy.service")
|
|
23
23
|
CADDYFILE = os.environ.get("CADDYFILE", "/etc/caddy/Caddyfile")
|
|
24
24
|
METRICS_PORT = int(os.environ.get("METRICS_PORT", "9090"))
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[Unit]
|
|
2
|
+
Description=Persist AutoTLS secure announce addresses for orbitdb-relay
|
|
3
|
+
After=orbitdb-relay.service
|
|
4
|
+
Wants=orbitdb-relay.service
|
|
5
|
+
ConditionPathExists=/etc/default/orbitdb-relay.ready
|
|
6
|
+
ConditionPathExists=!/etc/default/orbitdb-relay.autotls-ready
|
|
7
|
+
|
|
8
|
+
[Service]
|
|
9
|
+
Type=oneshot
|
|
10
|
+
Environment=ENV_FILE=/etc/default/orbitdb-relay
|
|
11
|
+
Environment=READY_FILE=/etc/default/orbitdb-relay.ready
|
|
12
|
+
Environment=AUTOTLS_READY_FILE=/etc/default/orbitdb-relay.autotls-ready
|
|
13
|
+
Environment=AUTOTLS_ZONE_FILE=/etc/default/orbitdb-relay.autotls-zone
|
|
14
|
+
Environment=AUTOTLS_HOSTS_FILE=/etc/default/orbitdb-relay.autotls-hosts
|
|
15
|
+
Environment=AUTOTLS_CADDY_READY_FILE=/etc/default/orbitdb-relay.caddy-ready
|
|
16
|
+
Environment=SERVICE_NAME=orbitdb-relay.service
|
|
17
|
+
Environment=CADDY_SERVICE=caddy.service
|
|
18
|
+
Environment=CADDYFILE=/etc/caddy/Caddyfile
|
|
19
|
+
ExecStart=/usr/bin/python3 /usr/local/sbin/orbitdb-relay-autotls-refresh.py
|
|
20
|
+
StandardOutput=journal
|
|
21
|
+
StandardError=journal
|
|
22
|
+
|
|
23
|
+
[Install]
|
|
24
|
+
WantedBy=multi-user.target
|
|
@@ -20,15 +20,15 @@ except ImportError as error: # pragma: no cover - runtime dependency
|
|
|
20
20
|
) from error
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
ENV_FILE = os.environ.get("ENV_FILE", "/etc/default/orbitdb-relay
|
|
23
|
+
ENV_FILE = os.environ.get("ENV_FILE", "/etc/default/orbitdb-relay")
|
|
24
24
|
DESCRIBE_SCRIPT = os.environ.get(
|
|
25
|
-
"DESCRIBE_SCRIPT", "/usr/local/sbin/orbitdb-relay-
|
|
25
|
+
"DESCRIBE_SCRIPT", "/usr/local/sbin/orbitdb-relay-describe.py"
|
|
26
26
|
)
|
|
27
27
|
DEFAULT_API_HOST = os.environ.get("ALEPH_BOOTSTRAP_API_HOST", "https://api.aleph.im")
|
|
28
28
|
DEFAULT_CHANNEL = os.environ.get("ALEPH_BOOTSTRAP_CHANNEL", "simple-todo")
|
|
29
29
|
DEFAULT_REF = os.environ.get("ALEPH_BOOTSTRAP_REF", "simple-todo-bootstrap")
|
|
30
30
|
DEFAULT_POST_TYPE = os.environ.get("ALEPH_BOOTSTRAP_POST_TYPE", "relay-bootstrap")
|
|
31
|
-
DEFAULT_PROFILE = os.environ.get("ALEPH_BOOTSTRAP_PROFILE", "orbitdb-relay
|
|
31
|
+
DEFAULT_PROFILE = os.environ.get("ALEPH_BOOTSTRAP_PROFILE", "orbitdb-relay")
|
|
32
32
|
MAX_PREVIOUS_PAGES = int(os.environ.get("ALEPH_BOOTSTRAP_MAX_PREVIOUS_PAGES", "5"))
|
|
33
33
|
PAGINATION = int(os.environ.get("ALEPH_BOOTSTRAP_PAGINATION", "50"))
|
|
34
34
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
[Unit]
|
|
2
|
+
Description=Refresh Aleph bootstrap registration for orbitdb-relay
|
|
3
|
+
Wants=network-online.target
|
|
4
|
+
After=network-online.target orbitdb-relay.service
|
|
5
|
+
ConditionPathExists=/etc/default/orbitdb-relay.ready
|
|
6
|
+
|
|
7
|
+
[Service]
|
|
8
|
+
Type=oneshot
|
|
9
|
+
Environment=ENV_FILE=/etc/default/orbitdb-relay
|
|
10
|
+
Environment=DESCRIBE_SCRIPT=/usr/local/sbin/orbitdb-relay-describe.py
|
|
11
|
+
ExecStart=/usr/bin/python3 /usr/local/sbin/orbitdb-relay-bootstrap-refresh.py
|
|
12
|
+
StandardOutput=journal
|
|
13
|
+
StandardError=journal
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[Unit]
|
|
2
|
-
Description=Periodic Aleph bootstrap refresh for orbitdb-relay
|
|
2
|
+
Description=Periodic Aleph bootstrap refresh for orbitdb-relay
|
|
3
3
|
|
|
4
4
|
[Timer]
|
|
5
5
|
OnBootSec=20m
|
|
6
6
|
OnUnitActiveSec=6h
|
|
7
7
|
RandomizedDelaySec=15m
|
|
8
8
|
Persistent=true
|
|
9
|
-
Unit=orbitdb-relay-
|
|
9
|
+
Unit=orbitdb-relay-bootstrap-refresh.service
|
|
10
10
|
|
|
11
11
|
[Install]
|
|
12
12
|
WantedBy=timers.target
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[Unit]
|
|
2
|
+
Description=Temporary orbitdb-relay setup endpoint
|
|
3
|
+
Wants=network-online.target
|
|
4
|
+
After=network-online.target
|
|
5
|
+
ConditionPathExists=!/etc/default/orbitdb-relay.ready
|
|
6
|
+
|
|
7
|
+
[Service]
|
|
8
|
+
Environment=ENV_FILE=/etc/default/orbitdb-relay
|
|
9
|
+
Environment=READY_FILE=/etc/default/orbitdb-relay.ready
|
|
10
|
+
Environment=SERVICE_NAME=orbitdb-relay.service
|
|
11
|
+
Environment=BOOTSTRAP_SERVICE=orbitdb-relay-bootstrap.service
|
|
12
|
+
Environment=METADATA_FILE=/run/orbitdb-relay-setup-metadata.json
|
|
13
|
+
Environment=METADATA_ERROR_FILE=/run/orbitdb-relay-setup-metadata.error
|
|
14
|
+
ExecStart=/usr/bin/python3 /usr/local/sbin/orbitdb-relay-setup-server.py
|
|
15
|
+
StandardOutput=journal
|
|
16
|
+
StandardError=journal
|
|
17
|
+
Restart=on-failure
|
|
18
|
+
RestartSec=2s
|
|
19
|
+
|
|
20
|
+
[Install]
|
|
21
|
+
WantedBy=multi-user.target
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
set -euo pipefail
|
|
3
3
|
|
|
4
|
-
INSTALL_DIR="${INSTALL_DIR:-/opt/orbitdb-relay
|
|
4
|
+
INSTALL_DIR="${INSTALL_DIR:-/opt/orbitdb-relay}"
|
|
5
5
|
SERVICE_USER="${SERVICE_USER:-orbitdb-relay}"
|
|
6
|
-
DATA_DIR="${DATA_DIR:-/var/lib/orbitdb-relay
|
|
7
|
-
ENV_FILE="${ENV_FILE:-/etc/default/orbitdb-relay
|
|
6
|
+
DATA_DIR="${DATA_DIR:-/var/lib/orbitdb-relay}"
|
|
7
|
+
ENV_FILE="${ENV_FILE:-/etc/default/orbitdb-relay}"
|
|
8
8
|
NODE_MIN_MAJOR="${NODE_MIN_MAJOR:-22}"
|
|
9
|
-
CADDY_READY_FILE="${CADDY_READY_FILE:-/etc/default/orbitdb-relay
|
|
9
|
+
CADDY_READY_FILE="${CADDY_READY_FILE:-/etc/default/orbitdb-relay.caddy-ready}"
|
|
10
10
|
|
|
11
11
|
if [ ! -d "${INSTALL_DIR}" ]; then
|
|
12
|
-
echo "Missing ${INSTALL_DIR}; the rootfs build did not copy orbitdb-relay
|
|
12
|
+
echo "Missing ${INSTALL_DIR}; the rootfs build did not copy orbitdb-relay."
|
|
13
13
|
exit 1
|
|
14
14
|
fi
|
|
15
15
|
|
|
@@ -74,17 +74,17 @@ rm -rf "${DATA_DIR}/.cache/corepack" "${DATA_DIR}/.npm" "${DATA_DIR}/.cache/npm"
|
|
|
74
74
|
rm -rf "${INSTALL_DIR}/node_modules/.cache"
|
|
75
75
|
|
|
76
76
|
mkdir -p "${INSTALL_DIR}/node_modules"
|
|
77
|
-
ln -sfn "${INSTALL_DIR}" "${INSTALL_DIR}/node_modules/orbitdb-relay
|
|
77
|
+
ln -sfn "${INSTALL_DIR}" "${INSTALL_DIR}/node_modules/orbitdb-relay"
|
|
78
78
|
|
|
79
|
-
cat > /usr/local/bin/orbitdb-relay
|
|
79
|
+
cat > /usr/local/bin/orbitdb-relay <<'EOF'
|
|
80
80
|
#!/usr/bin/env bash
|
|
81
81
|
set -euo pipefail
|
|
82
|
-
exec /usr/bin/node /opt/orbitdb-relay
|
|
82
|
+
exec /usr/bin/node /opt/orbitdb-relay/dist/cli.js "$@"
|
|
83
83
|
EOF
|
|
84
|
-
chmod 0755 /usr/local/bin/orbitdb-relay
|
|
84
|
+
chmod 0755 /usr/local/bin/orbitdb-relay
|
|
85
85
|
|
|
86
|
-
if [ -f "${INSTALL_DIR}/deploy/orbitdb-relay
|
|
87
|
-
cp "${INSTALL_DIR}/deploy/orbitdb-relay
|
|
86
|
+
if [ -f "${INSTALL_DIR}/deploy/orbitdb-relay.env.example" ] && [ ! -f "${ENV_FILE}" ]; then
|
|
87
|
+
cp "${INSTALL_DIR}/deploy/orbitdb-relay.env.example" "${ENV_FILE}"
|
|
88
88
|
fi
|
|
89
89
|
|
|
90
90
|
touch "${ENV_FILE}"
|
|
@@ -93,7 +93,7 @@ chown "root:${SERVICE_USER}" "${ENV_FILE}"
|
|
|
93
93
|
rm -f "${CADDY_READY_FILE}"
|
|
94
94
|
|
|
95
95
|
mkdir -p /etc/caddy /etc/systemd/system/caddy.service.d
|
|
96
|
-
cat > /etc/systemd/system/caddy.service.d/orbitdb-relay
|
|
96
|
+
cat > /etc/systemd/system/caddy.service.d/orbitdb-relay.conf <<EOF
|
|
97
97
|
[Unit]
|
|
98
98
|
ConditionPathExists=${CADDY_READY_FILE}
|
|
99
99
|
EOF
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
set -euo pipefail
|
|
3
3
|
|
|
4
|
-
ENV_FILE="${ENV_FILE:-/etc/default/orbitdb-relay
|
|
5
|
-
READY_FILE="${READY_FILE:-/etc/default/orbitdb-relay
|
|
6
|
-
AUTOTLS_READY_FILE="${AUTOTLS_READY_FILE:-/etc/default/orbitdb-relay
|
|
7
|
-
AUTOTLS_ZONE_FILE="${AUTOTLS_ZONE_FILE:-/etc/default/orbitdb-relay
|
|
8
|
-
AUTOTLS_HOSTS_FILE="${AUTOTLS_HOSTS_FILE:-/etc/default/orbitdb-relay
|
|
9
|
-
SERVICE_NAME="${SERVICE_NAME:-orbitdb-relay
|
|
4
|
+
ENV_FILE="${ENV_FILE:-/etc/default/orbitdb-relay}"
|
|
5
|
+
READY_FILE="${READY_FILE:-/etc/default/orbitdb-relay.ready}"
|
|
6
|
+
AUTOTLS_READY_FILE="${AUTOTLS_READY_FILE:-/etc/default/orbitdb-relay.autotls-ready}"
|
|
7
|
+
AUTOTLS_ZONE_FILE="${AUTOTLS_ZONE_FILE:-/etc/default/orbitdb-relay.autotls-zone}"
|
|
8
|
+
AUTOTLS_HOSTS_FILE="${AUTOTLS_HOSTS_FILE:-/etc/default/orbitdb-relay.autotls-hosts}"
|
|
9
|
+
SERVICE_NAME="${SERVICE_NAME:-orbitdb-relay.service}"
|
|
10
10
|
CADDY_SERVICE="${CADDY_SERVICE:-caddy.service}"
|
|
11
|
-
CADDY_READY_FILE="${CADDY_READY_FILE:-/etc/default/orbitdb-relay
|
|
11
|
+
CADDY_READY_FILE="${CADDY_READY_FILE:-/etc/default/orbitdb-relay.caddy-ready}"
|
|
12
12
|
CADDYFILE="${CADDYFILE:-/etc/caddy/Caddyfile}"
|
|
13
13
|
CADDY_UPSTREAM_WSS_PORT="${CADDY_UPSTREAM_WSS_PORT:-9092}"
|
|
14
14
|
CADDY_UPSTREAM_HOST="${CADDY_UPSTREAM_HOST:-127.0.0.1}"
|
|
15
15
|
CADDY_UPSTREAM_METRICS_PORT="${CADDY_UPSTREAM_METRICS_PORT:-9090}"
|
|
16
|
-
AUTOTLS_REFRESH_SERVICE="${AUTOTLS_REFRESH_SERVICE:-orbitdb-relay-
|
|
17
|
-
BOOTSTRAP_REFRESH_TIMER="${BOOTSTRAP_REFRESH_TIMER:-orbitdb-relay-
|
|
16
|
+
AUTOTLS_REFRESH_SERVICE="${AUTOTLS_REFRESH_SERVICE:-orbitdb-relay-autotls-refresh.service}"
|
|
17
|
+
BOOTSTRAP_REFRESH_TIMER="${BOOTSTRAP_REFRESH_TIMER:-orbitdb-relay-bootstrap-refresh.timer}"
|
|
18
18
|
PUBLIC_IPV4=""
|
|
19
19
|
PUBLIC_IPV6=""
|
|
20
20
|
TCP_PORT=""
|
|
@@ -34,7 +34,7 @@ START_SERVICE=1
|
|
|
34
34
|
usage() {
|
|
35
35
|
cat <<'EOF'
|
|
36
36
|
Usage:
|
|
37
|
-
orbitdb-relay-
|
|
37
|
+
orbitdb-relay-configure.sh \
|
|
38
38
|
--public-ipv4 <ip> \
|
|
39
39
|
[--public-ipv6 <ipv6>] \
|
|
40
40
|
--tcp-port <host-port> \
|
|
@@ -76,7 +76,7 @@ write_caddyfile() {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
${hostname} {
|
|
79
|
-
# Proxy the full orbitdb-relay
|
|
79
|
+
# Proxy the full orbitdb-relay HTTP API surface to the metrics/HTTP port.
|
|
80
80
|
# Everything else falls through to the relay WebSocket backend for browser libp2p.
|
|
81
81
|
handle /health {
|
|
82
82
|
reverse_proxy 127.0.0.1:${CADDY_UPSTREAM_METRICS_PORT}
|
|
@@ -263,7 +263,7 @@ fi
|
|
|
263
263
|
if [ -n "${BOOTSTRAP_REGISTRATION_ID}" ]; then
|
|
264
264
|
write_env_var "ALEPH_BOOTSTRAP_REGISTRATION_ID" "${BOOTSTRAP_REGISTRATION_ID}"
|
|
265
265
|
fi
|
|
266
|
-
write_env_var "ALEPH_BOOTSTRAP_PROFILE" "orbitdb-relay
|
|
266
|
+
write_env_var "ALEPH_BOOTSTRAP_PROFILE" "orbitdb-relay"
|
|
267
267
|
touch "${READY_FILE}"
|
|
268
268
|
|
|
269
269
|
if [ "${START_SERVICE}" -eq 1 ]; then
|
|
@@ -6,7 +6,7 @@ import urllib.error
|
|
|
6
6
|
import urllib.request
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
ENV_FILE = os.environ.get("ENV_FILE", "/etc/default/orbitdb-relay
|
|
9
|
+
ENV_FILE = os.environ.get("ENV_FILE", "/etc/default/orbitdb-relay")
|
|
10
10
|
METRICS_PORT = int(os.environ.get("METRICS_PORT", "9090"))
|
|
11
11
|
WAIT_TIMEOUT_SECONDS = int(os.environ.get("DESCRIBE_WAIT_TIMEOUT_SECONDS", "240"))
|
|
12
12
|
WAIT_INTERVAL_SECONDS = float(os.environ.get("DESCRIBE_WAIT_INTERVAL_SECONDS", "2"))
|
|
@@ -9,14 +9,14 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
|
9
9
|
from urllib.parse import urlsplit
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
ENV_FILE = os.environ.get("ENV_FILE", "/etc/default/orbitdb-relay
|
|
13
|
-
READY_FILE = os.environ.get("READY_FILE", "/etc/default/orbitdb-relay
|
|
14
|
-
SERVICE_NAME = os.environ.get("SERVICE_NAME", "orbitdb-relay
|
|
15
|
-
BOOTSTRAP_SERVICE = os.environ.get("BOOTSTRAP_SERVICE", "orbitdb-relay-
|
|
16
|
-
CONFIGURE_SCRIPT = "/usr/local/sbin/orbitdb-relay-
|
|
17
|
-
DESCRIBE_SCRIPT = "/usr/local/sbin/orbitdb-relay-
|
|
18
|
-
METADATA_FILE = os.environ.get("METADATA_FILE", "/run/orbitdb-relay-
|
|
19
|
-
METADATA_ERROR_FILE = os.environ.get("METADATA_ERROR_FILE", "/run/orbitdb-relay-
|
|
12
|
+
ENV_FILE = os.environ.get("ENV_FILE", "/etc/default/orbitdb-relay")
|
|
13
|
+
READY_FILE = os.environ.get("READY_FILE", "/etc/default/orbitdb-relay.ready")
|
|
14
|
+
SERVICE_NAME = os.environ.get("SERVICE_NAME", "orbitdb-relay.service")
|
|
15
|
+
BOOTSTRAP_SERVICE = os.environ.get("BOOTSTRAP_SERVICE", "orbitdb-relay-bootstrap.service")
|
|
16
|
+
CONFIGURE_SCRIPT = "/usr/local/sbin/orbitdb-relay-configure.sh"
|
|
17
|
+
DESCRIBE_SCRIPT = "/usr/local/sbin/orbitdb-relay-describe.py"
|
|
18
|
+
METADATA_FILE = os.environ.get("METADATA_FILE", "/run/orbitdb-relay-setup-metadata.json")
|
|
19
|
+
METADATA_ERROR_FILE = os.environ.get("METADATA_ERROR_FILE", "/run/orbitdb-relay-setup-metadata.error")
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
def _cors_headers(handler: BaseHTTPRequestHandler) -> None:
|
|
@@ -13,6 +13,7 @@ APP_BINARY="${OUT_DIR}/universal-chat-go"
|
|
|
13
13
|
ROOTFS_IMAGE_SIZE="${ROOTFS_IMAGE_SIZE:-20G}"
|
|
14
14
|
ROOTFS_SPARSIFY="${ROOTFS_SPARSIFY:-1}"
|
|
15
15
|
ROOTFS_BUILD_TMPDIR=""
|
|
16
|
+
ROOTFS_SPARSIFY_TMPDIR=""
|
|
16
17
|
HOST_UID="${HOST_UID:-}"
|
|
17
18
|
HOST_GID="${HOST_GID:-}"
|
|
18
19
|
|
|
@@ -34,6 +35,10 @@ cleanup() {
|
|
|
34
35
|
chmod -R u+w "${ROOTFS_BUILD_TMPDIR}" 2>/dev/null || true
|
|
35
36
|
rm -rf "${ROOTFS_BUILD_TMPDIR}"
|
|
36
37
|
fi
|
|
38
|
+
if [ -n "${ROOTFS_SPARSIFY_TMPDIR}" ] && [ -d "${ROOTFS_SPARSIFY_TMPDIR}" ]; then
|
|
39
|
+
chmod -R u+w "${ROOTFS_SPARSIFY_TMPDIR}" 2>/dev/null || true
|
|
40
|
+
rm -rf "${ROOTFS_SPARSIFY_TMPDIR}"
|
|
41
|
+
fi
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
trap cleanup EXIT
|
|
@@ -115,8 +120,10 @@ virt-customize \
|
|
|
115
120
|
if [ "${ROOTFS_SPARSIFY}" = "1" ] && command -v virt-sparsify >/dev/null 2>&1; then
|
|
116
121
|
SPARSE_IMAGE="${IMAGE%.qcow2}.sparse.qcow2"
|
|
117
122
|
rm -f "${SPARSE_IMAGE}"
|
|
123
|
+
ROOTFS_SPARSIFY_TMPDIR="$(mktemp -d "${OUT_DIR}/virt-sparsify-tmp.XXXXXX")"
|
|
118
124
|
echo "Sparsifying and compressing ${IMAGE}..."
|
|
119
|
-
|
|
125
|
+
echo "Using ${ROOTFS_SPARSIFY_TMPDIR} for virt-sparsify scratch space"
|
|
126
|
+
TMPDIR="${ROOTFS_SPARSIFY_TMPDIR}" virt-sparsify --check-tmpdir=continue --compress "${IMAGE}" "${SPARSE_IMAGE}"
|
|
120
127
|
mv "${SPARSE_IMAGE}" "${IMAGE}"
|
|
121
128
|
fi
|
|
122
129
|
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
[Unit]
|
|
2
|
-
Description=Persist AutoTLS secure announce addresses for orbitdb-relay-pinner
|
|
3
|
-
After=orbitdb-relay-pinner.service
|
|
4
|
-
Wants=orbitdb-relay-pinner.service
|
|
5
|
-
ConditionPathExists=/etc/default/orbitdb-relay-pinner.ready
|
|
6
|
-
ConditionPathExists=!/etc/default/orbitdb-relay-pinner.autotls-ready
|
|
7
|
-
|
|
8
|
-
[Service]
|
|
9
|
-
Type=oneshot
|
|
10
|
-
Environment=ENV_FILE=/etc/default/orbitdb-relay-pinner
|
|
11
|
-
Environment=READY_FILE=/etc/default/orbitdb-relay-pinner.ready
|
|
12
|
-
Environment=AUTOTLS_READY_FILE=/etc/default/orbitdb-relay-pinner.autotls-ready
|
|
13
|
-
Environment=AUTOTLS_ZONE_FILE=/etc/default/orbitdb-relay-pinner.autotls-zone
|
|
14
|
-
Environment=AUTOTLS_HOSTS_FILE=/etc/default/orbitdb-relay-pinner.autotls-hosts
|
|
15
|
-
Environment=AUTOTLS_CADDY_READY_FILE=/etc/default/orbitdb-relay-pinner.caddy-ready
|
|
16
|
-
Environment=SERVICE_NAME=orbitdb-relay-pinner.service
|
|
17
|
-
Environment=CADDY_SERVICE=caddy.service
|
|
18
|
-
Environment=CADDYFILE=/etc/caddy/Caddyfile
|
|
19
|
-
ExecStart=/usr/bin/python3 /usr/local/sbin/orbitdb-relay-pinner-autotls-refresh.py
|
|
20
|
-
StandardOutput=journal
|
|
21
|
-
StandardError=journal
|
|
22
|
-
|
|
23
|
-
[Install]
|
|
24
|
-
WantedBy=multi-user.target
|
package/reference/orbitdb-relay-pinner/rootfs/orbitdb-relay-pinner-bootstrap-refresh.service
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
[Unit]
|
|
2
|
-
Description=Refresh Aleph bootstrap registration for orbitdb-relay-pinner
|
|
3
|
-
Wants=network-online.target
|
|
4
|
-
After=network-online.target orbitdb-relay-pinner.service
|
|
5
|
-
ConditionPathExists=/etc/default/orbitdb-relay-pinner.ready
|
|
6
|
-
|
|
7
|
-
[Service]
|
|
8
|
-
Type=oneshot
|
|
9
|
-
Environment=ENV_FILE=/etc/default/orbitdb-relay-pinner
|
|
10
|
-
Environment=DESCRIBE_SCRIPT=/usr/local/sbin/orbitdb-relay-pinner-describe.py
|
|
11
|
-
ExecStart=/usr/bin/python3 /usr/local/sbin/orbitdb-relay-pinner-bootstrap-refresh.py
|
|
12
|
-
StandardOutput=journal
|
|
13
|
-
StandardError=journal
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
[Unit]
|
|
2
|
-
Description=Temporary orbitdb-relay-pinner setup endpoint
|
|
3
|
-
Wants=network-online.target
|
|
4
|
-
After=network-online.target
|
|
5
|
-
ConditionPathExists=!/etc/default/orbitdb-relay-pinner.ready
|
|
6
|
-
|
|
7
|
-
[Service]
|
|
8
|
-
Environment=ENV_FILE=/etc/default/orbitdb-relay-pinner
|
|
9
|
-
Environment=READY_FILE=/etc/default/orbitdb-relay-pinner.ready
|
|
10
|
-
Environment=SERVICE_NAME=orbitdb-relay-pinner.service
|
|
11
|
-
Environment=BOOTSTRAP_SERVICE=orbitdb-relay-pinner-bootstrap.service
|
|
12
|
-
Environment=METADATA_FILE=/run/orbitdb-relay-pinner-setup-metadata.json
|
|
13
|
-
Environment=METADATA_ERROR_FILE=/run/orbitdb-relay-pinner-setup-metadata.error
|
|
14
|
-
ExecStart=/usr/bin/python3 /usr/local/sbin/orbitdb-relay-pinner-setup-server.py
|
|
15
|
-
StandardOutput=journal
|
|
16
|
-
StandardError=journal
|
|
17
|
-
Restart=on-failure
|
|
18
|
-
RestartSec=2s
|
|
19
|
-
|
|
20
|
-
[Install]
|
|
21
|
-
WantedBy=multi-user.target
|
|
File without changes
|
|
File without changes
|