mirror of
https://github.com/actions/runner.git
synced 2025-12-10 20:36:49 +00:00
Check if service exists before stopping it (Linux) (#1135)
* Check if service exists before stopping it * Remove empty line (formatting) * Use the same way as status to check service * Revert formatting change
This commit is contained in:
@@ -106,18 +106,30 @@ function stop()
|
|||||||
|
|
||||||
function uninstall()
|
function uninstall()
|
||||||
{
|
{
|
||||||
stop
|
if service_exists; then
|
||||||
systemctl disable ${SVC_NAME} || failed "failed to disable ${SVC_NAME}"
|
stop
|
||||||
rm "${UNIT_PATH}" || failed "failed to delete ${UNIT_PATH}"
|
systemctl disable ${SVC_NAME} || failed "failed to disable ${SVC_NAME}"
|
||||||
|
rm "${UNIT_PATH}" || failed "failed to delete ${UNIT_PATH}"
|
||||||
|
else
|
||||||
|
echo "Service ${SVC_NAME} is not installed"
|
||||||
|
fi
|
||||||
if [ -f "${CONFIG_PATH}" ]; then
|
if [ -f "${CONFIG_PATH}" ]; then
|
||||||
rm "${CONFIG_PATH}" || failed "failed to delete ${CONFIG_PATH}"
|
rm "${CONFIG_PATH}" || failed "failed to delete ${CONFIG_PATH}"
|
||||||
fi
|
fi
|
||||||
systemctl daemon-reload || failed "failed to reload daemons"
|
systemctl daemon-reload || failed "failed to reload daemons"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function service_exists() {
|
||||||
|
if [ -f "${UNIT_PATH}" ]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function status()
|
function status()
|
||||||
{
|
{
|
||||||
if [ -f "${UNIT_PATH}" ]; then
|
if service_exists; then
|
||||||
echo
|
echo
|
||||||
echo "${UNIT_PATH}"
|
echo "${UNIT_PATH}"
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user