Services declared as oneshot are expected to take some action and exit immediatelly (thus, they are not really services,
no running processes remain). A common pattern for these type of service is to be defined by a setup and a teardown action.
Let's create a example foo service that when started creates a file, and when stopped it deletes it.
Create executable file /opt/foo/setup-foo.sh:
#!/bin/bash
echo "Setting up foo ..."
touch /tmp/foo-activatedCreate executable file /opt/foo/teardown-foo.sh:
#!/bin/bash
echo "Tearing down foo ..."
if [ -f /tmp/foo-activated ]; then
rm /tmp/foo-activated
else
echo "Doesnt seem to be up: Skipping ..."
fi
Just what I was looking for, thanks!