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).
This commit is contained in:
KernelDeimos 2024-11-22 13:58:33 -05:00
parent 960a9ec9ee
commit 791f7748c7
2 changed files with 33 additions and 1 deletions

View File

@ -110,6 +110,35 @@ config.contact_email = 'hey@' + config.domain;
// details to follow in a future announcement. // details to follow in a future announcement.
config.legacy_token_migrate = true; 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; module.exports = config;
// NEW_CONFIG_LOADING // NEW_CONFIG_LOADING

View File

@ -129,7 +129,7 @@ class WebServerService extends BaseService {
// Open the browser to the URL of Puter // Open the browser to the URL of Puter
// (if we are in development mode only) // (if we are in development mode only)
if(config.env === 'dev') { if(config.env === 'dev' && ! config.no_browser_launch) {
try{ try{
const openModule = await import('open'); const openModule = await import('open');
openModule.default(url); openModule.default(url);
@ -496,6 +496,9 @@ class WebServerService extends BaseService {
const txt = lines.join('\n'); const txt = lines.join('\n');
console.log('\n\x1B[34;1m' + txt + '\x1B[0m\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');
}
} }
} }