Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,11 @@ function main() {
// runner user has elevated privileges, so we can just run the script directly
childProcess.execFileSync(mainScript, ARGS, { stdio: 'inherit' })
} else {
try {
childProcess.execFileSync('sudo', ['-n', '-E', mainScript, ...ARGS], { stdio: 'inherit' })
} catch (error) {
try {
const whoami = childProcess.execSync('whoami').toString().trim()
console.log(`Current user (whoami): ${whoami}`)
} catch (error) {
console.log('Could not determine user via whoami')
}
if (error.code === 'ENOENT') {
// sudo not available (likely in container, which is already running as root), try running directly
childProcess.execFileSync(mainScript, ARGS, { stdio: 'inherit' })
} else {
throw error
}
}
childProcess.execFileSync(mainScript, ARGS, { stdio: 'inherit' })
}
process.exit(0)
}

if (require.main === module) {
main()
}
}
19 changes: 2 additions & 17 deletions index.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,11 @@ function main() {
// runner user has elevated privileges, so we can just run the script directly
childProcess.execFileSync(mainScript, ARGS, { stdio: 'inherit' })
} else {
try {
childProcess.execFileSync('sudo', ['-n', '-E', mainScript, ...ARGS], { stdio: 'inherit' })
} catch (error) {
try {
const whoami = childProcess.execSync('whoami').toString().trim()
console.log(`Current user (whoami): ${whoami}`)
} catch (error) {
console.log('Could not determine user via whoami')
}
if (error.code === 'ENOENT') {
// sudo not available (likely in container, which is already running as root), try running directly
childProcess.execFileSync(mainScript, ARGS, { stdio: 'inherit' })
} else {
throw error
}
}
childProcess.execFileSync(mainScript, ARGS, { stdio: 'inherit' })
}
process.exit(0)
}

if (require.main === module) {
main()
}
}
19 changes: 2 additions & 17 deletions post.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,11 @@ function main() {
// runner user has elevated privileges, so we can just run the script directly
childProcess.execFileSync(mainScript, ARGS, { stdio: 'inherit' })
} else {
try {
childProcess.execFileSync('sudo', ['-n', '-E', mainScript, ...ARGS], { stdio: 'inherit' })
} catch (error) {
try {
const whoami = childProcess.execSync('whoami').toString().trim()
console.log(`Current user (whoami): ${whoami}`)
} catch (error) {
console.log('Could not determine user via whoami')
}
if (error.code === 'ENOENT') {
// sudo not available (likely in container, which is already running as root), try running directly
childProcess.execFileSync(mainScript, ARGS, { stdio: 'inherit' })
} else {
throw error
}
}
childProcess.execFileSync(mainScript, ARGS, { stdio: 'inherit' })
}
process.exit(0)
}

if (require.main === module) {
main()
}
}
Loading