To check if some system service is active and then activate/deactivate it use the next code:

#!/bin/bash
systemctl -q is-active jackett.service  && \
 systemctl stop jackett.service || \
 systemctl start jackett.service