diff --git a/lib/toolcheck b/lib/toolcheck index 5334363..f87a0a0 100644 --- a/lib/toolcheck +++ b/lib/toolcheck @@ -1,23 +1,34 @@ #!/bin/bash # -# Make sure all required tools are installed. +# Make sure 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'" +toolcheck(){ + for b in $2; do + if [[ ! -f $(which "$b" 2> /dev/null) ]]; then + case $1 in + error) + log_error "Missing tool '$b'" + ;; + + warn) + log_warn "Missing tool '$b'" + return 1 + ;; + + info) + log_info "Missing tool '$b'" + return 1 + ;; + + silent) + return 1 + ;; + + *) + log_error "Unknown log level '$1'" + ;; + esac fi done } diff --git a/xynat b/xynat index b1bf822..2dbc53e 100755 --- a/xynat +++ b/xynat @@ -405,6 +405,10 @@ xynat_secondary_ip_list(){ +## TOOLCHECK ## +toolcheck error "grep sed iptables ip" + + ## PARSE ARGUMENTS ## while [[ "$#" -gt 0 ]]; do case "$1" in