From 791f7748c7c1959f63327a73a7e24e41b574a910 Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Fri, 22 Nov 2024 13:58:33 -0500 Subject: [PATCH] fix: configuration for browser launch Makes browser launch on startup configurable. Also, by default, users of Arch Linux will not be subjected to this behavior (they won't like it). --- src/backend/src/config.js | 29 ++++++++++++++++++++ src/backend/src/services/WebServerService.js | 5 +++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/backend/src/config.js b/src/backend/src/config.js index c23f357c..16eebe59 100644 --- a/src/backend/src/config.js +++ b/src/backend/src/config.js @@ -110,6 +110,35 @@ config.contact_email = 'hey@' + config.domain; // details to follow in a future announcement. config.legacy_token_migrate = true; +// === OS Information === +const os = require('os'); +const fs = require('fs'); +config.os = {}; +config.os.platform = os.platform(); + +if ( config.os.platform === 'linux' ) { + try { + const osRelease = fs.readFileSync('/etc/os-release').toString(); + // CONTRIBUTORS: If this is the behavior you expect, please add your + // Linux distro here. + if ( osRelease.includes('ID=arch') ) { + config.os.distro = 'arch'; + config.os.archbtw = true; + } + } catch (_) { + // We don't care if we can't read this file; + // we'll just assume it's not a Linux distro. + } +} + +// config.os.refined specifies if Puter is running within a host environment +// where a higher level of user configuration and control is expected. +config.os.refined = config.os.archbtw; + +if ( config.os.refined ) { + config.no_browser_launch = true; +} + module.exports = config; // NEW_CONFIG_LOADING diff --git a/src/backend/src/services/WebServerService.js b/src/backend/src/services/WebServerService.js index a55fec0d..4b795ed3 100644 --- a/src/backend/src/services/WebServerService.js +++ b/src/backend/src/services/WebServerService.js @@ -129,7 +129,7 @@ class WebServerService extends BaseService { // Open the browser to the URL of Puter // (if we are in development mode only) - if(config.env === 'dev') { + if(config.env === 'dev' && ! config.no_browser_launch) { try{ const openModule = await import('open'); openModule.default(url); @@ -496,6 +496,9 @@ class WebServerService extends BaseService { const txt = lines.join('\n'); console.log('\n\x1B[34;1m' + txt + '\x1B[0m\n'); } + if ( config.os.archbtw ) { + console.log('\x1B[34;1mPuter is running on Arch btw\x1B[0m'); + } } }