I'm trying to force the restart of my rsyslog server. I have sanitary reboot during the day, and sometimes the restart fails, so I want to restart it until the restart is a success.
At this point I'm trying to check if the output of the restart matches the output it is supposed to give when the restart is good.
But I don't understand why the
if statement below doesn't work. It always goes to the else statement whether I put a
!= in the test condition.
Is there a way to check if a multi-line string is equal to another predefined multi-line string?
#!/bin/sh endv=0 testv="Shutting down system logger: [ OK ] Starting system logger: [ OK ]" startv="$(/etc/init.d/rsyslog restart)" while [ $endv == 0 ]; do echo "$startv" if [[ "$startv" != "$testv" ]]; then startv="$(/etc/init.d/rsyslog restart)" echo THEN else echo ELSE endv=1 fi done