refactor: make dependency_check() take an array as first argument
Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
@@ -233,24 +233,25 @@ restart_nginx(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependency_check(){
|
dependency_check(){
|
||||||
|
local dep="${1}" # dep: array
|
||||||
status_msg "Checking for the following dependencies:"
|
status_msg "Checking for the following dependencies:"
|
||||||
#check if package is installed, if not write name into array
|
#check if package is installed, if not write name into array
|
||||||
for pkg in "${dep[@]}"
|
for pkg in ${dep}
|
||||||
do
|
do
|
||||||
echo -e "${cyan}● $pkg ${default}"
|
echo -e "${cyan}● ${pkg} ${default}"
|
||||||
if [[ ! $(dpkg-query -f'${Status}' --show $pkg 2>/dev/null) = *\ installed ]]; then
|
if [[ ! $(dpkg-query -f'${Status}' --show "${pkg}" 2>/dev/null) = *\ installed ]]; then
|
||||||
inst+=($pkg)
|
inst+=("${pkg}")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
#if array is not empty, install packages from array elements
|
#if array is not empty, install packages from array elements
|
||||||
if [ "${#inst[@]}" != "0" ]; then
|
if [ "${#inst[@]}" -ne 0 ]; then
|
||||||
status_msg "Installing the following dependencies:"
|
status_msg "Installing the following dependencies:"
|
||||||
for element in ${inst[@]}
|
for element in "${inst[@]}"
|
||||||
do
|
do
|
||||||
echo -e "${cyan}● $element ${default}"
|
echo -e "${cyan}● ${element} ${default}"
|
||||||
done
|
done
|
||||||
echo
|
echo
|
||||||
sudo apt-get update --allow-releaseinfo-change && sudo apt-get install ${inst[@]} -y
|
sudo apt-get update --allow-releaseinfo-change && sudo apt-get install "${inst[@]}" -y
|
||||||
ok_msg "Dependencies installed!"
|
ok_msg "Dependencies installed!"
|
||||||
#clearing the array
|
#clearing the array
|
||||||
unset inst
|
unset inst
|
||||||
|
|||||||
Reference in New Issue
Block a user