From 1daf0de9272689f2ba376ea351299eeb30f49f80 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Sun, 19 Feb 2017 00:21:03 +0100 Subject: Extract variables ${EMERGE} and ${GLSA_CHECK} for testability --- bin/porticron | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/bin/porticron b/bin/porticron index dfb996c..9597456 100755 --- a/bin/porticron +++ b/bin/porticron @@ -99,6 +99,7 @@ done : ${CHECK_DUP_MSG:=1} : ${SUBJECT:=Gentoo package updates on {FQDN\} [ {IP\} ]} : ${SUBJECT_WARN:=WARNING: Gentoo security updates on {FQDN\} [ {IP\} ]} +: ${EMERGE:=/usr/bin/emerge} log "using PORTICRON_CONF=${PORTICRON_CONF}, NOMAIL=${NOMAIL}, VERBOSE=${VERBOSE}" @@ -122,8 +123,9 @@ PORTDIR=$(portageq get_repo_path $(portageq envvar EROOT) gentoo) # defaults, second half : ${RCPT:=root} : ${FROM:=root@${FQDN}} -: ${SYNC_CMD:=/usr/bin/emerge --sync} +: ${SYNC_CMD:=${EMERGE} --sync} : ${SYNC_OVERLAYS_CMD:=/bin/true} +: ${GLSA_CHECK:=/usr/bin/glsa-check} # replace variables for var in FQDN HOST IP DATE; do @@ -139,14 +141,14 @@ ${SYNC_OVERLAYS_CMD} &>/dev/null # run emerge once to perform global updates while not cluttering mail output -/usr/bin/emerge --info &>/dev/null +${EMERGE} --info &>/dev/null # GLSA check -log "running GLSA_AFFECTED: /usr/bin/glsa-check --test --nocolor --verbose affected" -GLSA_AFFECTED=$(/usr/bin/glsa-check --test --nocolor --verbose affected 2>/dev/null) -log "running GLSA_UPGRADES: /usr/bin/glsa-check --nocolor --pretend affected" -GLSA_UPGRADES=$(/usr/bin/glsa-check --nocolor --pretend affected | grep '^ ') +log "running GLSA_AFFECTED: ${GLSA_CHECK} --test --nocolor --verbose affected" +GLSA_AFFECTED=$(${GLSA_CHECK} --test --nocolor --verbose affected 2>/dev/null) +log "running GLSA_UPGRADES: ${GLSA_CHECK} --nocolor --pretend affected" +GLSA_UPGRADES=$(${GLSA_CHECK} --nocolor --pretend affected | grep '^ ') if [[ -n ${GLSA_AFFECTED} ]]; then if check_msg GLSA_AFFECTED "${GLSA_AFFECTED}"; then @@ -194,8 +196,8 @@ fi # build list of upgrades : ${UPGRADE_OPTS:=--deep --update} -log "running UPGRADE_CMD: /usr/bin/emerge ${UPGRADE_OPTS} --quiet --pretend world" -UPGRADE=$(/usr/bin/emerge ${UPGRADE_OPTS} --quiet --pretend world 2>/dev/null) +log "running UPGRADE_CMD: ${EMERGE} ${UPGRADE_OPTS} --quiet --pretend world" +UPGRADE=$(${EMERGE} ${UPGRADE_OPTS} --quiet --pretend world 2>/dev/null) if [[ -n ${UPGRADE} ]]; then UPGRADE_MSG=" -- cgit v1.2.3-65-gdbad