Chore: improve PUID/PGID support (#5314)

This commit is contained in:
shamoon
2025-05-23 19:39:14 -07:00
committed by GitHub
parent 74c2a2462b
commit 27a392dcce
3 changed files with 51 additions and 8 deletions

View File

@@ -14,19 +14,29 @@ export const CONF_DIR = process.env.HOMEPAGE_CONFIG_DIR
: join(process.cwd(), "config");
export default function checkAndCopyConfig(config) {
// Ensure config directory exists
if (!existsSync(CONF_DIR)) {
mkdirSync(CONF_DIR, { recursive: true });
try {
mkdirSync(CONF_DIR, { recursive: true });
} catch (e) {
console.warn(`Could not create config directory ${CONF_DIR}: ${e.message}`);
return false;
}
}
const configYaml = join(CONF_DIR, config);
// If the config file doesn't exist, try to copy the skeleton
if (!existsSync(configYaml)) {
const configSkeleton = join(process.cwd(), "src", "skeleton", config);
try {
copyFileSync(configSkeleton, configYaml);
console.info("%s was copied to the config folder", config);
} catch (err) {
console.error("error copying config", err);
throw err;
console.error("❌ Failed to initialize required config: %s", configYaml);
console.error("Reason: %s", err.message);
console.error("Hint: Make /app/config writable or manually place the config file.");
process.exit(1);
}
return true;