From 6aa7bb3a3568cdd1c9aa57d3e2ecf9e01cd587d0 Mon Sep 17 00:00:00 2001 From: Brian Zalewski <59970525+ProfessorManhattan@users.noreply.github.com> Date: Wed, 8 Nov 2023 04:57:15 +0000 Subject: [PATCH] Added timeout to commands --- home/dot_local/bin/executable_install-program | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/home/dot_local/bin/executable_install-program b/home/dot_local/bin/executable_install-program index 200590b9..ee8cc6eb 100644 --- a/home/dot_local/bin/executable_install-program +++ b/home/dot_local/bin/executable_install-program @@ -1913,7 +1913,12 @@ async function installSoftware(pkgsToInstall) { } installOrdersPre.length && log('info', 'Pre-Install', `Running package-specific pre-installation steps`) for (const script of installOrdersPre) { - await $`${['bash', '-c', script]}` + const timeoutAvail = which.sync('timeout', { nothrow: true }) + if (timeoutAvail) { + await $`${['timeout', '1000', 'bash', '-c', script]}` + } else { + await $`${['bash', '-c', script]}` + } } installOrdersGroups.length && log('info', 'Users / Groups', `Adding groups / users`) for (const group of installOrdersGroups) { @@ -1941,7 +1946,12 @@ async function installSoftware(pkgsToInstall) { for (const script of installOrdersPost) { try { 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) { log('info', 'Post-Install Hook', 'Encountered error while running post-install hook') }