From 4f2d8f9bacc331daf01a7779fb1d03adcb78e2f4 Mon Sep 17 00:00:00 2001 From: ThomasC Date: Wed, 2 Jun 2021 17:12:27 +0200 Subject: [PATCH] modif function serviceIsEnabled --- functions.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/functions.sh b/functions.sh index c93a19d..e95c776 100644 --- a/functions.sh +++ b/functions.sh @@ -102,9 +102,11 @@ function fileCountPattern { file=$1 shift string=$@ - if [ ! -f $file ] ; then echo -ne "0;" ; return 0 ;fi + if [ ! -f $file ] ; then e 0 ; return 0 ;fi + local size=$(stat --printf '%s' $file) + if [ $size -eq 0 ] ; then e 0 ; return 0 ; fi num=$(grep -ciE "${string}" $file ) - echo -ne "$num;" + e "$num" } # Ok if file contains N pattern @@ -213,9 +215,10 @@ function commandStdoutPattern { # ok if given service is enabled # arg1: service function serviceIsEnabled { - service=$1 - service=/etc/systemd/system/multi-user.target.wants/${1}.service - if [ -h $service ] ; then e 1 ; else e 0 ; fi + local root=$1 + local service=${2}.service + c=$(ls -l ${root}/etc/systemd/system/multi-user.target.wants/ | grep -i ${service} | wc -l) + if [ $c -gt 0 ] ; then e 1 ; else e 0 ; fi } # ok if output of given url contains given stuff