Hi,
I am trying to run below task & its working fine in execution but using BigFix its generating blank file however when I am logging into machine locally & trying to run it then its generating file with values, I tried with many ways but no luck.
Tested on RHEL 7 & Centos 8.
delete __createfile
delete /tmp/OpenfileLimit.sh
delete /tmp/openFile.output
createfile until E_O_F
#!/bin/bash
#########################
## Script 1
## Date 21st Jan 2021
##############################################
LIMIT_FILE_LOCATION=/etc/security
LIMITS_FILE=$LIMIT_FILE_LOCATION/limits.conf
BACK_FOLDER=/tmp
TEMP_FILE=$BACK_FOLDER/myTmpLimits.txt
LIMIT_D_DIR=$LIMIT_FILE_LOCATION/limits.d
OUTPUT_FILE=/tmp/openFile.output
echo >$OUTPUT_FILE
BACK_FOLDER=/tmp/opfbak
#mkdir -p $BACK_FOLDER
SOFT_FILE_ENTRY=false
HARD_FILE_ENTRY=false
#check ulimit
UMILIT_VAL=`ulimit -n`
echo "ULIMIT VAL: $UMILIT_VAL"
if [ $UMILIT_VAL -lt 8040 ] ; then
echo "=======> File process : $file"
#clean backup
echo "list all files : find $LIMIT_D_DIR -maxdepth 1 -type f "
while read -r file; do
echo "Taking Backup of file "
FILE_NAME=`basename $file`
#Process file
### Append whatever you need to the temporary file.
SOFT_VAL=`grep -e "^\*.*soft.*nofile " $FILE_NAME | awk '{{if ($4 < 8040) print $4;}'`
echo "SOFT VAL : $SOFT_VAL"
if [[ -z $SOFT_VAL ]] ; then
if grep -e "^\*.*soft.*nofile " $TEMP_FILE ; then
echo "found soft value defined in $file"
SOFT_FILE_ENTRY=true;
fi
fi
HARD_VAL=`grep -e "^\*.*hard.*nofile " $FILE_NAME | awk '{{if ($4 < 8040) print $4;}'`
echo "Hard val : $HARD_VAL"
if [[ -z $HARD_VAL ]] ; then
if grep -e "^\*.*hard.*nofile " $TEMP_FILE ; then
echo "hard value defined in file $file"
HARD_FILE_ENTRY=true;
fi
fi
done < <( find $LIMIT_D_DIR -maxdepth 1 -type f )
else
SOFT_FILE_ENTRY=true
HARD_FILE_ENTRY=true
fi
echo "--------Final---------"
echo "Open file linit Hard Found= $HARD_FILE_ENTRY"
echo "Open file linit Soft Found= $SOFT_FILE_ENTRY"
if [[ $HARD_FILE_ENTRY == "false" ]] ; then
echo "False" > $OUTPUT_FILE
else
echo "True" > $OUTPUT_FILE
fi
if [[ $SOFT_FILE_ENTRY == "false" ]] ; then
echo "False" > $OUTPUT_FILE
else
echo "True" > $OUTPUT_FILE
fi
E_O_F
//move & modify createfile to allow execution
move __createfile /tmp/OpenfileLimit.sh
wait chmod 755 /tmp/OpenfileLimit.sh
run /tmp/OpenfileLimit.sh
wait sleep 2
if {not exists file "/var/opt/BESClient/openFile.output"}
exit 10
endif