Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4dbdfe8133 | ||
|
|
51e6951b58 |
No files matched your search
@@ -45,12 +45,6 @@ DB_URL='FULL_PATH_TO_YOUR_SQLITE_DB_FILE'
|
|||||||
|
|
||||||
TURBO_TELEMETRY_DISABLED=1
|
TURBO_TELEMETRY_DISABLED=1
|
||||||
|
|
||||||
# Comma-separated paths to Docker-compatible Unix sockets.
|
|
||||||
# Useful for connecting to multiple runtimes (Docker + Podman) simultaneously.
|
|
||||||
# When unset and no TCP hosts configured, defaults to /var/run/docker.sock.
|
|
||||||
# Example: DOCKER_SOCKET_PATHS=/var/run/docker.sock,/run/user/1000/podman/podman.sock
|
|
||||||
# DOCKER_SOCKET_PATHS=
|
|
||||||
|
|
||||||
# Enable kubernetes tool
|
# Enable kubernetes tool
|
||||||
# ENABLE_KUBERNETES=true
|
# ENABLE_KUBERNETES=true
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +1,3 @@
|
|||||||
## [1.61.1](https://github.com/homarr-labs/homarr/compare/v1.61.0...v1.61.1) (2026-05-18)
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **downloads-widget:** increase name column default width ratio ([e9142c0](https://github.com/homarr-labs/homarr/commit/e9142c0dbcaca6cd9215b5292a2d139d96919b51))
|
|
||||||
|
|
||||||
## [1.61.0](https://github.com/homarr-labs/homarr/compare/v1.60.0...v1.61.0) (2026-05-08)
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* add auto/system appearance mode + fix dark mode system resources charts ([#5492](https://github.com/homarr-labs/homarr/issues/5492)) ([831b622](https://github.com/homarr-labs/homarr/commit/831b6221fdf21fe4913b0f165ef551afeada4f33))
|
|
||||||
* add pwa support ([#5530](https://github.com/homarr-labs/homarr/issues/5530)) ([277a509](https://github.com/homarr-labs/homarr/commit/277a509f490d57bb6547c86c417c29c0e7af7e40))
|
|
||||||
* add Umami Analytics integration and widget ([#5362](https://github.com/homarr-labs/homarr/issues/5362)) ([43cc68b](https://github.com/homarr-labs/homarr/commit/43cc68bdd49c4877012e39e23355f6506aea7f4e))
|
|
||||||
* **docker:** Podman compatibility, multi-socket support, per-host error isolation ([#5425](https://github.com/homarr-labs/homarr/issues/5425)) ([56af6bc](https://github.com/homarr-labs/homarr/commit/56af6bcaf00e980e4c7a40d8e912901cd1395f5a))
|
|
||||||
* **entity-state:** add data attributes for custom-css styling ([#5655](https://github.com/homarr-labs/homarr/issues/5655)) ([0937555](https://github.com/homarr-labs/homarr/commit/0937555d49c29455bc33307ae5e50bf5b812c7c7))
|
|
||||||
* **installations:** support secrets file for all environment variables ([#5125](https://github.com/homarr-labs/homarr/issues/5125)) ([4d30a2e](https://github.com/homarr-labs/homarr/commit/4d30a2e8c48f818bb4947a651b0fec5f64cbf569))
|
|
||||||
* **qbittorrent:** add api-key support ([#5677](https://github.com/homarr-labs/homarr/issues/5677)) ([756e8d1](https://github.com/homarr-labs/homarr/commit/756e8d172455f91e40cd8fb5faff6953cc9778c5))
|
|
||||||
* **spotlight:** rework !bang search UX ([#4813](https://github.com/homarr-labs/homarr/issues/4813)) ([b5c316b](https://github.com/homarr-labs/homarr/commit/b5c316b825bdffa267fd173a3c39a12269142665))
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **apps:** creation on the fly broken ([#5605](https://github.com/homarr-labs/homarr/issues/5605)) ([3183914](https://github.com/homarr-labs/homarr/commit/3183914a1502555681b73975062ed6ca8a48cb75))
|
|
||||||
* **calendar:** keep working integrations when one fails ([#5629](https://github.com/homarr-labs/homarr/issues/5629)) ([44bd16d](https://github.com/homarr-labs/homarr/commit/44bd16d6770d289054df6c7c93adff42d2243252))
|
|
||||||
* **lang:** portuguese is linked to brazilian portuguese on crowdin ([#5622](https://github.com/homarr-labs/homarr/issues/5622)) ([62be81e](https://github.com/homarr-labs/homarr/commit/62be81ea607a609a816157686700c54540e1568b))
|
|
||||||
* **qbittorrent:** support version 5.2 ([#5672](https://github.com/homarr-labs/homarr/issues/5672)) ([00a0552](https://github.com/homarr-labs/homarr/commit/00a055283e8848542b67d88a656a99fdd0bcb444))
|
|
||||||
* **update-checker:** hide prereleases on non-prerelease versions ([#5645](https://github.com/homarr-labs/homarr/issues/5645)) ([b07a4a0](https://github.com/homarr-labs/homarr/commit/b07a4a0f3e3af384ec477bf5c505a705b003de47))
|
|
||||||
|
|
||||||
### Reverts
|
|
||||||
|
|
||||||
* **deps:** downgrade pnpm to v10 ([#5673](https://github.com/homarr-labs/homarr/issues/5673)) ([44a2973](https://github.com/homarr-labs/homarr/commit/44a2973b1aba1e2c6bd818be022205f3cdb7c943))
|
|
||||||
|
|
||||||
## [1.60.0](https://github.com/homarr-labs/homarr/compare/v1.59.3...v1.60.0) (2026-05-01)
|
## [1.60.0](https://github.com/homarr-labs/homarr/compare/v1.59.3...v1.60.0) (2026-05-01)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -3,11 +3,7 @@
|
|||||||
|
|
||||||
# Exempt Renovate‑managed files (no owners)
|
# Exempt Renovate‑managed files (no owners)
|
||||||
package.json
|
package.json
|
||||||
**/package.json
|
|
||||||
package-lock.json
|
package-lock.json
|
||||||
**/package-lock.json
|
|
||||||
pnpm-lock.yaml
|
pnpm-lock.yaml
|
||||||
**/pnpm-lock.yaml
|
|
||||||
pnpm-workspace.yaml
|
|
||||||
Dockerfile
|
Dockerfile
|
||||||
docker-compose.yml
|
docker-compose.yml
|
||||||
+1
-1
@@ -30,7 +30,7 @@ VOLUME /appdata
|
|||||||
|
|
||||||
# Enable homarr cli
|
# Enable homarr cli
|
||||||
COPY --from=builder /app/packages/cli/cli.cjs /app/apps/cli/cli.cjs
|
COPY --from=builder /app/packages/cli/cli.cjs /app/apps/cli/cli.cjs
|
||||||
RUN echo $'#!/bin/bash\nexport DISABLE_REDIS_LOGS=true\ncd /app/apps/cli && exec node ./cli.cjs "$@"' > /usr/bin/homarr
|
RUN echo $'#!/bin/bash\ncd /app/apps/cli && node ./cli.cjs "$@"' > /usr/bin/homarr
|
||||||
RUN chmod +x /usr/bin/homarr
|
RUN chmod +x /usr/bin/homarr
|
||||||
|
|
||||||
# Don't run production as root
|
# Don't run production as root
|
||||||
|
|||||||
@@ -58,18 +58,6 @@ const createColumns = (
|
|||||||
return <ContainerStateBadge state={cell.row.original.state} />;
|
return <ContainerStateBadge state={cell.row.original.state} />;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
accessorKey: "host",
|
|
||||||
header: t("docker.field.host.label"),
|
|
||||||
size: 140,
|
|
||||||
Cell({ row }) {
|
|
||||||
return (
|
|
||||||
<Text truncate="end" title={row.original.host}>
|
|
||||||
{row.original.host}
|
|
||||||
</Text>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
accessorKey: "image",
|
accessorKey: "image",
|
||||||
header: t("docker.field.containerImage.label"),
|
header: t("docker.field.containerImage.label"),
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "homarr",
|
"name": "homarr",
|
||||||
"version": "1.61.1",
|
"version": "1.60.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cross-env CI=true turbo build",
|
"build": "cross-env CI=true turbo build",
|
||||||
|
|||||||
@@ -138,7 +138,6 @@ const getContainerOrThrowAsync = async (id: string) => {
|
|||||||
interface DockerContainer {
|
interface DockerContainer {
|
||||||
name: string;
|
name: string;
|
||||||
id: string;
|
id: string;
|
||||||
host: string;
|
|
||||||
state: ContainerState;
|
state: ContainerState;
|
||||||
image: string;
|
image: string;
|
||||||
ports: Port[] | undefined;
|
ports: Port[] | undefined;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "esbuild src/index.ts --bundle --platform=node --outfile=cli.cjs --external:bcrypt --external:cpu-features --external:better-sqlite3 --external:mysql2 --external:pg --loader:.html=text --loader:.node=text",
|
"build": "esbuild src/index.ts --bundle --platform=node --outfile=cli.cjs --external:bcrypt --external:cpu-features --loader:.html=text --loader:.node=text",
|
||||||
"clean": "rm -rf .turbo node_modules",
|
"clean": "rm -rf .turbo node_modules",
|
||||||
"format": "prettier --check . --ignore-path ../../.gitignore",
|
"format": "prettier --check . --ignore-path ../../.gitignore",
|
||||||
"lint": "eslint",
|
"lint": "eslint",
|
||||||
@@ -25,16 +25,12 @@
|
|||||||
},
|
},
|
||||||
"prettier": "@homarr/prettier-config",
|
"prettier": "@homarr/prettier-config",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@drizzle-team/brocli": "catalog:",
|
||||||
"@homarr/auth": "workspace:^0.1.0",
|
"@homarr/auth": "workspace:^0.1.0",
|
||||||
"@homarr/common": "workspace:^0.1.0",
|
"@homarr/common": "workspace:^0.1.0",
|
||||||
"@homarr/core": "workspace:^0.1.0",
|
|
||||||
"@homarr/db": "workspace:^0.1.0",
|
"@homarr/db": "workspace:^0.1.0",
|
||||||
"@homarr/validation": "workspace:^0.1.0",
|
"@homarr/validation": "workspace:^0.1.0",
|
||||||
"better-sqlite3": "catalog:",
|
"dotenv": "catalog:"
|
||||||
"dotenv": "catalog:",
|
|
||||||
"drizzle-orm": "catalog:",
|
|
||||||
"mysql2": "catalog:",
|
|
||||||
"pg": "catalog:"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@homarr/eslint-config": "workspace:^0.2.0",
|
"@homarr/eslint-config": "workspace:^0.2.0",
|
||||||
|
|||||||
@@ -1,127 +0,0 @@
|
|||||||
import Database from "better-sqlite3";
|
|
||||||
import { drizzle as drizzleSqlite } from "drizzle-orm/better-sqlite3";
|
|
||||||
import { drizzle as drizzleMysql } from "drizzle-orm/mysql2";
|
|
||||||
import { drizzle as drizzlePostgres } from "drizzle-orm/node-postgres";
|
|
||||||
import mysql from "mysql2";
|
|
||||||
import type { Pool as MysqlPool } from "mysql2";
|
|
||||||
import { Pool as PostgresPool } from "pg";
|
|
||||||
|
|
||||||
import { DB_CASING } from "@homarr/core/infrastructure/db/constants";
|
|
||||||
import { dbEnv } from "@homarr/core/infrastructure/db/env";
|
|
||||||
import { schema } from "@homarr/db/schema";
|
|
||||||
|
|
||||||
const CONNECT_TIMEOUT_MS = 10_000;
|
|
||||||
|
|
||||||
const dbConfig = {
|
|
||||||
schema,
|
|
||||||
casing: DB_CASING,
|
|
||||||
};
|
|
||||||
|
|
||||||
export type CliDatabase = ReturnType<typeof drizzleSqlite<typeof schema>>;
|
|
||||||
|
|
||||||
type CliConnection =
|
|
||||||
| { driver: "better-sqlite3"; raw: Database.Database; db: CliDatabase }
|
|
||||||
| { driver: "mysql2"; raw: MysqlPool; db: CliDatabase }
|
|
||||||
| { driver: "node-postgres"; raw: PostgresPool; db: CliDatabase };
|
|
||||||
|
|
||||||
let connection: CliConnection | null = null;
|
|
||||||
|
|
||||||
const createMysqlPool = () => {
|
|
||||||
const poolOptions = {
|
|
||||||
maxIdle: 0,
|
|
||||||
idleTimeout: 60000,
|
|
||||||
enableKeepAlive: true,
|
|
||||||
connectTimeout: CONNECT_TIMEOUT_MS,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!dbEnv.HOST) {
|
|
||||||
return mysql.createPool({ ...poolOptions, uri: dbEnv.URL });
|
|
||||||
}
|
|
||||||
|
|
||||||
return mysql.createPool({
|
|
||||||
...poolOptions,
|
|
||||||
host: dbEnv.HOST,
|
|
||||||
port: dbEnv.PORT,
|
|
||||||
database: dbEnv.NAME,
|
|
||||||
user: dbEnv.USER,
|
|
||||||
password: dbEnv.PASSWORD,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const createPostgresPool = () => {
|
|
||||||
const poolOptions = {
|
|
||||||
max: 1,
|
|
||||||
idleTimeoutMillis: 60000,
|
|
||||||
connectionTimeoutMillis: CONNECT_TIMEOUT_MS,
|
|
||||||
allowExitOnIdle: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!dbEnv.HOST) {
|
|
||||||
return new PostgresPool({
|
|
||||||
...poolOptions,
|
|
||||||
connectionString: dbEnv.URL,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return new PostgresPool({
|
|
||||||
...poolOptions,
|
|
||||||
host: dbEnv.HOST,
|
|
||||||
port: dbEnv.PORT,
|
|
||||||
database: dbEnv.NAME,
|
|
||||||
user: dbEnv.USER,
|
|
||||||
password: dbEnv.PASSWORD,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const connectionFactories = {
|
|
||||||
"better-sqlite3": (): CliConnection => {
|
|
||||||
const raw = new Database(dbEnv.URL);
|
|
||||||
const db = drizzleSqlite(raw, dbConfig);
|
|
||||||
return { driver: "better-sqlite3", raw, db };
|
|
||||||
},
|
|
||||||
mysql2: (): CliConnection => {
|
|
||||||
const raw = createMysqlPool();
|
|
||||||
const db = drizzleMysql(raw, { ...dbConfig, mode: "default" }) as unknown as CliDatabase;
|
|
||||||
return { driver: "mysql2", raw, db };
|
|
||||||
},
|
|
||||||
"node-postgres": (): CliConnection => {
|
|
||||||
const raw = createPostgresPool();
|
|
||||||
const db = drizzlePostgres({ ...dbConfig, client: raw }) as unknown as CliDatabase;
|
|
||||||
return { driver: "node-postgres", raw, db };
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const closeHandlers: Record<CliConnection["driver"], (entry: CliConnection) => Promise<void>> = {
|
|
||||||
"better-sqlite3": async (entry) => {
|
|
||||||
(entry as Extract<CliConnection, { driver: "better-sqlite3" }>).raw.close();
|
|
||||||
},
|
|
||||||
mysql2: (entry) => {
|
|
||||||
const pool = (entry as Extract<CliConnection, { driver: "mysql2" }>).raw;
|
|
||||||
return new Promise<void>((resolve, reject) => {
|
|
||||||
pool.end((err) => (err ? reject(err) : resolve()));
|
|
||||||
});
|
|
||||||
},
|
|
||||||
"node-postgres": async (entry) => {
|
|
||||||
await (entry as Extract<CliConnection, { driver: "node-postgres" }>).raw.end();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getCliDb = (): CliDatabase => {
|
|
||||||
if (connection) {
|
|
||||||
return connection.db;
|
|
||||||
}
|
|
||||||
|
|
||||||
const driver = dbEnv.DRIVER ?? "better-sqlite3";
|
|
||||||
connection = connectionFactories[driver]();
|
|
||||||
return connection.db;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const closeCliDbAsync = async (): Promise<void> => {
|
|
||||||
if (!connection) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const current = connection;
|
|
||||||
connection = null;
|
|
||||||
await closeHandlers[current.driver](current);
|
|
||||||
};
|
|
||||||
@@ -1,35 +1,36 @@
|
|||||||
import { eq } from "drizzle-orm";
|
import { command } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
import { getCliDb } from "../cli-db";
|
import { db, eq } from "@homarr/db";
|
||||||
import { requireCredentialsProvider } from "../errors";
|
|
||||||
import { users } from "@homarr/db/schema";
|
import { users } from "@homarr/db/schema";
|
||||||
|
|
||||||
export async function fixUsernamesHandler(): Promise<number> {
|
export const fixUsernames = command({
|
||||||
requireCredentialsProvider();
|
name: "fix-usernames",
|
||||||
|
desc: "Changes all credentials usernames to lowercase",
|
||||||
const db = getCliDb();
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
const credentialUsers = await db.query.users.findMany({
|
handler: async () => {
|
||||||
where: eq(users.provider, "credentials"),
|
if (!process.env.AUTH_PROVIDERS?.toLowerCase().includes("credentials")) {
|
||||||
});
|
console.error("Credentials provider is not enabled");
|
||||||
|
return;
|
||||||
for (const user of credentialUsers) {
|
|
||||||
if (!user.name) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (user.name === user.name.toLowerCase()) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await db
|
const credentialUsers = await db.query.users.findMany({
|
||||||
.update(users)
|
where: eq(users.provider, "credentials"),
|
||||||
.set({
|
});
|
||||||
name: user.name.toLowerCase(),
|
|
||||||
})
|
|
||||||
.where(eq(users.id, user.id));
|
|
||||||
|
|
||||||
console.log(`Changed username from ${user.name} to ${user.name.toLowerCase()}`);
|
for (const user of credentialUsers) {
|
||||||
}
|
if (!user.name) continue;
|
||||||
|
if (user.name === user.name.toLowerCase()) continue;
|
||||||
|
|
||||||
console.log("All usernames have been fixed");
|
await db
|
||||||
return 0;
|
.update(users)
|
||||||
}
|
.set({
|
||||||
|
name: user.name.toLowerCase(),
|
||||||
|
})
|
||||||
|
.where(eq(users.id, user.id));
|
||||||
|
|
||||||
|
console.log(`Changed username from ${user.name} to ${user.name.toLowerCase()}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("All usernames have been fixed");
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -1,50 +1,39 @@
|
|||||||
import { parseArgs } from "node:util";
|
import { command, string } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
import { eq } from "drizzle-orm";
|
import { db, eq } from "@homarr/db";
|
||||||
|
|
||||||
import type { CliDatabase } from "../cli-db";
|
|
||||||
import { getCliDb } from "../cli-db";
|
|
||||||
import { CliError } from "../errors";
|
|
||||||
import { integrations } from "@homarr/db/schema";
|
import { integrations } from "@homarr/db/schema";
|
||||||
|
|
||||||
const integrationLookup: Record<
|
export const integrationsDelete = command({
|
||||||
"id" | "name",
|
name: "delete",
|
||||||
(db: CliDatabase, value: string) => Promise<{ id: string; name: string } | undefined>
|
desc: "Delete an integration by id or name",
|
||||||
> = {
|
options: {
|
||||||
id: (db, value) =>
|
id: string("id").alias("i").desc("ID of the integration"),
|
||||||
db.query.integrations.findFirst({
|
name: string("name").alias("n").desc("Name of the integration"),
|
||||||
where: eq(integrations.id, value),
|
},
|
||||||
}),
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
name: (db, value) =>
|
handler: async (options) => {
|
||||||
db.query.integrations.findFirst({
|
if (!options.id && !options.name) {
|
||||||
where: eq(integrations.name, value),
|
console.error("Either --id or --name must be provided");
|
||||||
}),
|
return;
|
||||||
};
|
}
|
||||||
|
|
||||||
export async function integrationsDeleteHandler(args: string[]): Promise<number> {
|
let entry;
|
||||||
const { values } = parseArgs({
|
if (options.id) {
|
||||||
args,
|
entry = await db.query.integrations.findFirst({
|
||||||
options: {
|
where: eq(integrations.id, options.id),
|
||||||
id: { type: "string", short: "i" },
|
});
|
||||||
name: { type: "string", short: "n" },
|
} else if (options.name) {
|
||||||
},
|
entry = await db.query.integrations.findFirst({
|
||||||
});
|
where: eq(integrations.name, options.name),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const lookupKey = values.id ? "id" : values.name ? "name" : null;
|
if (!entry) {
|
||||||
const lookupValue = values.id ?? values.name;
|
console.error("Integration not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!lookupKey || !lookupValue) {
|
await db.delete(integrations).where(eq(integrations.id, entry.id));
|
||||||
throw new CliError("Either --id or --name must be provided", 2);
|
console.log(`Integration ${entry.name} (${entry.id}) deleted`);
|
||||||
}
|
},
|
||||||
|
});
|
||||||
const db = getCliDb();
|
|
||||||
const entry = await integrationLookup[lookupKey](db, lookupValue);
|
|
||||||
|
|
||||||
if (!entry) {
|
|
||||||
throw new CliError("Integration not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
await db.delete(integrations).where(eq(integrations.id, entry.id));
|
|
||||||
console.log(`Integration ${entry.name} (${entry.id}) deleted`);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,35 +1,21 @@
|
|||||||
import { parseArgs } from "node:util";
|
import { command } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
import { getCliDb } from "../cli-db";
|
import { db } from "@homarr/db";
|
||||||
import { printTable } from "../utils";
|
|
||||||
|
|
||||||
export async function integrationsListHandler(args: string[] = []): Promise<number> {
|
export const integrationsList = command({
|
||||||
const { values } = parseArgs({
|
name: "list",
|
||||||
args,
|
desc: "List all integrations (id and name)",
|
||||||
options: {
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
json: { type: "boolean", default: false },
|
handler: async () => {
|
||||||
},
|
const all = await db.query.integrations.findMany();
|
||||||
strict: false,
|
if (all.length === 0) {
|
||||||
});
|
console.log("No integrations found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const db = getCliDb();
|
console.log("ID\t\t\t\tName");
|
||||||
const all = await db.query.integrations.findMany();
|
for (const i of all) {
|
||||||
|
console.log(`${i.id}\t${i.name}`);
|
||||||
if (values.json) {
|
}
|
||||||
const output = all.map((i) => ({ id: i.id, name: i.name, kind: i.kind, url: i.url }));
|
},
|
||||||
console.log(JSON.stringify(output, null, 2));
|
});
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (all.length === 0) {
|
|
||||||
console.log("No integrations found");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
printTable(
|
|
||||||
["ID", "Name", "Kind", "URL"],
|
|
||||||
all.map((i) => [i.id, i.name, i.kind, i.url]),
|
|
||||||
);
|
|
||||||
console.log(`\n${all.length} integration(s) total`);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { command } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
|
import { integrationsDelete } from "./integrations-delete";
|
||||||
|
import { integrationsList } from "./integrations-list";
|
||||||
|
|
||||||
|
export const integrationsRoot = command({
|
||||||
|
name: "integrations",
|
||||||
|
desc: "Group of commands to manage integrations",
|
||||||
|
subcommands: [integrationsList, integrationsDelete],
|
||||||
|
});
|
||||||
@@ -1,98 +1,94 @@
|
|||||||
import { parseArgs } from "node:util";
|
import { command, string } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
import { hashPasswordAsync } from "@homarr/auth/security";
|
import { hashPasswordAsync } from "@homarr/auth";
|
||||||
import { createId } from "@homarr/common";
|
import { createId } from "@homarr/common";
|
||||||
import { generateSecureRandomToken } from "../utils";
|
import { generateSecureRandomToken } from "@homarr/common/server";
|
||||||
import { and, count, eq, max } from "drizzle-orm";
|
import { and, count, db, eq } from "@homarr/db";
|
||||||
|
import { getMaxGroupPositionAsync } from "@homarr/db/queries";
|
||||||
import { getCliDb } from "../cli-db";
|
|
||||||
import { CliError, requireCredentialsProvider } from "../errors";
|
|
||||||
import { groupMembers, groupPermissions, groups, users } from "@homarr/db/schema";
|
import { groupMembers, groupPermissions, groups, users } from "@homarr/db/schema";
|
||||||
import { usernameSchema } from "@homarr/validation/user";
|
import { usernameSchema } from "@homarr/validation/user";
|
||||||
|
|
||||||
export async function recreateAdminHandler(args: string[]): Promise<number> {
|
export const recreateAdmin = command({
|
||||||
requireCredentialsProvider();
|
name: "recreate-admin",
|
||||||
|
desc: "Recreate credentials admin user if none exists anymore",
|
||||||
|
options: {
|
||||||
|
username: string("username").required().alias("u").desc("Name of the admin"),
|
||||||
|
},
|
||||||
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
|
handler: async (options) => {
|
||||||
|
if (!process.env.AUTH_PROVIDERS?.toLowerCase().includes("credentials")) {
|
||||||
|
console.error("Credentials provider is not enabled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const { values } = parseArgs({
|
const result = await usernameSchema.safeParseAsync(options.username);
|
||||||
args,
|
|
||||||
options: {
|
|
||||||
username: { type: "string", short: "u" },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!values.username) {
|
if (!result.success) {
|
||||||
throw new CliError("Missing required option: --username / -u", 2);
|
console.error("Invalid username:");
|
||||||
}
|
console.error(result.error.issues.map((error) => `- ${error.message}`).join("\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const result = await usernameSchema.safeParseAsync(values.username);
|
const totalCount = await db
|
||||||
if (!result.success) {
|
.select({
|
||||||
const messages = result.error.issues.map((issue) => `- ${issue.message}`).join("\n");
|
count: count(),
|
||||||
throw new CliError(`Invalid username:\n${messages}`, 2);
|
})
|
||||||
}
|
.from(groupPermissions)
|
||||||
|
.leftJoin(groupMembers, eq(groupMembers.groupId, groupPermissions.groupId))
|
||||||
|
.leftJoin(users, eq(users.id, groupMembers.userId))
|
||||||
|
.where(and(eq(groupPermissions.permission, "admin"), eq(users.provider, "credentials")))
|
||||||
|
.then((rows) => rows.at(0)?.count ?? 0);
|
||||||
|
|
||||||
const db = getCliDb();
|
if (totalCount > 0) {
|
||||||
|
console.error("Credentials admin user exists");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const totalCount = await db
|
const existingUser = await db.query.users.findFirst({
|
||||||
.select({
|
where: eq(users.name, result.data),
|
||||||
count: count(),
|
});
|
||||||
})
|
|
||||||
.from(groupPermissions)
|
|
||||||
.leftJoin(groupMembers, eq(groupMembers.groupId, groupPermissions.groupId))
|
|
||||||
.leftJoin(users, eq(users.id, groupMembers.userId))
|
|
||||||
.where(and(eq(groupPermissions.permission, "admin"), eq(users.provider, "credentials")))
|
|
||||||
.then((rows: { count: number }[]) => rows.at(0)?.count ?? 0);
|
|
||||||
|
|
||||||
if (totalCount > 0) {
|
if (existingUser) {
|
||||||
throw new CliError("Credentials admin user exists");
|
console.error("User with this name already exists");
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const existingUser = await db.query.users.findFirst({
|
const temporaryGroupId = createId();
|
||||||
where: eq(users.name, result.data),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (existingUser) {
|
const maxPosition = await getMaxGroupPositionAsync(db);
|
||||||
throw new CliError("User with this name already exists");
|
await db.insert(groups).values({
|
||||||
}
|
id: temporaryGroupId,
|
||||||
|
name: temporaryGroupId,
|
||||||
|
position: maxPosition + 1,
|
||||||
|
});
|
||||||
|
|
||||||
const temporaryGroupId = createId();
|
await db.insert(groupPermissions).values({
|
||||||
const maxPosition = await db
|
groupId: temporaryGroupId,
|
||||||
.select({ value: max(groups.position) })
|
permission: "admin",
|
||||||
.from(groups)
|
});
|
||||||
.then((result: { value: number | null }[]) => result[0]?.value ?? 1);
|
|
||||||
|
|
||||||
await db.insert(groups).values({
|
const password = generateSecureRandomToken(24);
|
||||||
id: temporaryGroupId,
|
const hashedPassword = await hashPasswordAsync(password);
|
||||||
name: temporaryGroupId,
|
|
||||||
position: maxPosition + 1,
|
|
||||||
});
|
|
||||||
|
|
||||||
await db.insert(groupPermissions).values({
|
const userId = createId();
|
||||||
groupId: temporaryGroupId,
|
await db.insert(users).values({
|
||||||
permission: "admin",
|
id: userId,
|
||||||
});
|
name: result.data,
|
||||||
|
provider: "credentials",
|
||||||
|
password: hashedPassword,
|
||||||
|
});
|
||||||
|
|
||||||
const password = generateSecureRandomToken(24);
|
await db.insert(groupMembers).values({
|
||||||
const hashedPassword = await hashPasswordAsync(password);
|
groupId: temporaryGroupId,
|
||||||
const userId = createId();
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
await db.insert(users).values({
|
console.log(
|
||||||
id: userId,
|
"We created a new admin user for you. Please keep in mind, that the admin group of it has a temporary name. You should change it to something more meaningful.",
|
||||||
name: result.data,
|
);
|
||||||
provider: "credentials",
|
console.log(`\tUsername: ${result.data}`);
|
||||||
password: hashedPassword,
|
console.log(`\tPassword: ${password}`);
|
||||||
});
|
console.log(`\tGroup: ${temporaryGroupId}`);
|
||||||
|
console.log(""); // Empty line for better readability
|
||||||
await db.insert(groupMembers).values({
|
},
|
||||||
groupId: temporaryGroupId,
|
});
|
||||||
userId,
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(
|
|
||||||
"We created a new admin user for you. Please keep in mind, that the admin group of it has a temporary name. You should change it to something more meaningful.",
|
|
||||||
);
|
|
||||||
console.log(`\tUsername: ${result.data}`);
|
|
||||||
console.log(`\tPassword: ${password}`);
|
|
||||||
console.log(`\tGroup: ${temporaryGroupId}`);
|
|
||||||
console.log("");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,48 +1,46 @@
|
|||||||
import { parseArgs } from "node:util";
|
import { command, string } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
import { hashPasswordAsync } from "@homarr/auth/security";
|
import { hashPasswordAsync } from "@homarr/auth";
|
||||||
import { generateSecureRandomToken } from "../utils";
|
import { generateSecureRandomToken } from "@homarr/common/server";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, db, eq } from "@homarr/db";
|
||||||
|
|
||||||
import { getCliDb } from "../cli-db";
|
|
||||||
import { CliError, requireCredentialsProvider } from "../errors";
|
|
||||||
import { sessions, users } from "@homarr/db/schema";
|
import { sessions, users } from "@homarr/db/schema";
|
||||||
|
|
||||||
export async function resetPasswordHandler(args: string[]): Promise<number> {
|
export const resetPassword = command({
|
||||||
requireCredentialsProvider();
|
name: "reset-password",
|
||||||
|
desc: "Reset password for a user",
|
||||||
|
options: {
|
||||||
|
username: string("username").required().alias("u").desc("Name of the user"),
|
||||||
|
},
|
||||||
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
|
handler: async (options) => {
|
||||||
|
if (!process.env.AUTH_PROVIDERS?.toLowerCase().includes("credentials")) {
|
||||||
|
console.error("Credentials provider is not enabled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const { values } = parseArgs({
|
const user = await db.query.users.findFirst({
|
||||||
args,
|
where: and(eq(users.name, options.username), eq(users.provider, "credentials")),
|
||||||
options: {
|
});
|
||||||
username: { type: "string", short: "u" },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!values.username) {
|
if (!user?.password) {
|
||||||
throw new CliError("Missing required option: --username / -u", 2);
|
console.error(`User ${options.username} not found`);
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const db = getCliDb();
|
// Generates a new password with 48 characters
|
||||||
const user = await db.query.users.findFirst({
|
const newPassword = generateSecureRandomToken(24);
|
||||||
where: and(eq(users.name, values.username), eq(users.provider, "credentials")),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!user?.password) {
|
await db
|
||||||
throw new CliError(`User ${values.username} not found`);
|
.update(users)
|
||||||
}
|
.set({
|
||||||
|
password: await hashPasswordAsync(newPassword),
|
||||||
|
})
|
||||||
|
.where(eq(users.id, user.id));
|
||||||
|
|
||||||
const newPassword = generateSecureRandomToken(24);
|
await db.delete(sessions).where(eq(sessions.userId, user.id));
|
||||||
|
console.log(`All sessions for user ${options.username} have been deleted`);
|
||||||
|
|
||||||
await db
|
console.log("You can now login with the new password");
|
||||||
.update(users)
|
console.log(`New password for user ${options.username}: ${newPassword}`);
|
||||||
.set({
|
},
|
||||||
password: await hashPasswordAsync(newPassword),
|
});
|
||||||
})
|
|
||||||
.where(eq(users.id, user.id));
|
|
||||||
|
|
||||||
await db.delete(sessions).where(eq(sessions.userId, user.id));
|
|
||||||
console.log(`All sessions for user ${values.username} have been deleted`);
|
|
||||||
console.log("You can now login with the new password");
|
|
||||||
console.log(`New password for user ${values.username}: ${newPassword}`);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,47 +1,39 @@
|
|||||||
import { parseArgs } from "node:util";
|
import { command, string } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
import { eq } from "drizzle-orm";
|
import { db, eq } from "@homarr/db";
|
||||||
|
|
||||||
import type { CliDatabase } from "../cli-db";
|
|
||||||
import { getCliDb } from "../cli-db";
|
|
||||||
import { CliError } from "../errors";
|
|
||||||
import { users } from "@homarr/db/schema";
|
import { users } from "@homarr/db/schema";
|
||||||
|
|
||||||
const userLookup: Record<"id" | "username", (db: CliDatabase, value: string) => Promise<{ id: string; name: string | null } | undefined>> = {
|
export const usersDelete = command({
|
||||||
id: (db, value) =>
|
name: "delete",
|
||||||
db.query.users.findFirst({
|
desc: "Delete a user by id or username",
|
||||||
where: eq(users.id, value),
|
options: {
|
||||||
}),
|
id: string("id").alias("i").desc("ID of the user"),
|
||||||
username: (db, value) =>
|
username: string("username").alias("u").desc("Name of the user"),
|
||||||
db.query.users.findFirst({
|
},
|
||||||
where: eq(users.name, value),
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
}),
|
handler: async (options) => {
|
||||||
};
|
if (!options.id && !options.username) {
|
||||||
|
console.error("Either --id or --username must be provided");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
export async function usersDeleteHandler(args: string[]): Promise<number> {
|
let user;
|
||||||
const { values } = parseArgs({
|
if (options.id) {
|
||||||
args,
|
user = await db.query.users.findFirst({
|
||||||
options: {
|
where: eq(users.id, options.id),
|
||||||
id: { type: "string", short: "i" },
|
});
|
||||||
username: { type: "string", short: "u" },
|
} else if (options.username) {
|
||||||
},
|
user = await db.query.users.findFirst({
|
||||||
});
|
where: eq(users.name, options.username),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const lookupKey = values.id ? "id" : values.username ? "username" : null;
|
if (!user) {
|
||||||
const lookupValue = values.id ?? values.username;
|
console.error("User not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!lookupKey || !lookupValue) {
|
await db.delete(users).where(eq(users.id, user.id));
|
||||||
throw new CliError("Either --id or --username must be provided", 2);
|
console.log(`User ${user.name ?? user.id} (${user.id}) deleted`);
|
||||||
}
|
},
|
||||||
|
});
|
||||||
const db = getCliDb();
|
|
||||||
const user = await userLookup[lookupKey](db, lookupValue);
|
|
||||||
|
|
||||||
if (!user) {
|
|
||||||
throw new CliError("User not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
await db.delete(users).where(eq(users.id, user.id));
|
|
||||||
console.log(`User ${user.name ?? user.id} (${user.id}) deleted`);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,35 +1,22 @@
|
|||||||
import { parseArgs } from "node:util";
|
import { command } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
import { getCliDb } from "../cli-db";
|
import { db } from "@homarr/db";
|
||||||
import { printTable } from "../utils";
|
|
||||||
|
|
||||||
export async function usersListHandler(args: string[] = []): Promise<number> {
|
export const usersList = command({
|
||||||
const { values } = parseArgs({
|
name: "list",
|
||||||
args,
|
desc: "List all users (id, username, email)",
|
||||||
options: {
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
json: { type: "boolean", default: false },
|
handler: async () => {
|
||||||
},
|
const allUsers = await db.query.users.findMany();
|
||||||
strict: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const db = getCliDb();
|
if (allUsers.length === 0) {
|
||||||
const allUsers = await db.query.users.findMany();
|
console.log("No users found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (values.json) {
|
console.log("ID\t\t\t\tUsername\tEmail");
|
||||||
const output = allUsers.map((u) => ({ id: u.id, name: u.name, email: u.email, provider: u.provider }));
|
for (const user of allUsers) {
|
||||||
console.log(JSON.stringify(output, null, 2));
|
console.log(`${user.id}\t${user.name ?? ""}\t${user.email ?? ""}`);
|
||||||
return 0;
|
}
|
||||||
}
|
},
|
||||||
|
});
|
||||||
if (allUsers.length === 0) {
|
|
||||||
console.log("No users found");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
printTable(
|
|
||||||
["ID", "Username", "Email", "Provider"],
|
|
||||||
allUsers.map((u) => [u.id, u.name ?? "", u.email ?? "", u.provider]),
|
|
||||||
);
|
|
||||||
console.log(`\n${allUsers.length} user(s) total`);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,66 +1,50 @@
|
|||||||
import { parseArgs } from "node:util";
|
import { command, string } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
import { hashPasswordAsync } from "@homarr/auth/security";
|
import { hashPasswordAsync } from "@homarr/auth";
|
||||||
import { eq } from "drizzle-orm";
|
import { db, eq } from "@homarr/db";
|
||||||
|
|
||||||
import type { CliDatabase } from "../cli-db";
|
|
||||||
import { getCliDb } from "../cli-db";
|
|
||||||
import { CliError, requireCredentialsProvider } from "../errors";
|
|
||||||
import { sessions, users } from "@homarr/db/schema";
|
import { sessions, users } from "@homarr/db/schema";
|
||||||
|
|
||||||
const userLookup: Record<
|
export const usersUpdatePassword = command({
|
||||||
"id" | "username",
|
name: "update-password",
|
||||||
(db: CliDatabase, value: string) => Promise<{ id: string; name: string | null; password: string | null } | undefined>
|
desc: "Update the password for a user (credentials provider only)",
|
||||||
> = {
|
options: {
|
||||||
id: (db, value) =>
|
id: string("id").alias("i").desc("ID of the user"),
|
||||||
db.query.users.findFirst({
|
username: string("username").alias("u").desc("Name of the user"),
|
||||||
where: eq(users.id, value),
|
password: string("password").alias("p").required().desc("New password"),
|
||||||
}),
|
},
|
||||||
username: (db, value) =>
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
db.query.users.findFirst({
|
handler: async (options) => {
|
||||||
where: eq(users.name, value),
|
if (!process.env.AUTH_PROVIDERS?.toLowerCase().includes("credentials")) {
|
||||||
}),
|
console.error("Credentials provider is not enabled");
|
||||||
};
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
export async function usersUpdatePasswordHandler(args: string[]): Promise<number> {
|
if (!options.id && !options.username) {
|
||||||
requireCredentialsProvider();
|
console.error("Either --id or --username must be provided");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const { values } = parseArgs({
|
const user = await db.query.users.findFirst({
|
||||||
args,
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
options: {
|
where: options.id ? eq(users.id, options.id) : eq(users.name, options.username!),
|
||||||
id: { type: "string", short: "i" },
|
});
|
||||||
username: { type: "string", short: "u" },
|
|
||||||
password: { type: "string", short: "p" },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const lookupKey = values.id ? "id" : values.username ? "username" : null;
|
if (!user?.password) {
|
||||||
const lookupValue = values.id ?? values.username;
|
console.error("User not found or has no credentials record");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!lookupKey || !lookupValue) {
|
await db
|
||||||
throw new CliError("Either --id or --username must be provided", 2);
|
.update(users)
|
||||||
}
|
.set({
|
||||||
|
password: await hashPasswordAsync(options.password),
|
||||||
|
})
|
||||||
|
.where(eq(users.id, user.id));
|
||||||
|
|
||||||
if (!values.password) {
|
// invalidate existing sessions
|
||||||
throw new CliError("Missing required option: --password / -p", 2);
|
await db.delete(sessions).where(eq(sessions.userId, user.id));
|
||||||
}
|
console.log(`All sessions for user ${user.name ?? user.id} have been deleted`);
|
||||||
|
|
||||||
const db = getCliDb();
|
console.log("Password updated successfully");
|
||||||
const user = await userLookup[lookupKey](db, lookupValue);
|
},
|
||||||
|
});
|
||||||
if (!user?.password) {
|
|
||||||
throw new CliError("User not found or has no credentials record");
|
|
||||||
}
|
|
||||||
|
|
||||||
await db
|
|
||||||
.update(users)
|
|
||||||
.set({
|
|
||||||
password: await hashPasswordAsync(values.password),
|
|
||||||
})
|
|
||||||
.where(eq(users.id, user.id));
|
|
||||||
|
|
||||||
await db.delete(sessions).where(eq(sessions.userId, user.id));
|
|
||||||
console.log(`All sessions for user ${user.name ?? user.id} have been deleted`);
|
|
||||||
console.log("Password updated successfully");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { command } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
|
import { usersDelete } from "./users-delete";
|
||||||
|
import { usersList } from "./users-list";
|
||||||
|
import { usersUpdatePassword } from "./users-update-password";
|
||||||
|
|
||||||
|
export const usersRoot = command({
|
||||||
|
name: "users",
|
||||||
|
desc: "Group of commands to manage users",
|
||||||
|
subcommands: [usersList, usersDelete, usersUpdatePassword],
|
||||||
|
});
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
export class CliError extends Error {
|
|
||||||
constructor(
|
|
||||||
message: string,
|
|
||||||
readonly exitCode: 1 | 2 = 1,
|
|
||||||
) {
|
|
||||||
super(message);
|
|
||||||
this.name = "CliError";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const requireCredentialsProvider = () => {
|
|
||||||
const enabled = process.env.AUTH_PROVIDERS?.toLowerCase().includes("credentials") ?? false;
|
|
||||||
if (!enabled) {
|
|
||||||
throw new CliError("Credentials provider is not enabled");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
+11
-38
@@ -1,41 +1,14 @@
|
|||||||
import { closeCliDbAsync } from "./cli-db";
|
import { run } from "@drizzle-team/brocli";
|
||||||
import { CliError } from "./errors";
|
|
||||||
import { runCliAsync } from "./router";
|
|
||||||
|
|
||||||
const mainAsync = async (): Promise<number> => {
|
import { fixUsernames } from "./commands/fix-usernames";
|
||||||
const argv = process.argv.slice(2);
|
import { integrationsRoot } from "./commands/integrations";
|
||||||
const start = performance.now();
|
import { recreateAdmin } from "./commands/recreate-admin";
|
||||||
|
import { resetPassword } from "./commands/reset-password";
|
||||||
|
import { usersRoot } from "./commands/users";
|
||||||
|
|
||||||
try {
|
const commands = [usersRoot, integrationsRoot, resetPassword, fixUsernames, recreateAdmin];
|
||||||
const code = await runCliAsync(argv);
|
|
||||||
if (code === 0) {
|
|
||||||
const elapsed = Math.round(performance.now() - start);
|
|
||||||
console.error(`\nDone in ${elapsed}ms`);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
} catch (error) {
|
|
||||||
if (error instanceof CliError) {
|
|
||||||
console.error(error.message);
|
|
||||||
return error.exitCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error instanceof TypeError && error.message.startsWith("Unknown option")) {
|
void run(commands, {
|
||||||
console.error(error.message);
|
name: "homarr-cli",
|
||||||
return 2;
|
version: "1.0.0",
|
||||||
}
|
});
|
||||||
|
|
||||||
console.error(error instanceof Error ? error.message : error);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
mainAsync()
|
|
||||||
.then(async (code) => {
|
|
||||||
await closeCliDbAsync();
|
|
||||||
process.exit(code);
|
|
||||||
})
|
|
||||||
.catch(async (error) => {
|
|
||||||
console.error(error instanceof Error ? error.message : error);
|
|
||||||
await closeCliDbAsync();
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
@@ -1,167 +0,0 @@
|
|||||||
import { fixUsernamesHandler } from "./commands/fix-usernames";
|
|
||||||
import { integrationsDeleteHandler } from "./commands/integrations-delete";
|
|
||||||
import { integrationsListHandler } from "./commands/integrations-list";
|
|
||||||
import { recreateAdminHandler } from "./commands/recreate-admin";
|
|
||||||
import { resetPasswordHandler } from "./commands/reset-password";
|
|
||||||
import { usersDeleteHandler } from "./commands/users-delete";
|
|
||||||
import { usersListHandler } from "./commands/users-list";
|
|
||||||
import { usersUpdatePasswordHandler } from "./commands/users-update-password";
|
|
||||||
import { CliError } from "./errors";
|
|
||||||
|
|
||||||
const VERSION = "1.0.0";
|
|
||||||
|
|
||||||
type CommandHandler = (args: string[]) => Promise<number>;
|
|
||||||
|
|
||||||
interface CommandDef {
|
|
||||||
handler: CommandHandler;
|
|
||||||
desc: string;
|
|
||||||
usage: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
type CommandGroup = Record<string, CommandDef>;
|
|
||||||
|
|
||||||
const topLevelCommands: Record<string, CommandDef> = {
|
|
||||||
"reset-password": {
|
|
||||||
handler: resetPasswordHandler,
|
|
||||||
desc: "Reset password for a credentials user",
|
|
||||||
usage: "homarr reset-password -u <username>",
|
|
||||||
},
|
|
||||||
"fix-usernames": {
|
|
||||||
handler: (args) => fixUsernamesHandler(),
|
|
||||||
desc: "Lowercase all credentials usernames",
|
|
||||||
usage: "homarr fix-usernames",
|
|
||||||
},
|
|
||||||
"recreate-admin": {
|
|
||||||
handler: recreateAdminHandler,
|
|
||||||
desc: "Create credentials admin if none exists",
|
|
||||||
usage: "homarr recreate-admin -u <username>",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const commandGroups: Record<string, CommandGroup> = {
|
|
||||||
users: {
|
|
||||||
list: {
|
|
||||||
handler: (args) => usersListHandler(args),
|
|
||||||
desc: "List all users",
|
|
||||||
usage: "homarr users list [--json]",
|
|
||||||
},
|
|
||||||
delete: {
|
|
||||||
handler: usersDeleteHandler,
|
|
||||||
desc: "Delete a user by id or username",
|
|
||||||
usage: "homarr users delete --id <id> | --username <name>",
|
|
||||||
},
|
|
||||||
"update-password": {
|
|
||||||
handler: usersUpdatePasswordHandler,
|
|
||||||
desc: "Set password for a credentials user",
|
|
||||||
usage: "homarr users update-password (--id <id> | --username <name>) --password <pw>",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
integrations: {
|
|
||||||
list: {
|
|
||||||
handler: (args) => integrationsListHandler(args),
|
|
||||||
desc: "List all integrations",
|
|
||||||
usage: "homarr integrations list [--json]",
|
|
||||||
},
|
|
||||||
delete: {
|
|
||||||
handler: integrationsDeleteHandler,
|
|
||||||
desc: "Delete an integration by id or name",
|
|
||||||
usage: "homarr integrations delete --id <id> | --name <name>",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const HELP_TEXT = `homarr-cli ${VERSION}
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
homarr <command> [options]
|
|
||||||
|
|
||||||
Commands:
|
|
||||||
reset-password Reset password for a credentials user
|
|
||||||
recreate-admin Create credentials admin if none exists
|
|
||||||
fix-usernames Lowercase all credentials usernames
|
|
||||||
users list List all users
|
|
||||||
users delete Delete a user by id or username
|
|
||||||
users update-password Set password for a credentials user
|
|
||||||
integrations list List all integrations
|
|
||||||
integrations delete Delete an integration by id or name
|
|
||||||
|
|
||||||
Global Options:
|
|
||||||
-h, --help Show help (use after a command for command-specific help)
|
|
||||||
-v, --version Show CLI version
|
|
||||||
`;
|
|
||||||
|
|
||||||
const printHelp = () => {
|
|
||||||
console.log(HELP_TEXT);
|
|
||||||
};
|
|
||||||
|
|
||||||
const printCommandHelp = (def: CommandDef) => {
|
|
||||||
console.log(`${def.desc}\n`);
|
|
||||||
console.log(`Usage:\n ${def.usage}\n`);
|
|
||||||
};
|
|
||||||
|
|
||||||
const resolveHandler = (argv: string[]): { handler: CommandHandler; args: string[] } => {
|
|
||||||
const [command, subcommand, ...rest] = argv;
|
|
||||||
|
|
||||||
if (!command) {
|
|
||||||
throw new CliError("Missing command", 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
const group = commandGroups[command];
|
|
||||||
if (group) {
|
|
||||||
if (!subcommand || subcommand === "--help" || subcommand === "-h") {
|
|
||||||
const subcommands = Object.entries(group)
|
|
||||||
.map(([name, def]) => ` ${name.padEnd(18)} ${def.desc}`)
|
|
||||||
.join("\n");
|
|
||||||
console.log(`Usage:\n homarr ${command} <subcommand> [options]\n\nSubcommands:\n${subcommands}\n`);
|
|
||||||
return { handler: async () => subcommand ? 0 : 2, args: [] };
|
|
||||||
}
|
|
||||||
|
|
||||||
const def = group[subcommand];
|
|
||||||
if (!def) {
|
|
||||||
throw new CliError(`Unknown subcommand "${subcommand}" for "${command}"`, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasFlag(rest, "--help", "-h")) {
|
|
||||||
printCommandHelp(def);
|
|
||||||
return { handler: async () => 0, args: [] };
|
|
||||||
}
|
|
||||||
|
|
||||||
return { handler: def.handler, args: rest };
|
|
||||||
}
|
|
||||||
|
|
||||||
const def = topLevelCommands[command];
|
|
||||||
if (!def) {
|
|
||||||
throw new CliError(`Unknown command "${command}"`, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
const args = argv.slice(1);
|
|
||||||
if (hasFlag(args, "--help", "-h")) {
|
|
||||||
printCommandHelp(def);
|
|
||||||
return { handler: async () => 0, args: [] };
|
|
||||||
}
|
|
||||||
|
|
||||||
return { handler: def.handler, args };
|
|
||||||
};
|
|
||||||
|
|
||||||
const hasFlag = (argv: string[], flag: string, short: string) =>
|
|
||||||
argv.some((arg) => arg === flag || arg === short);
|
|
||||||
|
|
||||||
export const runCliAsync = async (argv: string[]): Promise<number> => {
|
|
||||||
if (hasFlag(argv, "--help", "-h") && argv.length === 1) {
|
|
||||||
printHelp();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasFlag(argv, "--version", "-v")) {
|
|
||||||
console.log(VERSION);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argv.length === 0) {
|
|
||||||
printHelp();
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { handler, args } = resolveHandler(argv);
|
|
||||||
return handler(args);
|
|
||||||
};
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
import { randomBytes } from "node:crypto";
|
|
||||||
|
|
||||||
export const generateSecureRandomToken = (size: number) => randomBytes(size).toString("hex");
|
|
||||||
|
|
||||||
export const printTable = (headers: string[], rows: string[][]) => {
|
|
||||||
const widths = headers.map((h, i) =>
|
|
||||||
Math.max(h.length, ...rows.map((r) => (r[i] ?? "").length)),
|
|
||||||
);
|
|
||||||
|
|
||||||
const formatRow = (cells: string[]) =>
|
|
||||||
cells.map((cell, i) => cell.padEnd(widths[i]!)).join(" ");
|
|
||||||
|
|
||||||
console.log(formatRow(headers));
|
|
||||||
console.log(widths.map((w) => "─".repeat(w)).join(" "));
|
|
||||||
for (const row of rows) {
|
|
||||||
console.log(formatRow(row));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -14,7 +14,6 @@
|
|||||||
"./infrastructure/db": "./src/infrastructure/db/index.ts",
|
"./infrastructure/db": "./src/infrastructure/db/index.ts",
|
||||||
"./infrastructure/db/env": "./src/infrastructure/db/env.ts",
|
"./infrastructure/db/env": "./src/infrastructure/db/env.ts",
|
||||||
"./infrastructure/db/constants": "./src/infrastructure/db/constants.ts",
|
"./infrastructure/db/constants": "./src/infrastructure/db/constants.ts",
|
||||||
"./infrastructure/db/mapping": "./src/infrastructure/db/mapping.ts",
|
|
||||||
"./infrastructure/certificates": "./src/infrastructure/certificates/index.ts",
|
"./infrastructure/certificates": "./src/infrastructure/certificates/index.ts",
|
||||||
"./infrastructure/certificates/hostnames/db/sqlite": "./src/infrastructure/certificates/hostnames/db/sqlite.ts",
|
"./infrastructure/certificates/hostnames/db/sqlite": "./src/infrastructure/certificates/hostnames/db/sqlite.ts",
|
||||||
"./infrastructure/certificates/hostnames/db/mysql": "./src/infrastructure/certificates/hostnames/db/mysql.ts",
|
"./infrastructure/certificates/hostnames/db/mysql": "./src/infrastructure/certificates/hostnames/db/mysql.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { InferSelectModel } from "drizzle-orm";
|
import type { InferSelectModel } from "drizzle-orm";
|
||||||
|
|
||||||
import { createDbMapping as createSchema } from "@homarr/core/infrastructure/db/mapping";
|
import { createSchema } from "@homarr/core/infrastructure/db";
|
||||||
|
|
||||||
import * as mysqlSchema from "./mysql";
|
import * as mysqlSchema from "./mysql";
|
||||||
import * as pgSchema from "./postgresql";
|
import * as pgSchema from "./postgresql";
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export const integrationDefs = {
|
|||||||
},
|
},
|
||||||
qBittorrent: {
|
qBittorrent: {
|
||||||
name: "qBittorrent",
|
name: "qBittorrent",
|
||||||
secretKinds: [["apiKey"], ["username", "password"]],
|
secretKinds: [["username", "password"]],
|
||||||
iconUrl: "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/qbittorrent.svg",
|
iconUrl: "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/qbittorrent.svg",
|
||||||
category: ["downloadClient", "torrent"],
|
category: ["downloadClient", "torrent"],
|
||||||
documentationUrl: createDocumentationLink("/docs/integrations/q-bittorent"),
|
documentationUrl: createDocumentationLink("/docs/integrations/q-bittorent"),
|
||||||
|
|||||||
@@ -4,11 +4,9 @@ import { createBooleanSchema, createEnv } from "@homarr/core/infrastructure/env"
|
|||||||
|
|
||||||
export const env = createEnv({
|
export const env = createEnv({
|
||||||
server: {
|
server: {
|
||||||
// Comma separated list of docker hostnames that can be used to connect to query the docker endpoints (localhost,host.docker.internal, ...)
|
// Comma separated list of docker hostnames that can be used to connect to query the docker endpoints (localhost:2375,host.docker.internal:2375, ...)
|
||||||
DOCKER_HOSTNAMES: z.string().optional(),
|
DOCKER_HOSTNAMES: z.string().optional(),
|
||||||
DOCKER_PORTS: z.string().optional(),
|
DOCKER_PORTS: z.string().optional(),
|
||||||
// Comma separated paths to Docker-compatible Unix sockets (e.g., /var/run/docker.sock,/run/user/1000/podman/podman.sock)
|
|
||||||
DOCKER_SOCKET_PATHS: z.string().optional(),
|
|
||||||
ENABLE_DOCKER: createBooleanSchema(true),
|
ENABLE_DOCKER: createBooleanSchema(true),
|
||||||
ENABLE_KUBERNETES: createBooleanSchema(false),
|
ENABLE_KUBERNETES: createBooleanSchema(false),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,43 +11,31 @@ export class DockerSingleton {
|
|||||||
private static instances: DockerInstance[] | null = null;
|
private static instances: DockerInstance[] | null = null;
|
||||||
|
|
||||||
private createInstances() {
|
private createInstances() {
|
||||||
const socketPaths = env.DOCKER_SOCKET_PATHS;
|
|
||||||
const hostVariable = env.DOCKER_HOSTNAMES;
|
const hostVariable = env.DOCKER_HOSTNAMES;
|
||||||
const portVariable = env.DOCKER_PORTS;
|
const portVariable = env.DOCKER_PORTS;
|
||||||
|
if (hostVariable === undefined || portVariable === undefined) {
|
||||||
// Socket instances from DOCKER_SOCKET_PATHS
|
|
||||||
const socketInstances: DockerInstance[] = socketPaths
|
|
||||||
? socketPaths.split(",").map((socketPath) => ({
|
|
||||||
host: socketPath,
|
|
||||||
instance: new Docker({ socketPath }),
|
|
||||||
}))
|
|
||||||
: [];
|
|
||||||
|
|
||||||
// TCP instances from existing DOCKER_HOSTNAMES/DOCKER_PORTS
|
|
||||||
let tcpInstances: DockerInstance[] = [];
|
|
||||||
if (hostVariable !== undefined && portVariable !== undefined) {
|
|
||||||
const hostnames = hostVariable.split(",");
|
|
||||||
const ports = portVariable.split(",");
|
|
||||||
|
|
||||||
if (hostnames.length !== ports.length) {
|
|
||||||
throw new Error("The number of hosts and ports must match");
|
|
||||||
}
|
|
||||||
|
|
||||||
tcpInstances = hostnames.map((host, i) => ({
|
|
||||||
host: `${host}:${ports[i]}`,
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
||||||
instance: new Docker({ host, port: parseInt(ports[i]!, 10) }),
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
const instances = [...socketInstances, ...tcpInstances];
|
|
||||||
|
|
||||||
// Default: local socket if nothing else configured
|
|
||||||
if (instances.length === 0) {
|
|
||||||
return [{ host: "socket", instance: new Docker() }];
|
return [{ host: "socket", instance: new Docker() }];
|
||||||
}
|
}
|
||||||
|
const hostnames = hostVariable.split(",");
|
||||||
|
const ports = portVariable.split(",");
|
||||||
|
|
||||||
return instances;
|
if (hostnames.length !== ports.length) {
|
||||||
|
throw new Error("The number of hosts and ports must match");
|
||||||
|
}
|
||||||
|
|
||||||
|
return hostnames.map((host, i) => {
|
||||||
|
// Check above ensures that ports[i] is not undefined
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
const port = ports[i]!;
|
||||||
|
|
||||||
|
return {
|
||||||
|
host: `${host}:${port}`,
|
||||||
|
instance: new Docker({
|
||||||
|
host,
|
||||||
|
port: parseInt(port, 10),
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static findInstance(host: string): DockerInstance | undefined {
|
public static findInstance(host: string): DockerInstance | undefined {
|
||||||
|
|||||||
@@ -1,110 +0,0 @@
|
|||||||
import { beforeEach, describe, expect, test, vi } from "vitest";
|
|
||||||
|
|
||||||
import { DockerSingleton } from "../singleton";
|
|
||||||
|
|
||||||
const mockEnv = vi.hoisted(() => ({
|
|
||||||
DOCKER_SOCKET_PATHS: undefined as string | undefined,
|
|
||||||
DOCKER_HOSTNAMES: undefined as string | undefined,
|
|
||||||
DOCKER_PORTS: undefined as string | undefined,
|
|
||||||
ENABLE_DOCKER: true,
|
|
||||||
ENABLE_KUBERNETES: false,
|
|
||||||
}));
|
|
||||||
|
|
||||||
vi.mock("dockerode", () => {
|
|
||||||
return {
|
|
||||||
default: class MockDocker {
|
|
||||||
constructor(public opts?: Record<string, unknown>) {}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
vi.mock("../env", () => ({
|
|
||||||
env: mockEnv,
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe("DockerSingleton", () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
// Reset singleton cache between tests
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
|
|
||||||
(DockerSingleton as any).instances = null;
|
|
||||||
|
|
||||||
// Reset env to defaults
|
|
||||||
mockEnv.DOCKER_SOCKET_PATHS = undefined;
|
|
||||||
mockEnv.DOCKER_HOSTNAMES = undefined;
|
|
||||||
mockEnv.DOCKER_PORTS = undefined;
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return default socket when no env vars set", () => {
|
|
||||||
const instances = DockerSingleton.getInstances();
|
|
||||||
|
|
||||||
expect(instances).toHaveLength(1);
|
|
||||||
expect(instances[0]?.host).toBe("socket");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return TCP instances only when DOCKER_HOSTNAMES and DOCKER_PORTS set", () => {
|
|
||||||
mockEnv.DOCKER_HOSTNAMES = "remote-host";
|
|
||||||
mockEnv.DOCKER_PORTS = "2375";
|
|
||||||
|
|
||||||
const instances = DockerSingleton.getInstances();
|
|
||||||
|
|
||||||
expect(instances).toHaveLength(1);
|
|
||||||
expect(instances[0]?.host).toBe("remote-host:2375");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return multiple TCP instances", () => {
|
|
||||||
mockEnv.DOCKER_HOSTNAMES = "host1,host2";
|
|
||||||
mockEnv.DOCKER_PORTS = "2375,2376";
|
|
||||||
|
|
||||||
const instances = DockerSingleton.getInstances();
|
|
||||||
|
|
||||||
expect(instances).toHaveLength(2);
|
|
||||||
expect(instances[0]?.host).toBe("host1:2375");
|
|
||||||
expect(instances[1]?.host).toBe("host2:2376");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should throw when hostname and port counts do not match", () => {
|
|
||||||
mockEnv.DOCKER_HOSTNAMES = "host1,host2";
|
|
||||||
mockEnv.DOCKER_PORTS = "2375";
|
|
||||||
|
|
||||||
expect(() => DockerSingleton.getInstances()).toThrow("The number of hosts and ports must match");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return socket instances when DOCKER_SOCKET_PATHS set", () => {
|
|
||||||
mockEnv.DOCKER_SOCKET_PATHS = "/var/run/docker.sock";
|
|
||||||
|
|
||||||
const instances = DockerSingleton.getInstances();
|
|
||||||
|
|
||||||
expect(instances).toHaveLength(1);
|
|
||||||
expect(instances[0]?.host).toBe("/var/run/docker.sock");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return multiple socket instances", () => {
|
|
||||||
mockEnv.DOCKER_SOCKET_PATHS = "/var/run/docker.sock,/run/user/1000/podman/podman.sock";
|
|
||||||
|
|
||||||
const instances = DockerSingleton.getInstances();
|
|
||||||
|
|
||||||
expect(instances).toHaveLength(2);
|
|
||||||
expect(instances[0]?.host).toBe("/var/run/docker.sock");
|
|
||||||
expect(instances[1]?.host).toBe("/run/user/1000/podman/podman.sock");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should combine socket and TCP instances", () => {
|
|
||||||
mockEnv.DOCKER_SOCKET_PATHS = "/var/run/docker.sock,/run/user/1000/podman/podman.sock";
|
|
||||||
mockEnv.DOCKER_HOSTNAMES = "remote-host";
|
|
||||||
mockEnv.DOCKER_PORTS = "2375";
|
|
||||||
|
|
||||||
const instances = DockerSingleton.getInstances();
|
|
||||||
|
|
||||||
expect(instances).toHaveLength(3);
|
|
||||||
expect(instances[0]?.host).toBe("/var/run/docker.sock");
|
|
||||||
expect(instances[1]?.host).toBe("/run/user/1000/podman/podman.sock");
|
|
||||||
expect(instances[2]?.host).toBe("remote-host:2375");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should cache instances on subsequent calls", () => {
|
|
||||||
const first = DockerSingleton.getInstances();
|
|
||||||
const second = DockerSingleton.getInstances();
|
|
||||||
|
|
||||||
expect(first).toBe(second);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -90,18 +90,10 @@ export class QBitTorrentIntegration extends Integration implements IDownloadClie
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getClientAsync(dispatcher?: Dispatcher) {
|
private async getClientAsync(dispatcher?: Dispatcher) {
|
||||||
const credentials = this.hasSecretValue("apiKey")
|
|
||||||
? {
|
|
||||||
apiKey: this.getSecretValue("apiKey"),
|
|
||||||
}
|
|
||||||
: {
|
|
||||||
username: this.getSecretValue("username"),
|
|
||||||
password: this.getSecretValue("password"),
|
|
||||||
};
|
|
||||||
|
|
||||||
return new QBittorrent({
|
return new QBittorrent({
|
||||||
...credentials,
|
|
||||||
baseUrl: this.url("/").toString(),
|
baseUrl: this.url("/").toString(),
|
||||||
|
username: this.getSecretValue("username"),
|
||||||
|
password: this.getSecretValue("password"),
|
||||||
dispatcher: dispatcher ?? (await createCertificateAgentAsync()),
|
dispatcher: dispatcher ?? (await createCertificateAgentAsync()),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import dayjs from "dayjs";
|
|||||||
import type { ContainerInfo, ContainerStats } from "dockerode";
|
import type { ContainerInfo, ContainerStats } from "dockerode";
|
||||||
import type Dockerode from "dockerode";
|
import type Dockerode from "dockerode";
|
||||||
|
|
||||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
|
||||||
import { ErrorWithMetadata } from "@homarr/core/infrastructure/logs/error";
|
|
||||||
import { db, like, or } from "@homarr/db";
|
import { db, like, or } from "@homarr/db";
|
||||||
import { icons } from "@homarr/db/schema";
|
import { icons } from "@homarr/db/schema";
|
||||||
import type { ContainerState } from "@homarr/docker";
|
import type { ContainerState } from "@homarr/docker";
|
||||||
@@ -11,8 +9,6 @@ import { dockerLabels, DockerSingleton } from "@homarr/docker";
|
|||||||
|
|
||||||
import { createCachedWidgetRequestHandler } from "./lib/cached-widget-request-handler";
|
import { createCachedWidgetRequestHandler } from "./lib/cached-widget-request-handler";
|
||||||
|
|
||||||
const logger = createLogger({ module: "dockerRequestHandler" });
|
|
||||||
|
|
||||||
export const dockerContainersRequestHandler = createCachedWidgetRequestHandler({
|
export const dockerContainersRequestHandler = createCachedWidgetRequestHandler({
|
||||||
queryKey: "dockerContainersResult",
|
queryKey: "dockerContainersResult",
|
||||||
widgetKind: "dockerContainers",
|
widgetKind: "dockerContainers",
|
||||||
@@ -22,34 +18,19 @@ export const dockerContainersRequestHandler = createCachedWidgetRequestHandler({
|
|||||||
cacheDuration: dayjs.duration(20, "seconds"),
|
cacheDuration: dayjs.duration(20, "seconds"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const dockerInstances = DockerSingleton.getInstances();
|
||||||
|
|
||||||
const extractImage = (container: ContainerInfo) => container.Image.split("/").at(-1)?.split(":").at(0) ?? "";
|
const extractImage = (container: ContainerInfo) => container.Image.split("/").at(-1)?.split(":").at(0) ?? "";
|
||||||
|
|
||||||
async function getContainersWithStatsAsync() {
|
async function getContainersWithStatsAsync() {
|
||||||
const dockerInstances = DockerSingleton.getInstances();
|
const containers = await Promise.all(
|
||||||
const results = await Promise.allSettled(
|
|
||||||
dockerInstances.map(async ({ instance, host }) => {
|
dockerInstances.map(async ({ instance, host }) => {
|
||||||
const instanceContainers = await instance.listContainers({ all: true });
|
const instanceContainers = await instance.listContainers({ all: true });
|
||||||
return instanceContainers
|
return instanceContainers
|
||||||
.filter((container) => !(dockerLabels.hide in container.Labels))
|
.filter((container) => !(dockerLabels.hide in container.Labels))
|
||||||
.map((container) => ({ ...container, instance: host }));
|
.map((container) => ({ ...container, instance: host }));
|
||||||
}),
|
}),
|
||||||
);
|
).then((res) => res.flat());
|
||||||
|
|
||||||
const containers = results.flatMap((result, index) => {
|
|
||||||
if (result.status === "fulfilled") return result.value;
|
|
||||||
logger.warn(
|
|
||||||
new ErrorWithMetadata(
|
|
||||||
"Failed to list containers from Docker host",
|
|
||||||
{
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
||||||
host: dockerInstances[index]!.host,
|
|
||||||
},
|
|
||||||
{ cause: result.reason },
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
return [];
|
|
||||||
});
|
|
||||||
const likeQueries = containers.map((container) => like(icons.name, `%${extractImage(container)}%`));
|
const likeQueries = containers.map((container) => like(icons.name, `%${extractImage(container)}%`));
|
||||||
|
|
||||||
const dbIcons =
|
const dbIcons =
|
||||||
@@ -63,6 +44,8 @@ async function getContainersWithStatsAsync() {
|
|||||||
const instance = dockerInstances.find(({ host }) => host === container.instance)?.instance;
|
const instance = dockerInstances.find(({ host }) => host === container.instance)?.instance;
|
||||||
if (!instance) return null;
|
if (!instance) return null;
|
||||||
|
|
||||||
|
// Get stats, falling back to an empty stats object if fetch fails
|
||||||
|
// calculateCpuUsage and calculateMemoryUsage will return 0 for invalid/missing stats
|
||||||
const stats = await instance
|
const stats = await instance
|
||||||
.getContainer(container.Id)
|
.getContainer(container.Id)
|
||||||
.stats({ stream: false, "one-shot": true })
|
.stats({ stream: false, "one-shot": true })
|
||||||
@@ -80,7 +63,6 @@ async function getContainersWithStatsAsync() {
|
|||||||
return {
|
return {
|
||||||
id: container.Id,
|
id: container.Id,
|
||||||
name: container.Names[0]?.split("/")[1] ?? "Unknown",
|
name: container.Names[0]?.split("/")[1] ?? "Unknown",
|
||||||
host: container.instance,
|
|
||||||
state: container.State as ContainerState,
|
state: container.State as ContainerState,
|
||||||
iconUrl:
|
iconUrl:
|
||||||
dbIcons.find((icon) => {
|
dbIcons.find((icon) => {
|
||||||
@@ -98,10 +80,9 @@ async function getContainersWithStatsAsync() {
|
|||||||
return (await Promise.all(containerStatsPromises)).filter((container) => container !== null);
|
return (await Promise.all(containerStatsPromises)).filter((container) => container !== null);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function calculateCpuUsage(stats: ContainerStats): number {
|
function calculateCpuUsage(stats: ContainerStats): number {
|
||||||
// Handle containers with missing or invalid stats (e.g., exited, dead containers, Podman responses)
|
// Handle containers with missing or invalid stats (e.g., exited, dead containers)
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
if (!stats.cpu_stats.online_cpus || stats.cpu_stats.online_cpus === 0 || !stats.cpu_stats.cpu_usage.total_usage) {
|
||||||
if (!stats.cpu_stats?.online_cpus || stats.cpu_stats.online_cpus === 0 || !stats.cpu_stats.cpu_usage?.total_usage) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,10 +95,9 @@ export function calculateCpuUsage(stats: ContainerStats): number {
|
|||||||
return (stats.cpu_stats.cpu_usage.total_usage / usage) * numberOfCpus * 100;
|
return (stats.cpu_stats.cpu_usage.total_usage / usage) * numberOfCpus * 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function calculateMemoryUsage(stats: ContainerStats): number {
|
function calculateMemoryUsage(stats: ContainerStats): number {
|
||||||
// Handle containers with missing or invalid stats (e.g., exited, dead containers, Podman responses)
|
// Handle containers with missing or invalid stats (e.g., exited, dead containers)
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
if (!stats.memory_stats.usage) {
|
||||||
if (!stats.memory_stats?.usage) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,121 +0,0 @@
|
|||||||
import type { ContainerStats } from "dockerode";
|
|
||||||
import { describe, expect, test, vi } from "vitest";
|
|
||||||
|
|
||||||
import { createDb } from "@homarr/db/test";
|
|
||||||
|
|
||||||
import { calculateCpuUsage, calculateMemoryUsage } from "../docker";
|
|
||||||
|
|
||||||
vi.mock("@homarr/db", async (importActual) => {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
|
||||||
const actual = await importActual<typeof import("@homarr/db")>();
|
|
||||||
return {
|
|
||||||
...actual,
|
|
||||||
db: createDb(),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
// Helper to create a partial stats object, cast to ContainerStats.
|
|
||||||
// This mirrors what Podman and other Docker-compatible runtimes may return
|
|
||||||
// at runtime, even though @types/dockerode declares all fields as required.
|
|
||||||
const createStats = (overrides: Record<string, unknown> = {}) => overrides as unknown as ContainerStats;
|
|
||||||
|
|
||||||
describe("calculateCpuUsage", () => {
|
|
||||||
test("should return 0 when cpu_stats is undefined (Podman)", () => {
|
|
||||||
const stats = createStats({ cpu_stats: undefined });
|
|
||||||
expect(calculateCpuUsage(stats)).toBe(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return 0 when online_cpus is 0", () => {
|
|
||||||
const stats = createStats({
|
|
||||||
cpu_stats: { online_cpus: 0, cpu_usage: { total_usage: 1000 }, system_cpu_usage: 5000 },
|
|
||||||
});
|
|
||||||
expect(calculateCpuUsage(stats)).toBe(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return 0 when online_cpus is undefined", () => {
|
|
||||||
const stats = createStats({
|
|
||||||
cpu_stats: { cpu_usage: { total_usage: 1000 }, system_cpu_usage: 5000 },
|
|
||||||
});
|
|
||||||
expect(calculateCpuUsage(stats)).toBe(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return 0 when cpu_usage is undefined", () => {
|
|
||||||
const stats = createStats({
|
|
||||||
cpu_stats: { online_cpus: 4, system_cpu_usage: 5000 },
|
|
||||||
});
|
|
||||||
expect(calculateCpuUsage(stats)).toBe(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return 0 when total_usage is 0", () => {
|
|
||||||
const stats = createStats({
|
|
||||||
cpu_stats: { online_cpus: 4, cpu_usage: { total_usage: 0 }, system_cpu_usage: 5000 },
|
|
||||||
});
|
|
||||||
expect(calculateCpuUsage(stats)).toBe(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return 0 when system_cpu_usage is 0", () => {
|
|
||||||
const stats = createStats({
|
|
||||||
cpu_stats: { online_cpus: 4, cpu_usage: { total_usage: 1000 }, system_cpu_usage: 0 },
|
|
||||||
});
|
|
||||||
expect(calculateCpuUsage(stats)).toBe(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should calculate correct CPU percentage for valid stats", () => {
|
|
||||||
const stats = createStats({
|
|
||||||
cpu_stats: { online_cpus: 4, cpu_usage: { total_usage: 2000 }, system_cpu_usage: 10000 },
|
|
||||||
});
|
|
||||||
// (2000 / 10000) * 4 * 100 = 80
|
|
||||||
expect(calculateCpuUsage(stats)).toBe(80);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should handle fractional CPU usage", () => {
|
|
||||||
const stats = createStats({
|
|
||||||
cpu_stats: { online_cpus: 2, cpu_usage: { total_usage: 500 }, system_cpu_usage: 100000 },
|
|
||||||
});
|
|
||||||
// (500 / 100000) * 2 * 100 = 1
|
|
||||||
expect(calculateCpuUsage(stats)).toBe(1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("calculateMemoryUsage", () => {
|
|
||||||
test("should return 0 when memory_stats is undefined (Podman)", () => {
|
|
||||||
const stats = createStats({ memory_stats: undefined });
|
|
||||||
expect(calculateMemoryUsage(stats)).toBe(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return 0 when memory_stats.usage is 0", () => {
|
|
||||||
const stats = createStats({ memory_stats: { usage: 0 } });
|
|
||||||
expect(calculateMemoryUsage(stats)).toBe(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return 0 when memory_stats.usage is undefined", () => {
|
|
||||||
const stats = createStats({ memory_stats: {} });
|
|
||||||
expect(calculateMemoryUsage(stats)).toBe(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should subtract cache from usage", () => {
|
|
||||||
const stats = createStats({
|
|
||||||
memory_stats: { usage: 1000, stats: { cache: 200 } },
|
|
||||||
});
|
|
||||||
expect(calculateMemoryUsage(stats)).toBe(800);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should use total_inactive_file when cache is absent", () => {
|
|
||||||
const stats = createStats({
|
|
||||||
memory_stats: { usage: 1000, stats: { total_inactive_file: 300 } },
|
|
||||||
});
|
|
||||||
expect(calculateMemoryUsage(stats)).toBe(700);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should use inactive_file as last fallback", () => {
|
|
||||||
const stats = createStats({
|
|
||||||
memory_stats: { usage: 1000, stats: { inactive_file: 150 } },
|
|
||||||
});
|
|
||||||
expect(calculateMemoryUsage(stats)).toBe(850);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return raw usage when memory_stats.stats is undefined", () => {
|
|
||||||
const stats = createStats({ memory_stats: { usage: 512 } });
|
|
||||||
expect(calculateMemoryUsage(stats)).toBe(512);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -3970,9 +3970,6 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Ports"
|
"label": "Ports"
|
||||||
},
|
|
||||||
"host": {
|
|
||||||
"label": "Host"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -79,19 +79,6 @@ const createColumns = (
|
|||||||
return <ContainerStateBadge state={row.original.state} />;
|
return <ContainerStateBadge state={row.original.state} />;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: "host",
|
|
||||||
accessorKey: "host",
|
|
||||||
size: 100,
|
|
||||||
header: t("field.host.label"),
|
|
||||||
Cell({ row }) {
|
|
||||||
return (
|
|
||||||
<Text size="xs" truncate="end">
|
|
||||||
{row.original.host}
|
|
||||||
</Text>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: "cpuUsage",
|
id: "cpuUsage",
|
||||||
sortingFn: (rowA, rowB) => {
|
sortingFn: (rowA, rowB) => {
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ const columnsRatios: Record<keyof ExtendedDownloadClientItem, number> = {
|
|||||||
id: 1,
|
id: 1,
|
||||||
index: 1,
|
index: 1,
|
||||||
integration: 1,
|
integration: 1,
|
||||||
name: 16,
|
name: 8,
|
||||||
progress: 6,
|
progress: 4,
|
||||||
ratio: 2,
|
ratio: 2,
|
||||||
received: 3,
|
received: 3,
|
||||||
sent: 3,
|
sent: 3,
|
||||||
|
|||||||
Generated
+1243
-1606
File diff suppressed because it is too large.
Load diff
+9
-9
@@ -6,7 +6,7 @@ catalog:
|
|||||||
"@auth/core": ^0.41.2
|
"@auth/core": ^0.41.2
|
||||||
"@auth/drizzle-adapter": ^1.11.2
|
"@auth/drizzle-adapter": ^1.11.2
|
||||||
"@ctrl/deluge": ^8.0.0
|
"@ctrl/deluge": ^8.0.0
|
||||||
"@ctrl/qbittorrent": ^9.12.1
|
"@ctrl/qbittorrent": ^9.11.2
|
||||||
"@ctrl/transmission": ^7.4.0
|
"@ctrl/transmission": ^7.4.0
|
||||||
"@dnd-kit/core": ^6.3.1
|
"@dnd-kit/core": ^6.3.1
|
||||||
"@dnd-kit/modifiers": ^9.0.0
|
"@dnd-kit/modifiers": ^9.0.0
|
||||||
@@ -14,7 +14,7 @@ catalog:
|
|||||||
"@dnd-kit/utilities": ^3.2.2
|
"@dnd-kit/utilities": ^3.2.2
|
||||||
"@drizzle-team/brocli": ^0.12.0
|
"@drizzle-team/brocli": ^0.12.0
|
||||||
'@eslint/js': 10.0.1
|
'@eslint/js': 10.0.1
|
||||||
"@extractus/feed-extractor": 7.2.1
|
"@extractus/feed-extractor": 7.1.7
|
||||||
"@gitbeaker/rest": ^43.8.0
|
"@gitbeaker/rest": ^43.8.0
|
||||||
"@homarr/gridstack": ^1.12.0
|
"@homarr/gridstack": ^1.12.0
|
||||||
"@homarr/node-unifi": ^2.6.0
|
"@homarr/node-unifi": ^2.6.0
|
||||||
@@ -45,9 +45,9 @@ catalog:
|
|||||||
"@semantic-release/release-notes-generator": ^14.1.0
|
"@semantic-release/release-notes-generator": ^14.1.0
|
||||||
"@t3-oss/env-nextjs": ^0.13.11
|
"@t3-oss/env-nextjs": ^0.13.11
|
||||||
"@tabler/icons-react": ^3.41.1
|
"@tabler/icons-react": ^3.41.1
|
||||||
"@tanstack/react-query": ^5.100.9
|
"@tanstack/react-query": ^5.100.8
|
||||||
"@tanstack/react-query-devtools": ^5.100.9
|
"@tanstack/react-query-devtools": ^5.100.8
|
||||||
"@tanstack/react-query-next-experimental": ^5.100.9
|
"@tanstack/react-query-next-experimental": ^5.100.8
|
||||||
"@testcontainers/mysql": ^11.14.0
|
"@testcontainers/mysql": ^11.14.0
|
||||||
"@testcontainers/postgresql": ^11.14.0
|
"@testcontainers/postgresql": ^11.14.0
|
||||||
"@testcontainers/redis": ^11.14.0
|
"@testcontainers/redis": ^11.14.0
|
||||||
@@ -72,7 +72,7 @@ catalog:
|
|||||||
"@trpc/react-query": ^11.17.0
|
"@trpc/react-query": ^11.17.0
|
||||||
"@trpc/server": ^11.17.0
|
"@trpc/server": ^11.17.0
|
||||||
"@trpc/tanstack-react-query": ^11.17.0
|
"@trpc/tanstack-react-query": ^11.17.0
|
||||||
"@turbo/gen": ^2.9.8
|
"@turbo/gen": ^2.9.7
|
||||||
"@types/adm-zip": 0.5.8
|
"@types/adm-zip": 0.5.8
|
||||||
"@types/bcrypt": 6.0.0
|
"@types/bcrypt": 6.0.0
|
||||||
"@types/better-sqlite3": 7.6.13
|
"@types/better-sqlite3": 7.6.13
|
||||||
@@ -123,7 +123,7 @@ catalog:
|
|||||||
esbuild: ^0.28.0
|
esbuild: ^0.28.0
|
||||||
eslint: ^10.3.0
|
eslint: ^10.3.0
|
||||||
eslint-config-prettier: ^10.1.8
|
eslint-config-prettier: ^10.1.8
|
||||||
eslint-config-turbo: ^2.9.8
|
eslint-config-turbo: ^2.9.7
|
||||||
eslint-plugin-import: ^2.32.0
|
eslint-plugin-import: ^2.32.0
|
||||||
eslint-plugin-jsx-a11y: ^6.10.2
|
eslint-plugin-jsx-a11y: ^6.10.2
|
||||||
eslint-plugin-react: ^7.37.5
|
eslint-plugin-react: ^7.37.5
|
||||||
@@ -173,7 +173,7 @@ catalog:
|
|||||||
trpc-to-openapi: ^3.2.0
|
trpc-to-openapi: ^3.2.0
|
||||||
tsdav: ^2.2.0
|
tsdav: ^2.2.0
|
||||||
tsx: 4.20.4
|
tsx: 4.20.4
|
||||||
turbo: ^2.9.8
|
turbo: ^2.9.7
|
||||||
typescript: ^5.9.3
|
typescript: ^5.9.3
|
||||||
typescript-eslint: ^8.58.2
|
typescript-eslint: ^8.58.2
|
||||||
undici: 7.24.6
|
undici: 7.24.6
|
||||||
@@ -185,7 +185,7 @@ catalog:
|
|||||||
ws: ^8.20.0
|
ws: ^8.20.0
|
||||||
xml2js: ^0.6.2
|
xml2js: ^0.6.2
|
||||||
yaml: 2.8.4
|
yaml: 2.8.4
|
||||||
zod: ^4.4.3
|
zod: ^4.4.2
|
||||||
zod-form-data: ^3.0.1
|
zod-form-data: ^3.0.1
|
||||||
zod-validation-error: ^5.0.0
|
zod-validation-error: ^5.0.0
|
||||||
catalogMode: strict
|
catalogMode: strict
|
||||||
|
|||||||
@@ -18,19 +18,6 @@ if [ "${PUID}" != "0" ] || [ "${PGID}" != "0" ]; then
|
|||||||
echo "Changing owner to $PUID:$PGID, done."
|
echo "Changing owner to $PUID:$PGID, done."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# support _FILE Suffix for environment variables
|
|
||||||
for file_var in $(env | cut -d '=' -f 1 | grep "_FILE$"); do
|
|
||||||
target_var=$(echo "$file_var" | cut -d'=' -f1 | sed 's/_FILE//')
|
|
||||||
file_path=$(printenv "$file_var")
|
|
||||||
|
|
||||||
if [ -f "$file_path" ]; then
|
|
||||||
export "$target_var"=$(cat "$file_path" | tr -d '\n\r')
|
|
||||||
echo "Info: Loaded secret for $target_var from $file_path"
|
|
||||||
else
|
|
||||||
echo "Warning: Secret file $file_path not found for $target_var"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "${PUID}" != "0" ]; then
|
if [ "${PUID}" != "0" ]; then
|
||||||
exec su-exec $PUID:$PGID "$@"
|
exec su-exec $PUID:$PGID "$@"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ export AUTH_SECRET=$(openssl rand -base64 32)
|
|||||||
# Cron job API key is generated every time the container starts as it is required for communication between nextjs-api and tasks-api
|
# Cron job API key is generated every time the container starts as it is required for communication between nextjs-api and tasks-api
|
||||||
export CRON_JOB_API_KEY=$(openssl rand -base64 32)
|
export CRON_JOB_API_KEY=$(openssl rand -base64 32)
|
||||||
|
|
||||||
|
# Support secret file for encryption key (is not empty and file exists)
|
||||||
|
if [ -n "$SECRET_ENCRYPTION_KEY_FILE" ] && [ -f "$SECRET_ENCRYPTION_KEY_FILE" ]; then
|
||||||
|
export SECRET_ENCRYPTION_KEY=$(cat $SECRET_ENCRYPTION_KEY_FILE)
|
||||||
|
fi
|
||||||
|
|
||||||
# Start nginx proxy
|
# Start nginx proxy
|
||||||
# 1. Replace the HOSTNAME in the nginx template file
|
# 1. Replace the HOSTNAME in the nginx template file
|
||||||
# 2. Create the nginx configuration file from the template
|
# 2. Create the nginx configuration file from the template
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
[{"login":"ajnart","avatar_url":"https://avatars.githubusercontent.com/u/49837342?v=4"},{"login":"manuel-rw","avatar_url":"https://avatars.githubusercontent.com/u/30572287?v=4"},{"login":"Meierschlumpf","avatar_url":"https://avatars.githubusercontent.com/u/63781622?v=4"},{"login":"SeDemal","avatar_url":"https://avatars.githubusercontent.com/u/26098587?v=4"},{"login":"lammersbjorn","avatar_url":"https://avatars.githubusercontent.com/u/71191962?v=4"},{"login":"LarveyOfficial","avatar_url":"https://avatars.githubusercontent.com/u/39219859?v=4"},{"login":"c00ldude1oo","avatar_url":"https://avatars.githubusercontent.com/u/15677803?v=4"},{"login":"InterN0te","avatar_url":"https://avatars.githubusercontent.com/u/10882916?v=4"},{"login":"Aimsucks","avatar_url":"https://avatars.githubusercontent.com/u/1828486?v=4"},{"login":"JannesV","avatar_url":"https://avatars.githubusercontent.com/u/5984244?v=4"},{"login":"MauriceNino","avatar_url":"https://avatars.githubusercontent.com/u/18658092?v=4"},{"login":"hillaliy","avatar_url":"https://avatars.githubusercontent.com/u/950010?v=4"},{"login":"Skeeww","avatar_url":"https://avatars.githubusercontent.com/u/9639992?v=4"},{"login":"RichyHBM","avatar_url":"https://avatars.githubusercontent.com/u/5472275?v=4"},{"login":"Bonfire","avatar_url":"https://avatars.githubusercontent.com/u/5704760?v=4"},{"login":"wieli99","avatar_url":"https://avatars.githubusercontent.com/u/46794825?v=4"},{"login":"ishaanparlikar","avatar_url":"https://avatars.githubusercontent.com/u/43013132?v=4"},{"login":"Zareix","avatar_url":"https://avatars.githubusercontent.com/u/29818713?v=4"},{"login":"tuggan","avatar_url":"https://avatars.githubusercontent.com/u/4325608?v=4"},{"login":"Spillebulle","avatar_url":"https://avatars.githubusercontent.com/u/46653946?v=4"},{"login":"spkesDE","avatar_url":"https://avatars.githubusercontent.com/u/1682314?v=4"},{"login":"j3lte","avatar_url":"https://avatars.githubusercontent.com/u/2557568?v=4"},{"login":"dslatt","avatar_url":"https://avatars.githubusercontent.com/u/5211001?v=4"},{"login":"Malong11-007","avatar_url":"https://avatars.githubusercontent.com/u/40298510?v=4"},{"login":"StefanB7","avatar_url":"https://avatars.githubusercontent.com/u/22056509?v=4"},{"login":"souravghosh01","avatar_url":"https://avatars.githubusercontent.com/u/37548139?v=4"},{"login":"SR3u","avatar_url":"https://avatars.githubusercontent.com/u/2380522?v=4"},{"login":"Rikpat","avatar_url":"https://avatars.githubusercontent.com/u/33869814?v=4"},{"login":"NormanJS","avatar_url":"https://avatars.githubusercontent.com/u/83409549?v=4"},{"login":"No-Maines-Land","avatar_url":"https://avatars.githubusercontent.com/u/20687725?v=4"},{"login":"stark1tty","avatar_url":"https://avatars.githubusercontent.com/u/69326376?v=4"},{"login":"Momcilo42","avatar_url":"https://avatars.githubusercontent.com/u/10118137?v=4"},{"login":"marius-arch","avatar_url":"https://avatars.githubusercontent.com/u/72494359?v=4"},{"login":"Lumilias","avatar_url":"https://avatars.githubusercontent.com/u/10852161?v=4"},{"login":"Havock94","avatar_url":"https://avatars.githubusercontent.com/u/7635248?v=4"},{"login":"Lollyde","avatar_url":"https://avatars.githubusercontent.com/u/11347524?v=4"},{"login":"krishnamuppaneni","avatar_url":"https://avatars.githubusercontent.com/u/4703366?v=4"},{"login":"devtobi","avatar_url":"https://avatars.githubusercontent.com/u/28538704?v=4"},{"login":"TyxTang","avatar_url":"https://avatars.githubusercontent.com/u/90897955?v=4"},{"login":"alotlikebeans","avatar_url":"https://avatars.githubusercontent.com/u/19630511?v=4"},{"login":"WillyJL","avatar_url":"https://avatars.githubusercontent.com/u/49810075?v=4"},{"login":"anonysoul","avatar_url":"https://avatars.githubusercontent.com/u/105715150?v=4"},{"login":"cospeedster","avatar_url":"https://avatars.githubusercontent.com/u/52749645?v=4"},{"login":"diederbert","avatar_url":"https://avatars.githubusercontent.com/u/162878798?v=4"},{"login":"digdilem","avatar_url":"https://avatars.githubusercontent.com/u/4052275?v=4"},{"login":"dinghino","avatar_url":"https://avatars.githubusercontent.com/u/14729459?v=4"},{"login":"gfomichev","avatar_url":"https://avatars.githubusercontent.com/u/1596146?v=4"},{"login":"gnattu","avatar_url":"https://avatars.githubusercontent.com/u/12995396?v=4"},{"login":"tuxpizza","avatar_url":"https://avatars.githubusercontent.com/u/84710786?v=4"},{"login":"xmarkurion","avatar_url":"https://avatars.githubusercontent.com/u/46654687?v=4"},{"login":"huanga","avatar_url":"https://avatars.githubusercontent.com/u/732970?v=4"},{"login":"taos15","avatar_url":"https://avatars.githubusercontent.com/u/122130728?v=4"},{"login":"arghyadipchak","avatar_url":"https://avatars.githubusercontent.com/u/32430374?v=4"},{"login":"AuthorShin","avatar_url":"https://avatars.githubusercontent.com/u/4959043?v=4"},{"login":"benniblot","avatar_url":"https://avatars.githubusercontent.com/u/47495914?v=4"},{"login":"bebsworthy","avatar_url":"https://avatars.githubusercontent.cLine truncated
|
[{"login":"ajnart","avatar_url":"https://avatars.githubusercontent.com/u/49837342?v=4"},{"login":"manuel-rw","avatar_url":"https://avatars.githubusercontent.com/u/30572287?v=4"},{"login":"Meierschlumpf","avatar_url":"https://avatars.githubusercontent.com/u/63781622?v=4"},{"login":"SeDemal","avatar_url":"https://avatars.githubusercontent.com/u/26098587?v=4"},{"login":"lammersbjorn","avatar_url":"https://avatars.githubusercontent.com/u/71191962?v=4"},{"login":"LarveyOfficial","avatar_url":"https://avatars.githubusercontent.com/u/39219859?v=4"},{"login":"c00ldude1oo","avatar_url":"https://avatars.githubusercontent.com/u/15677803?v=4"},{"login":"InterN0te","avatar_url":"https://avatars.githubusercontent.com/u/10882916?v=4"},{"login":"Aimsucks","avatar_url":"https://avatars.githubusercontent.com/u/1828486?v=4"},{"login":"JannesV","avatar_url":"https://avatars.githubusercontent.com/u/5984244?v=4"},{"login":"MauriceNino","avatar_url":"https://avatars.githubusercontent.com/u/18658092?v=4"},{"login":"hillaliy","avatar_url":"https://avatars.githubusercontent.com/u/950010?v=4"},{"login":"Skeeww","avatar_url":"https://avatars.githubusercontent.com/u/9639992?v=4"},{"login":"RichyHBM","avatar_url":"https://avatars.githubusercontent.com/u/5472275?v=4"},{"login":"Bonfire","avatar_url":"https://avatars.githubusercontent.com/u/5704760?v=4"},{"login":"wieli99","avatar_url":"https://avatars.githubusercontent.com/u/46794825?v=4"},{"login":"ishaanparlikar","avatar_url":"https://avatars.githubusercontent.com/u/43013132?v=4"},{"login":"Zareix","avatar_url":"https://avatars.githubusercontent.com/u/29818713?v=4"},{"login":"tuggan","avatar_url":"https://avatars.githubusercontent.com/u/4325608?v=4"},{"login":"Spillebulle","avatar_url":"https://avatars.githubusercontent.com/u/46653946?v=4"},{"login":"spkesDE","avatar_url":"https://avatars.githubusercontent.com/u/1682314?v=4"},{"login":"j3lte","avatar_url":"https://avatars.githubusercontent.com/u/2557568?v=4"},{"login":"dslatt","avatar_url":"https://avatars.githubusercontent.com/u/5211001?v=4"},{"login":"Malong11-007","avatar_url":"https://avatars.githubusercontent.com/u/40298510?v=4"},{"login":"StefanB7","avatar_url":"https://avatars.githubusercontent.com/u/22056509?v=4"},{"login":"souravghosh01","avatar_url":"https://avatars.githubusercontent.com/u/37548139?v=4"},{"login":"SR3u","avatar_url":"https://avatars.githubusercontent.com/u/2380522?v=4"},{"login":"Rikpat","avatar_url":"https://avatars.githubusercontent.com/u/33869814?v=4"},{"login":"NormanJS","avatar_url":"https://avatars.githubusercontent.com/u/83409549?v=4"},{"login":"No-Maines-Land","avatar_url":"https://avatars.githubusercontent.com/u/20687725?v=4"},{"login":"stark1tty","avatar_url":"https://avatars.githubusercontent.com/u/69326376?v=4"},{"login":"Momcilo42","avatar_url":"https://avatars.githubusercontent.com/u/10118137?v=4"},{"login":"marius-arch","avatar_url":"https://avatars.githubusercontent.com/u/72494359?v=4"},{"login":"Lumilias","avatar_url":"https://avatars.githubusercontent.com/u/10852161?v=4"},{"login":"Havock94","avatar_url":"https://avatars.githubusercontent.com/u/7635248?v=4"},{"login":"Lollyde","avatar_url":"https://avatars.githubusercontent.com/u/11347524?v=4"},{"login":"krishnamuppaneni","avatar_url":"https://avatars.githubusercontent.com/u/4703366?v=4"},{"login":"devtobi","avatar_url":"https://avatars.githubusercontent.com/u/28538704?v=4"},{"login":"TyxTang","avatar_url":"https://avatars.githubusercontent.com/u/90897955?v=4"},{"login":"alotlikebeans","avatar_url":"https://avatars.githubusercontent.com/u/19630511?v=4"},{"login":"WillyJL","avatar_url":"https://avatars.githubusercontent.com/u/49810075?v=4"},{"login":"anonysoul","avatar_url":"https://avatars.githubusercontent.com/u/105715150?v=4"},{"login":"cospeedster","avatar_url":"https://avatars.githubusercontent.com/u/52749645?v=4"},{"login":"diederbert","avatar_url":"https://avatars.githubusercontent.com/u/162878798?v=4"},{"login":"digdilem","avatar_url":"https://avatars.githubusercontent.com/u/4052275?v=4"},{"login":"dinghino","avatar_url":"https://avatars.githubusercontent.com/u/14729459?v=4"},{"login":"gfomichev","avatar_url":"https://avatars.githubusercontent.com/u/1596146?v=4"},{"login":"gnattu","avatar_url":"https://avatars.githubusercontent.com/u/12995396?v=4"},{"login":"tuxpizza","avatar_url":"https://avatars.githubusercontent.com/u/84710786?v=4"},{"login":"xmarkurion","avatar_url":"https://avatars.githubusercontent.com/u/46654687?v=4"},{"login":"huanga","avatar_url":"https://avatars.githubusercontent.com/u/732970?v=4"},{"login":"taos15","avatar_url":"https://avatars.githubusercontent.com/u/122130728?v=4"},{"login":"arghyadipchak","avatar_url":"https://avatars.githubusercontent.com/u/32430374?v=4"},{"login":"AuthorShin","avatar_url":"https://avatars.githubusercontent.com/u/4959043?v=4"},{"login":"benniblot","avatar_url":"https://avatars.githubusercontent.com/u/47495914?v=4"},{"login":"bebsworthy","avatar_url":"https://avatars.githubusercontent.cLine truncated
|
||||||
@@ -37,7 +37,6 @@
|
|||||||
"DB_DRIVER",
|
"DB_DRIVER",
|
||||||
"DOCKER_HOSTNAMES",
|
"DOCKER_HOSTNAMES",
|
||||||
"DOCKER_PORTS",
|
"DOCKER_PORTS",
|
||||||
"DOCKER_SOCKET_PATHS",
|
|
||||||
"NODE_ENV",
|
"NODE_ENV",
|
||||||
"PORT",
|
"PORT",
|
||||||
"LOCAL_CERTIFICATE_PATH",
|
"LOCAL_CERTIFICATE_PATH",
|
||||||
|
|||||||
Reference in new issue
Block a user