Skip to content

Instantly share code, notes, and snippets.

@mariotacke
Last active February 23, 2021 14:57
Show Gist options
  • Save mariotacke/bfc2f3136cfc03496227b39731b074f8 to your computer and use it in GitHub Desktop.
Save mariotacke/bfc2f3136cfc03496227b39731b074f8 to your computer and use it in GitHub Desktop.
/etc/init.d/teamcity-agent auto start script for TeamCity Agents
#!/bin/sh
### BEGIN INIT INFO
# Provides: TeamCity Build Agent
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start build agent daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
USER="agentuser"
case "$1" in
start)
su - $USER -c "/opt/JetBrains/agent/BuildAgent/bin/agent.sh start"
;;
stop)
su - $USER -c "/opt/JetBrains/agent/BuildAgent/bin/agent.sh stop"
;;
*)
echo "usage start/stop"
exit 1
;;
esac
exit 0
@mariotacke
Copy link
Author

To enable:

sudo chmod +x /etc/init.d/teamcity-agent
sudo chown root:root /etc/init.d/teamcity-agent
sudo update-rc.d teamcity-agent defaults
sudo update-rc.d teamcity-agent enable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment