Skip to content

Instantly share code, notes, and snippets.

@sodre
Last active April 9, 2016 04:11
Show Gist options
  • Save sodre/353cece52dc9d5cecb637ba8538b0eb7 to your computer and use it in GitHub Desktop.
Save sodre/353cece52dc9d5cecb637ba8538b0eb7 to your computer and use it in GitHub Desktop.
#!/bin/bash
team_city_server=$(mdata-get team-city-server)
useradd -m bender
mkdir -p /home/bender/agent && pushd /home/bender/agent
wget http://${team_city_server}/update/buildAgent.zip
unzip buildAgent.zip && rm -f buildAgent.zip
chmod 755 bin/agent.sh
sed -e "s/^serverUrl=.*/serverUrl=${team_city_server}/" \
-e "s/^name=.*/name=$(hostname)/" \
conf/buildAgent.dist.properties > conf/buildAgent.properties
wget https://gist.githubusercontent.com/sodre/353cece52dc9d5cecb637ba8538b0eb7/raw/ce3d111bd770070cb102ffaaafda05fc735f1f9f/TeamCityAgent.xml \
-O bin/teamcity.xml
svccfg validate bin/teamcity.xml
svccfg import bin/teamcity.xml
chown -R bender: /home/bender
svcadm enable teamcity/agent
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
Copyright (C) 2007 Paul Oswald
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<!-- updated by Jim Park <jpark@jim80.net> for use with SmartOS and Jenkins -->
<!-- updated by Patrick Sodre <psodre@gmail.com> for use with SmartOS and TeamCity -->
<service_bundle type="manifest" name="TeamCity Agent">
<service name="application/teamcity/agent" type="service" version="1">
<create_default_instance enabled="false" />
<single_instance />
<dependency name="multi-user-server" type="service" grouping="require_all" restart_on="none">
<service_fmri value="svc:/milestone/multi-user-server" />
</dependency>
<method_context>
<method_credential user="bender" group="other" />
<method_environment>
<envvar name="PATH" value="/usr/local/sbin:/usr/local/bin:/opt/local/sbin:/opt/local/bin:/usr/sbin:/usr/bin:/sbin" />
<envvar name="JAVA_HOME" value="/opt/local/java/oracle-jdk8" />
</method_environment>
</method_context>
<exec_method type="method" name="start" exec="/home/bender/agent/bin/agent.sh run" timeout_seconds="0"/>
<exec_method type="method" name="stop" exec="/home/bender/agent/bin/agent.sh stop" timeout_seconds="30"/>
<!-- We are going to be kicking off a single child process so we want Wait mode-->
<property_group name="startd" type="framework">
<propval name="duration" type="astring" value="child" />
</property_group>
<stability value="Unstable" />
<template>
<common_name>
<loctext xml:lang="C">TeamCity Agent</loctext>
</common_name>
<documentation>
<doc_link name="TeamCity" uri="https://www.jetbrains.com/teamcity/" />
</documentation>
</template>
</service>
</service_bundle>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment