diff --git a/lib/color b/lib/color index 2d3d628..7b27e40 100644 --- a/lib/color +++ b/lib/color @@ -16,7 +16,7 @@ color_white="" ## ONLY IF PRINTING TO A TERMINAL ## -if test -t 1; then +if test -t 1 && [[ -f $(which tput) ]]; then # check count of supported colors color_count=$(TERM=${TERM:-"dumb"} tput colors) if [[ ! -z "$color_count" && "$color_count" -ge 8 ]]; then diff --git a/lib/toolcheck b/lib/toolcheck new file mode 100644 index 0000000..5334363 --- /dev/null +++ b/lib/toolcheck @@ -0,0 +1,23 @@ +#!/bin/bash + +# +# Make sure all required tools are installed. +# +workplace_toolcheck(){ + ## BINARIES IN PATH ## + bin_tool_list=("grep") + for b in $bin_tool_list; do + if [[ ! -f $(which "$b") ]]; then + log_error "Missing tool '$b'" + fi + done + + + ## DPKG PACKAGES ## + dpkg_tool_list=("sed iptables iproute2") + for d in $dpkg_tool_list; do + if ! dpkg -s $d 2>&1 | grep -q "Status: install ok installed"; then + log_error "Missing tool '$d'" + fi + done +} diff --git a/xynat b/xynat index d065fb3..b1bf822 100755 --- a/xynat +++ b/xynat @@ -15,7 +15,7 @@ VERSION=$(cat ${SCRIPT_DIR}/VERSION | xargs) # load libraries source "${SCRIPT_DIR}/lib/color" source "${SCRIPT_DIR}/lib/log" -#source "${SCRIPT_DIR}/lib/toolcheck" +source "${SCRIPT_DIR}/lib/toolcheck" source "${SCRIPT_DIR}/lib/sudocheck" # regex definitions