0

I have a file in fleetctl let's call it file@123.service And I have a local file let's call it file@.service

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 "file@123.service"
    # file@123.service 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
Gal Gibli
  • 474
  • 3
  • 6
  • 16

1 Answers1

0

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
Gal Gibli
  • 474
  • 3
  • 6
  • 16