Skip to content

Commit 3ebfca5

Browse files
committed
Create packagecheck.sh
1 parent 15dff4b commit 3ebfca5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packagecheck.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
PACKAGES=$1
4+
5+
notinstall_pkgs=""
6+
install=false
7+
8+
for pkg in $PACKAGES; do
9+
status="$(dpkg-query -W --showformat='${db:Status-Status}' "$pkg" 2>&1)"
10+
if [ ! $? = 0 ] || [ ! "$status" = installed ]; then
11+
install=true
12+
notinstall_pkgs=$pkg" "$notinstall_pkgs
13+
else
14+
installed_pkgs=$pkg" "$installed_pkgs
15+
fi
16+
done
17+
18+
if "$install"; then
19+
apt-get install -y --no-install-recommends $notinstall_pkgs && rm -rf /var/lib/apt/lists/*
20+
else
21+
echo "### WARNING ${installed_pkgs} Package[s] already installed. ###"
22+
fi

0 commit comments

Comments
 (0)