Skip to content

Instantly share code, notes, and snippets.

@bastengao
Created April 23, 2015 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bastengao/0cfd4c6e8294d7d93df0 to your computer and use it in GitHub Desktop.
Save bastengao/0cfd4c6e8294d7d93df0 to your computer and use it in GitHub Desktop.
Teamcity buildagent init start script
#!/bin/bash
# Teamcity buildagent daemon start/stop script.
### BEGIN INIT INFO
# Provides: Teamcity buildagent
# Required-Start: $local_fs $network $remote_fs
# Should-Start: ypbind nscd ldap ntpd xntpd
# Required-Stop: $local_fs $network $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop teamciy buildagent
# Description: Teamcity buildagent
### END INIT INFO
BUILDAGENT="/usr/local/TeamCity/buildAgent"
BUILDAGENT_BIN="/usr/local/TeamCity/buildAgent/bin/"
PID_FILE="$BUILDAGENT/logs/buildAgent.pid"
check_alive() {
ps_alive=0
if [ -f "$PID_FILE" ] ; then
if ps -p `cat $PID_FILE` >/dev/null 2>&1; then
ps_alive=1;
else
rm $PID_FILE
fi
fi
if [ "$ps_alive" = "0" ]; then
return 1
else
return 0
fi
}
start() {
$BUILDAGENT_BIN/agent.sh start
}
stop() {
$BUILDAGENT_BIN/agent.sh stop
}
case "$1" in
start)
start
exit 0
;;
stop)
stop
exit 0
;;
restart)
stop
start
exit 0
;;
status)
if check_alive; then
echo "Running"
else
echo "Stopped"
exit 1
fi
;;
**)
echo "Usage: $0 {start|stop|restart|status}" 1>&2
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment