🧱 dont rely on dpkg

This commit is contained in:
DrMaxNix 2024-08-07 18:41:17 +02:00
parent 2137ab881b
commit 7b4d46601f
2 changed files with 31 additions and 16 deletions

View File

@ -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
}

4
xynat
View File

@ -405,6 +405,10 @@ xynat_secondary_ip_list(){
## TOOLCHECK ##
toolcheck error "grep sed iptables ip"
## PARSE ARGUMENTS ##
while [[ "$#" -gt 0 ]]; do
case "$1" in