#!/bin/bash


IS_SCRIPT_RUNNER_ACTIVE=$(systemctl is-active lwr-isc-script-runner)
IS_MANAGEMENT_SERVER_ACTIVE=$(systemctl is-active lwr-isc-management-server)

if [[ "${IS_SCRIPT_RUNNER_ACTIVE}" == "active" ]]; then
  systemctl stop lwr-isc-script-runner
fi

if [[ "${IS_MANAGEMENT_SERVER_ACTIVE}" == "active" ]]; then
  systemctl stop lwr-isc-management-server
fi

rm -rf /mnt/storage/config/user-storage/isc/*

if [[ "${IS_MANAGEMENT_SERVER_ACTIVE}" == "active" ]]; then
  systemctl start lwr-isc-management-server
fi

if [[ "${IS_SCRIPT_RUNNER_ACTIVE}" == "active" ]]; then
  systemctl start lwr-isc-script-runner
fi

exit 0
