Get diff between fleetctl files and local files

38 views Asked by At

I have a file in fleetctl let's call it [email protected] And I have a local file let's call it [email protected]

I want to check if they are different or not. If they are different I will initiate a destroy and start command, but I can't find the way to diff between them..

What I did is built a script:

check_diff ()
{
    # Check if local file is diff from fleetctl file "[email protected]"
    # [email protected] is currently active in the fleetctl
    # Looking for something like
      diff (fleetctl list-units | grep $1 | head -n 1 | awk '{print $1}') $1.service
}

# Get local file names and push them to the function
for unit in $(ls -l | awk '{print $9}' | grep -e \.service); do
  check_diff ${unit%.*} # Will result unit as "file@"
done
1

There are 1 answers

0
Gal Gibli On

Solution:

Found the solution

DIFF=$(fleetctl cat $fleetctlFile | diff -q -w ~/$localServiceUnit -)

Then just check the $DIFF var

if [ -z "$DIFF" ]
then
  echo "No DIFF"
else
  echo "DIFF was found"
fi