diff --git a/home/dot_local/bin/executable_installx b/home/dot_local/bin/executable_installx index bfab59bb..1f820fb8 100644 --- a/home/dot_local/bin/executable_installx +++ b/home/dot_local/bin/executable_installx @@ -276,7 +276,7 @@ async function installPackages(pkgInstructions) { const promises = [] log(`Populating install order lists`) for (const option of installOrder[sysType]) { - const instructions = pkgInstructions.filter(x => x.installType === option) + const instructions = pkgInstructions.filter(x => x.installType === option).filter((value, index, array) => array.indexOf(value) === index) if (instructions.length) { combined[option] = instructions } @@ -583,7 +583,15 @@ async function main() { const postField = getPkgData('_post', x, x.installType) if (postField) { log(`Running post-install script for ${x.listKey}`) - await runScript(x.listKey, x[postField]) + const binField = getPkgData('_bin', x, x.installType) + const isArray = Array.isArray(x[binField]) + if (typeof x[binField] === 'string' || isArray) { + isArray && log(`_bin field for ${x.listKey} is an array so the first entry will be used to check`) + const whichCheck = which.sync(typeof x[binField] === 'string' ? x[binField] : x[binField][0], { nothrow: true }) + whichCheck && await runScript(x.listKey, x[postField]) + } else { + console.error(`${x.listKey}'s _bin field should either be a string or an array of strings`) + } } } log(`Running post-install scripts defined in ~/.local/bin/post-installx`) diff --git a/home/dot_local/bin/post-installx/executable_post-rkhunter.sh b/home/dot_local/bin/post-installx/executable_post-rkhunter.sh index ae493649..cbb86696 100644 --- a/home/dot_local/bin/post-installx/executable_post-rkhunter.sh +++ b/home/dot_local/bin/post-installx/executable_post-rkhunter.sh @@ -15,11 +15,11 @@ if command -v rkhunter > /dev/null; then logg info 'Updating file /etc/rkhunter.conf' && sed -i "s/^#WEB_CMD.*$/WEB_CMD=curl\ -L/" /etc/rkhunter.conf fi sudo rkhunter --propupd || RK_PROPUPD_EXIT_CODE=$? - if [ -n "$RK_PROPUPD_EXIT_CODE" ]; then + if [ -n "${RK_PROPUPD_EXIT_CODE-}" ]; then logg error "sudo rkhunter --propupd returned non-zero exit code" fi sudo rkhunter --update || RK_UPDATE_EXIT_CODE=$? - if [ -n "$RK_UPDATE_EXIT_CODE" ]; then + if [ -n "${RK_UPDATE_EXIT_CODE-}" ]; then logg error "sudo rkhunter --update returned non-zero exit code" fi else diff --git a/home/dot_local/bin/post-installx/executable_post-samba.sh b/home/dot_local/bin/post-installx/executable_post-samba.sh index 196029bb..5628fe3a 100644 --- a/home/dot_local/bin/post-installx/executable_post-samba.sh +++ b/home/dot_local/bin/post-installx/executable_post-samba.sh @@ -88,7 +88,7 @@ if command -v smbd > /dev/null; then ### Copy the Samba server configuration file if [ -d /Applications ] && [ -d /System ]; then ### System Private Samba Share - if SMB_OUTPUT=$(sudo sharing -a "$PRIVATE_SHARE" -S "Private (System)" -n "Private (System)" -g 000 -s 001 -E 1 -R 1); then + if SMB_OUTPUT=$(sudo sharing -a "$PRIVATE_SHARE" -S "Private (System)" -n "Private (System)" -g 000 -s 001 -E 1 -R 1 2>&1); then logg success "Configured $PRIVATE_SHARE as a private Samba share" else if echo $SMB_OUTPUT | grep 'smb name already exists' > /dev/null; then @@ -100,7 +100,7 @@ if command -v smbd > /dev/null; then fi ### System Public Samba Share - if SMB_OUTPUT=$(sudo sharing -a "$PUBLIC_SHARE" -S "Public (System)" -n "Public (System)" -g 001 -s 001 -E 1 -R 0); then + if SMB_OUTPUT=$(sudo sharing -a "$PUBLIC_SHARE" -S "Public (System)" -n "Public (System)" -g 001 -s 001 -E 1 -R 0 2>&1); then logg success "Configured $PUBLIC_SHARE as a system public Samba share" else if echo $SMB_OUTPUT | grep 'smb name already exists' > /dev/null; then @@ -112,7 +112,7 @@ if command -v smbd > /dev/null; then fi ### User Shared Samba Share - if SMB_OUTPUT=$(sudo sharing -a "$HOME/Shared" -S "Shared (User)" -n "Shared (User)" -g 001 -s 001 -E 1 -R 0); then + if SMB_OUTPUT=$(sudo sharing -a "$HOME/Shared" -S "Shared (User)" -n "Shared (User)" -g 001 -s 001 -E 1 -R 0 2>&1); then logg success "Configured $HOME/Shared as a user-scoped Samba share" else if echo $SMB_OUTPUT | grep 'smb name already exists' > /dev/null; then