Added timeout to commands

This commit is contained in:
Brian Zalewski 2023-11-08 04:57:15 +00:00
parent cbdff4460a
commit 6aa7bb3a35

View file

@ -1913,8 +1913,13 @@ async function installSoftware(pkgsToInstall) {
} }
installOrdersPre.length && log('info', 'Pre-Install', `Running package-specific pre-installation steps`) installOrdersPre.length && log('info', 'Pre-Install', `Running package-specific pre-installation steps`)
for (const script of installOrdersPre) { for (const script of installOrdersPre) {
const timeoutAvail = which.sync('timeout', { nothrow: true })
if (timeoutAvail) {
await $`${['timeout', '1000', 'bash', '-c', script]}`
} else {
await $`${['bash', '-c', script]}` await $`${['bash', '-c', script]}`
} }
}
installOrdersGroups.length && log('info', 'Users / Groups', `Adding groups / users`) installOrdersGroups.length && log('info', 'Users / Groups', `Adding groups / users`)
for (const group of installOrdersGroups) { for (const group of installOrdersGroups) {
await addUserGroup(group) await addUserGroup(group)
@ -1941,7 +1946,12 @@ async function installSoftware(pkgsToInstall) {
for (const script of installOrdersPost) { for (const script of installOrdersPost) {
try { try {
log('info', 'Post Hook', script) log('info', 'Post Hook', script)
await $`source "${process.env.HOME}/.bashrc" && ${script.replace(/\n/g, "\\\n")}` const timeoutAvail = which.sync('timeout', { nothrow: true })
if (timeoutAvail) {
await $`${['timeout', '1000', 'bash', '-c', script]}`
} else {
await $`${['bash', '-c', script]}`
}
} catch(e) { } catch(e) {
log('info', 'Post-Install Hook', 'Encountered error while running post-install hook') log('info', 'Post-Install Hook', 'Encountered error while running post-install hook')
} }