#!/bin/sh

snapctl set service-option="$(snapctl get service-option-source)"

COMMAND=$(snapctl get command)
if [ "$COMMAND" != "" ]; then
    if [ "$COMMAND" = "restart" ]; then
        snapctl restart test-snapd-service.test-snapd-service
    else
        snapctl "$COMMAND" test-snapd-service.test-snapd-service
    fi
fi

snapctl restart test-snapd-service.test-snapd-other-service

# We need to sleep a little bit, otherwise the restarts in the test happen to quickly
# and systemd fails them with:
# `Start request repeated too quickly.` error in the journal (making the tests fail).
sleep 3
