mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-26 11:03:21 +00:00
Read Setup URI generator values from LIVESYNC_ variables
hostname, username, and the other unprefixed names collide with shell and system variables (fish makes hostname read-only, Windows already defines USERNAME). The generator now reads LIVESYNC_HOST, LIVESYNC_USER, LIVESYNC_PASS, LIVESYNC_DB, and LIVESYNC_PASSPHRASE first and falls back to the old names, so existing instructions keep working. Co-authored-by: rwbru <59871009+rwbru@users.noreply.github.com>
This commit is contained in:
1 parent
ce0524d49f
commit
b35ac635d0
7 files changed
+114
-24
No files matched your search
@@ -64,9 +64,17 @@ function configureIdDerivation(
|
||||
function requireValue(
|
||||
environment: SetupGeneratorEnvironment,
|
||||
name: string,
|
||||
legacyName?: string,
|
||||
): string {
|
||||
const value = environment[name]?.trim();
|
||||
if (!value) throw new Error(`${name} is required`);
|
||||
const value = environment[name]?.trim() ||
|
||||
(legacyName && environment[legacyName]?.trim());
|
||||
if (!value) {
|
||||
throw new Error(
|
||||
legacyName
|
||||
? `${name} (or ${legacyName}) is required`
|
||||
: `${name} is required`,
|
||||
);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -97,7 +105,7 @@ function applyEncryptedVaultSettings(
|
||||
Object.assign(settings, {
|
||||
isConfigured: true,
|
||||
encrypt: true,
|
||||
passphrase: requireValue(environment, "passphrase"),
|
||||
passphrase: requireValue(environment, "LIVESYNC_PASSPHRASE", "passphrase"),
|
||||
usePathObfuscation: true,
|
||||
});
|
||||
}
|
||||
@@ -107,10 +115,10 @@ function createCouchDBSettings(
|
||||
): ObsidianLiveSyncSettings {
|
||||
const settings = createNewVaultSettings();
|
||||
Object.assign(settings, PREFERRED_SETTING_SELF_HOSTED, {
|
||||
couchDB_URI: requireValue(environment, "hostname"),
|
||||
couchDB_USER: requireValue(environment, "username"),
|
||||
couchDB_PASSWORD: requireValue(environment, "password"),
|
||||
couchDB_DBNAME: requireValue(environment, "database"),
|
||||
couchDB_URI: requireValue(environment, "LIVESYNC_HOST", "hostname"),
|
||||
couchDB_USER: requireValue(environment, "LIVESYNC_USER", "username"),
|
||||
couchDB_PASSWORD: requireValue(environment, "LIVESYNC_PASS", "password"),
|
||||
couchDB_DBNAME: requireValue(environment, "LIVESYNC_DB", "database"),
|
||||
batchSave: true,
|
||||
periodicReplication: true,
|
||||
syncOnStart: true,
|
||||
|
||||
Reference in new issue
Block a user