Browse Source

tab funtions

pull/743/head
Daniel Gibbs 9 years ago
parent
commit
bad55355a2
  1. 30
      functions/check_deps.sh

30
functions/check_deps.sh

@ -8,48 +8,48 @@ lgsm_version="060216"
fn_deps_detector(){ fn_deps_detector(){
# Checks if dependency is missing # Checks if dependency is missing
if [ -n "$(command -v dpkg-query)" ]; then if [ -n "$(command -v dpkg-query)" ]; then
dpkg-query -W -f='${Status}' ${deptocheck} 2>/dev/null| grep -q -P '^install ok installed$' dpkg-query -W -f='${Status}' ${deptocheck} 2>/dev/null| grep -q -P '^install ok installed$'
depstatus=$? depstatus=$?
elif [ -n "$(command -v yum)" ]; then elif [ -n "$(command -v yum)" ]; then
yum -q list installed ${deptocheck} > /dev/null 2>&1 yum -q list installed ${deptocheck} > /dev/null 2>&1
depstatus=$? depstatus=$?
fi fi
if [ "${depstatus}" == "0" ]; then if [ "${depstatus}" == "0" ]; then
missingdep=0 missingdep=0
if [ "${function_selfname}" == "command_install.sh" ]; then if [ "${function_selfname}" == "command_install.sh" ]; then
echo -e "\e[0;32m${deptocheck}\e[0m" echo -e "\e[0;32m${deptocheck}\e[0m"
sleep 0.5 sleep 0.5
fi fi
else else
# if missing dependency is found # if missing dependency is found
missingdep=1 missingdep=1
if [ "${function_selfname}" == "command_install.sh" ]; then if [ "${function_selfname}" == "command_install.sh" ]; then
echo -e "\e[0;31m${deptocheck}\e[0m" echo -e "\e[0;31m${deptocheck}\e[0m"
sleep 0.5 sleep 0.5
fi fi
fi fi
# Missing dependencies are added to array_deps_missing # Missing dependencies are added to array_deps_missing
if [ "${missingdep}" == "1" ]; then if [ "${missingdep}" == "1" ]; then
array_deps_missing+=("${deptocheck}") array_deps_missing+=("${deptocheck}")
fi fi
} }
fn_deps_email(){ fn_deps_email(){
# Adds postfix to required dependencies if email notification is enabled # Adds postfix to required dependencies if email notification is enabled
if [ "${emailnotification}" == "on" ]; then if [ "${emailnotification}" == "on" ]; then
if [ -n "$(command -v dpkg-query)" ]; then if [ -n "$(command -v dpkg-query)" ]; then
array_deps_required+=( mailutils postfix ) array_deps_required+=( mailutils postfix )
elif [ -n "$(command -v yum)" ]; then elif [ -n "$(command -v yum)" ]; then
array_deps_required+=( mailx postfix ) array_deps_required+=( mailx postfix )
fi fi
fi fi
} }
fn_found_missing_deps(){ fn_found_missing_deps(){
if [ "${#array_deps_missing[@]}" != "0" ]; then if [ "${#array_deps_missing[@]}" != "0" ]; then
fn_print_dots "Checking dependencies" fn_print_dots "Checking dependencies"
sleep 2 sleep 2
fn_print_warn "Checking dependencies: missing: \e[0;31m${array_deps_missing[@]}\e[0m" fn_print_warn "Checking dependencies: missing: \e[0;31m${array_deps_missing[@]}\e[0m"
@ -86,7 +86,7 @@ if [ "${#array_deps_missing[@]}" != "0" ]; then
if [ "${function_selfname}" == "command_install.sh" ]; then if [ "${function_selfname}" == "command_install.sh" ]; then
sleep 5 sleep 5
fi fi
fi fi
} }
fn_check_loop(){ fn_check_loop(){

Loading…
Cancel
Save