Skip to content

Commit

Permalink
fix: alpine stuck bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gengjiawen committed Oct 16, 2024
1 parent 2080e58 commit 53490a6
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/helpers/system.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
const osName = require('os-name');
const utils = require('../utils');
const os = require('os');
const fs = require('fs');

function isAlpine() {
let osRelease;

try {
// Read the /etc/os-release file
const osReleaseContent = fs.readFileSync('/etc/os-release', 'utf8');

// Parse the content to find the ID or NAME field
osRelease = osReleaseContent.split('\n').reduce((acc, line) => {
const [key, value] = line.split('=').map(part => part.trim());
if (key && value) {
acc[key] = value.replace(/"/g, ''); // Remove quotes if any
}
return acc;
}, {});

// Check if the OS is Alpine
return osRelease.ID === 'alpine' || osRelease.NAME === 'Alpine Linux';
} catch (error) {
// If the file can't be read, assume it's not Alpine
console.error('Unable to determine OS:', error);
return false;
}
}

module.exports = {
getContainerInfo: () => {
Expand Down Expand Up @@ -66,6 +92,9 @@ module.exports = {

getShellInfo: () => {
utils.log('trace', 'getShellInfo', process.env);
if (isAlpine()) {
return Promise.resolve(['Shell', 'N/A']);
}
if (utils.isMacOS || utils.isLinux) {
const shell =
process.env.SHELL || utils.runSync('getent passwd $LOGNAME | cut -d: -f7 | head -1');
Expand Down

0 comments on commit 53490a6

Please sign in to comment.