Files
sunnypilot/system/manager/gitlab_runner.sh
T
Jason Wen e36dbe97b5 Merge branch 'master' into SP-147-sync-priv-2024
# Conflicts:
#	common/api/__init__.py
#	panda
#	release/build_release.sh
#	release/files_common
#	selfdrive/car/card.py
#	selfdrive/car/toyota/carcontroller.py
#	selfdrive/controls/controlsd.py
#	selfdrive/controls/radard.py
#	selfdrive/ui/qt/api.cc
#	selfdrive/ui/qt/maps/map.cc
#	selfdrive/ui/ui.cc
#	system/athena/manage_athenad.py
#	system/athena/manage_sunnylinkd.py
#	system/athena/sunnylinkd.py
#	system/manager/gitlab_runner.sh
#	system/manager/manager.py
#	system/manager/mapd_installer.py
#	system/manager/process_config.py
#	system/manager/sunnylink.py
#	system/sentry.py
2024-06-10 21:24:23 -04:00

41 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# Define the service name
SERVICE_NAME="gitlab-runner"
# Function to control the service
control_service() {
local action=$1 # Store the function argument in a local variable
sudo systemctl $action ${SERVICE_NAME}
}
service_exists_and_is_loaded() {
sudo systemctl status ${SERVICE_NAME} &>/dev/null
if [[ $? -ne 4 ]]; then
return 0 # Service is known to systemd (i.e., loaded)
else
return 1 # Service is unknown to systemd (i.e., not loaded)
fi
}
# Check for required argument
if [[ -z $1 ]] || { [[ $1 != "start" ]] && [[ $1 != "stop" ]]; }; then
echo "Usage: $0 {start|stop}"
exit 1
fi
# Store the script argument in a descriptive variable
ACTION=$1
# Trap EXIT signal (Ctrl+C) and stop the service
trap 'control_service stop ; exit' SIGINT SIGKILL EXIT
# Enter the main loop
while true; do
# Check if the service is actually present on the system
if service_exists_and_is_loaded; then
control_service $ACTION # Call the function with the specified action
fi
sleep 1 # Pause before the next iteration
done