From 6af23967a50abb13647fd72c5a8ae861b1a5ae30 Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 09:14:54 +0100 Subject: [PATCH] Add: prevent install package again in download_install_debpkg() --- install.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index a49f114..04747a0 100755 --- a/install.sh +++ b/install.sh @@ -103,9 +103,19 @@ function check_kernel_headers() { } function download_install_debpkg() { - local prefix name r + local prefix name r pkg status _name prefix=$1 name=$2 + pkg=${name%%_*} + + status=$(dpkg -l $pkg | tail -1) + _name=$( echo "$status" | awk '{ printf "%s_%s_%s", $2, $3, $4; }') + status=$(echo "$status" | awk '{ printf "%s", $1; }') + + if [ "X$status" == "Xii" -a "X${name%.deb}" == "X$_name" ]; then + echo "debian package $name already installed." + return 0 + fi for (( i = 0; i < 3; i++ )); do wget $prefix$name -O /tmp/$name && break