Add fix script

This commit is contained in:
Bernhard "bero" Rosenkränzer (Boggins) 2025-02-17 21:50:05 +01:00
parent 8a9d007a6f
commit a1d18d4e49

47
bin/fix Executable file
View File

@ -0,0 +1,47 @@
#!/bin/bash
#
# Try to fix a service
#
# By default, the problem is "solved" the Microsoft way
# (stop and start).
# To do something more intelligent, create a
# /federated/services/<service>/fix
# script.
if [ "$#" != 1 ]; then
echo Usage: $0 service
exit 1
fi
SERVICE="$1"
if /federated/bin/check ${SERVICE}; then
echo "${SERVICE} doesn't seem to be broken"
exit 0
fi
/federated/bin/stop ${SERVICE}
/federated/bin/start ${SERVICE}
if /federated/bin/check ${SERVICE}; then
echo "${SERVICE} was (probably) fixed by a restart"
exit 0
fi
[ -e /federated/services/${SERVICE}/fix ] && . /federated/services/${SERVICE}/fix
if /federated/bin/check ${SERVICE}; then
echo "${SERVICE} was (probably) fixed by the service fix script"
exit 0
fi
/federated/bin/stop ${SERVICE}
/federated/bin/start ${SERVICE}
if /federated/bin/check ${SERVICE}; then
echo "${SERVICE} was (probably) fixed by restarting after running the fix script"
exit 0
fi
echo "${SERVICE} is still broken. Please improve the fix script."
exit 1