Skip to content

Commit

Permalink
Add rudimentary support for Ubuntu 14.04 agents
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Box committed Nov 1, 2016
1 parent 9e779ca commit 5ae4e25
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 12 deletions.
39 changes: 27 additions & 12 deletions manifests/agent.pp
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,33 @@
$kill_command = "${use_agent_path}/bin/agent.sh stop force"
$service_description = "Teamcity build agent '${agent_name}'"

file { "/etc/systemd/system/teamcity-agent-${agent_name}.service":
ensure => 'present',
content => template('teamcity/systemd_teamcity.service.erb'),
mode => '0755',
} ~>

Exec['systemctl-daemon-reload'] ->

service { "teamcity-agent-${agent_name}":
ensure => 'running',
enable => true,
require => File["${use_agent_path}/bin/agent.sh"]
if $::operatingsystem == "Ubuntu" && $::operatingsystemrelease == "14.04" {
file { "/etc/init.d/teamcity-agent-${agent_name}":
ensure => 'file',
owner => 'root',
group => 'root',
mode => '0755',
content => template("teamcity/teamcity-agent.erb"),
notify => Service["teamcity-agent-${agent_name}"],
} ->
service { "teamcity-agent-${agent_name}":
ensure => 'running',
enable => true,
}
} else {
file { "/etc/systemd/system/teamcity-agent-${agent_name}.service":
ensure => 'present',
content => template('teamcity/systemd_teamcity.service.erb'),
mode => '0755',
} ~>

Exec['systemctl-daemon-reload'] ->

service { "teamcity-agent-${agent_name}":
ensure => 'running',
enable => true,
require => File["${use_agent_path}/bin/agent.sh"]
}
}

}
61 changes: 61 additions & 0 deletions templates/teamcity-agent.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/sh -
# File is managed by Puppet

### BEGIN INIT INFO
# Provides: teamcity_agent_<%= @agent_name %>
# Required-Start: $local_fs $syslog
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: TeamCity agent management script
### END INIT INFO

. /lib/lsb/init-functions

NAME=teamcity_agent_<%= @agent_name %>
DAEMON=/opt/teamcity_agent_<%= @agent_name %>/bin/agent.sh
PIDFILE=/opt/teamcity_agent_<%= @agent_name %>/logs/teamcityAgent.pid
USER=root

# If the daemon is not there, then exit.
test -x $DAEMON || exit 5

case $1 in
start)
if [ -e $PIDFILE ]; then
status_of_proc -p $PIDFILE $DAEMON "$NAME process" >/dev/null && status="0" || status="$?"
if [ $status = "0" ]; then
log_daemon_msg "$NAME process is already running"
exit
fi
fi

log_daemon_msg "Starting the process" "$NAME"
su --login -c "$DAEMON start" $USER || log_end_msg 1
;;
stop)
if [ -e $PIDFILE ]; then
status_of_proc -p $PIDFILE $DAEMON "Stoppping the $NAME process" >/dev/null && status="0" || status="$?"
if [ $status = "0" ]; then
su --login -c "$DAEMON stop" $USER || log_end_msg 1
else
log_daemon_msg "$NAME process is not running"
log_end_msg 0
fi
fi
;;
restart)
$0 stop && sleep 2 && $0 start
;;
status)
if [ -e $PIDFILE ]; then
status_of_proc -p $PIDFILE $DAEMON "$NAME process" && exit 0 || exit $?
else
log_daemon_msg "$NAME Process is not running"
log_end_msg 0
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 2
esac

0 comments on commit 5ae4e25

Please sign in to comment.