#!/bin/bash ARGS="" SUDO="" usage() { echo "${0##*/} [--pretend|-p] [--apply|-a]" echo echo " Check for GLSAs applicable to this system and apply them, if desired." echo " Requires sudo access to apply GLSAs." echo echo " --pretend|-p" echo " Show which packages would be upgraded." echo " --apply|-a" echo " Actually perform the upgrade." exit 1 } needed_bins() { local i for i in glsa-check sudo; do if ! type ${i} >& /dev/null; then echo "Executable '${i}' not found!" echo "Quitting." exit 1 fi done } if [[ -z $1 ]]; then usage fi needed_bins case $1 in --pretend|-p) ARGS="--pretend" ;; --apply|-a) ARGS="--fix" SUDO="sudo" ;; *) usage ;; esac LIST=$(glsa-check -ln 2>/dev/null | awk '{ print $1 }') if [[ -n $LIST ]]; then TEST=$(glsa-check -t ${LIST}) if [[ -n $TEST ]]; then ${SUDO} glsa-check ${ARGS} ${TEST} else echo "No unapplied GLSAs affect this system." echo "Quitting" exit 0 fi else echo "No unapplied GLSAs." echo "Quitting" exit 0 fi