From 2835919931f45d6cedc342695c820e4f3fc1f26b Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Tue, 1 Aug 2023 18:07:52 -0400 Subject: [PATCH] fix: load env files for cli (#3503) --- server/bin/admin-cli.sh | 1 - server/package-lock.json | 2 +- server/package.json | 2 +- server/src/{cli => admin-cli}/app.module.ts | 0 .../src/{cli => admin-cli}/commands/list-users.command.ts | 0 server/src/{cli => admin-cli}/commands/password-login.ts | 0 .../commands/reset-admin-password.command.ts | 0 server/src/{cli => admin-cli}/constants.ts | 0 server/src/{cli/immich.ts => admin-cli/main.ts} | 0 server/src/main.ts | 6 +++--- server/start.sh | 5 +++++ 11 files changed, 10 insertions(+), 6 deletions(-) delete mode 100755 server/bin/admin-cli.sh rename server/src/{cli => admin-cli}/app.module.ts (100%) rename server/src/{cli => admin-cli}/commands/list-users.command.ts (100%) rename server/src/{cli => admin-cli}/commands/password-login.ts (100%) rename server/src/{cli => admin-cli}/commands/reset-admin-password.command.ts (100%) rename server/src/{cli => admin-cli}/constants.ts (100%) rename server/src/{cli/immich.ts => admin-cli/main.ts} (100%) diff --git a/server/bin/admin-cli.sh b/server/bin/admin-cli.sh deleted file mode 100755 index 90db9957ed..0000000000 --- a/server/bin/admin-cli.sh +++ /dev/null @@ -1 +0,0 @@ -node ./dist/main cli "$@" diff --git a/server/package-lock.json b/server/package-lock.json index 91e79b132b..74f8bd2a2f 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -54,7 +54,7 @@ }, "bin": { "immich": "bin/cli.sh", - "immich-admin": "bin/admin-cli.sh" + "immich-admin": "start.sh admin-cli" }, "devDependencies": { "@nestjs/cli": "^9.1.8", diff --git a/server/package.json b/server/package.json index 735280f9cc..2343f9befd 100644 --- a/server/package.json +++ b/server/package.json @@ -7,7 +7,7 @@ "license": "UNLICENSED", "bin": { "immich": "./bin/cli.sh", - "immich-admin": "./bin/admin-cli.sh" + "immich-admin": "./start.sh admin-cli" }, "scripts": { "build": "nest build", diff --git a/server/src/cli/app.module.ts b/server/src/admin-cli/app.module.ts similarity index 100% rename from server/src/cli/app.module.ts rename to server/src/admin-cli/app.module.ts diff --git a/server/src/cli/commands/list-users.command.ts b/server/src/admin-cli/commands/list-users.command.ts similarity index 100% rename from server/src/cli/commands/list-users.command.ts rename to server/src/admin-cli/commands/list-users.command.ts diff --git a/server/src/cli/commands/password-login.ts b/server/src/admin-cli/commands/password-login.ts similarity index 100% rename from server/src/cli/commands/password-login.ts rename to server/src/admin-cli/commands/password-login.ts diff --git a/server/src/cli/commands/reset-admin-password.command.ts b/server/src/admin-cli/commands/reset-admin-password.command.ts similarity index 100% rename from server/src/cli/commands/reset-admin-password.command.ts rename to server/src/admin-cli/commands/reset-admin-password.command.ts diff --git a/server/src/cli/constants.ts b/server/src/admin-cli/constants.ts similarity index 100% rename from server/src/cli/constants.ts rename to server/src/admin-cli/constants.ts diff --git a/server/src/cli/immich.ts b/server/src/admin-cli/main.ts similarity index 100% rename from server/src/cli/immich.ts rename to server/src/admin-cli/main.ts diff --git a/server/src/main.ts b/server/src/main.ts index 3ab308fd51..1f2221a8de 100644 --- a/server/src/main.ts +++ b/server/src/main.ts @@ -1,4 +1,4 @@ -import { bootstrap as cli } from './cli/immich'; +import { bootstrap as adminCli } from './admin-cli/main'; import { bootstrap as immich } from './immich/main'; import { bootstrap as microservices } from './microservices/main'; @@ -14,8 +14,8 @@ function bootstrap() { return immich(); case 'microservices': return microservices(); - case 'cli': - return cli(); + case 'admin-cli': + return adminCli(); default: console.log(`Invalid app name: ${immichApp}. Expected one of immich|microservices|cli`); process.exit(1); diff --git a/server/start.sh b/server/start.sh index 4d1bc9a78b..617837da70 100755 --- a/server/start.sh +++ b/server/start.sh @@ -1,5 +1,10 @@ #!/bin/sh +if [ "$DB_URL_FILE" ]; then + export DB_URL=$(cat $DB_URL_FILE) + unset DB_URL_FILE +fi + if [ "$DB_HOSTNAME_FILE" ]; then export DB_HOSTNAME=$(cat $DB_HOSTNAME_FILE) unset DB_HOSTNAME_FILE