mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 22:06:00 +00:00
fix(docker): ensure temp admin pass shows
This commit is contained in:
parent
683c20ca7f
commit
d2c7477b3b
@ -90,7 +90,18 @@ class DefaultUserService extends BaseService {
|
||||
if ( ! is_default_password ) return;
|
||||
|
||||
// show console widget
|
||||
this.default_user_widget = () => {
|
||||
this.default_user_widget = ({ is_docker }) => {
|
||||
if ( is_docker ) {
|
||||
// In Docker we keep the output as simple as possible because
|
||||
// we're unable to determine the size of the terminal
|
||||
return [
|
||||
'Password for `admin`: ' + tmp_password,
|
||||
// TODO: possible bug
|
||||
// These blank lines are necessary for it to render and
|
||||
// I'm not entirely sure why anymore.
|
||||
'', '',
|
||||
];
|
||||
}
|
||||
const lines = [
|
||||
`Your admin user has been created!`,
|
||||
`\x1B[31;1musername:\x1B[0m ${USERNAME}`,
|
||||
@ -100,6 +111,7 @@ class DefaultUserService extends BaseService {
|
||||
surrounding_box('31;1', lines);
|
||||
return lines;
|
||||
};
|
||||
this.default_user_widget.critical = true;
|
||||
this.start_poll_({ tmp_password, user });
|
||||
const svc_devConsole = this.services.get('dev-console');
|
||||
svc_devConsole.add_widget(this.default_user_widget);
|
||||
|
@ -20,11 +20,26 @@ const { consoleLogManager } = require('../util/consolelog');
|
||||
const BaseService = require('./BaseService');
|
||||
|
||||
class DevConsoleService extends BaseService {
|
||||
static MODULES = {
|
||||
fs: require('fs'),
|
||||
}
|
||||
|
||||
_construct () {
|
||||
this.static_lines = [];
|
||||
this.widgets = [];
|
||||
this.identifiers = {};
|
||||
this.has_updates = false;
|
||||
|
||||
try {
|
||||
const require = this.require;
|
||||
const fs = require('fs');
|
||||
this.is_docker = fs.existsSync('/.dockerenv');
|
||||
} catch (e) {
|
||||
// if this fails, we assume is_docker should
|
||||
// be false.
|
||||
this.log.error(e.message);
|
||||
this.is_docker = false;
|
||||
}
|
||||
}
|
||||
|
||||
turn_on_the_warning_lights () {
|
||||
@ -60,7 +75,7 @@ class DevConsoleService extends BaseService {
|
||||
let positions = [];
|
||||
for ( const w of this.widgets ) {
|
||||
let output; try {
|
||||
output = w();
|
||||
output = w({ is_docker: this.is_docker });
|
||||
} catch ( e ) {
|
||||
consoleLogManager.log_raw('error', e);
|
||||
to_remove.push(w);
|
||||
@ -78,6 +93,7 @@ class DevConsoleService extends BaseService {
|
||||
for ( let i = this.widgets.length-1 ; i >= 0 ; i-- ) {
|
||||
if ( size_ok() ) break;
|
||||
const w = this.widgets[i];
|
||||
if ( w.critical ) continue;
|
||||
if ( ! w.unimportant ) continue;
|
||||
n_hidden++;
|
||||
const [start, length] = positions[i];
|
||||
@ -89,8 +105,9 @@ class DevConsoleService extends BaseService {
|
||||
}
|
||||
for ( let i = this.widgets.length-1 ; i >= 0 ; i-- ) {
|
||||
if ( size_ok() ) break;
|
||||
n_hidden++;
|
||||
const w = this.widgets[i];
|
||||
if ( w.critical ) continue;
|
||||
n_hidden++;
|
||||
const [start, length] = positions[i];
|
||||
this.static_lines.splice(start, length);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user