File: //usr/syno/lib/systemd/scripts/synocacheadvisord-clean-up.sh
#! /bin/bash
SERVICE_NAME=synocacheadvisord.service
ADVISOR_TOOL=/usr/syno/sbin/synocacheadvisor
service_result=$(systemctl show -p Result $SERVICE_NAME | awk -F '=' '{print $2}')
service_status=$(systemctl show -p ExecMainStatus $SERVICE_NAME | awk -F '=' '{print $2}')
# exit-code -1(255) implies internal error / load fail, in both cases no need to cleanup
if [ ! "$service_result" = "success" ] && ! { [ "$service_result" = "exit-code" ] && [ "$service_status" = "255" ]; }; then
$ADVISOR_TOOL --clean-up
fi