Last active
February 19, 2017 21:34
-
-
Save denys-popov/fa1a842c490d33776f8a to your computer and use it in GitHub Desktop.
teamcity installation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "'tc.coding-rocks.com' 8111 '9.1.3'" | |
domain=$1 | |
port=$2 | |
teamcity_version=$3 | |
teamcity_user=teamcity | |
teamcity_home=/opt/teamcity | |
java_home=/usr/lib/jvm/java-8-oracle | |
gistpath=https://gist.github.com/purblind/fa1a842c490d33776f8a/raw | |
echo "installing TeamCity version:${version} fro domain:${domain} on internal port:${port} ..." | |
sudo apt-get update | |
# install strong password generator | |
sudo apt-get install apg | |
# install nginx | |
sudo apt-add-repository ppa:nginx/stable -y | |
sudo apt-get update && sudo apt-get install nginx nginx-extras | |
sudo unlink /etc/nginx/sites-enabled/default || true | |
# update the config | |
sudo wget -v ${gistpath}/teamcity-init.d.sh -O /etc/init.d/teamcity | |
sudo sed -i "s/<myteamcityuser>/${teamcity_user}/" /etc/init.d/teamcity | |
sudo sed -i "s/<myteamcityhome>/${teamcity_home}/" /etc/init.d/teamcity | |
sudo chmod +x /etc/init.d/teamcity | |
sudo wget -v ${gistpath}/nginx.conf -O /etc/nginx/sites-available/${domain} | |
sudo sed -i "s/<myport>/${port}/" /etc/nginx/sites-available/${domain} | |
sudo sed -i "s/<mydomain>/${domain}/" /etc/nginx/sites-available/${domain} | |
# create syn link | |
sudo ln -s /etc/nginx/sites-available/${domain} /etc/nginx/sites-enabled/${domain} | |
# reload | |
sudo /etc/init.d/nginx reload | |
sudo update-rc.d nginx defaults | |
sudo apt-get install postgresql postgresql-contrib | |
teamcity_db_pass=`apg -a 1 -n 1 -m 13` | |
echo "TEAMCITY_DB_PASS: ${teamcity_db_pass}" > "teamcity.db.pass.txt" | |
# create service | |
# sudo nano /etc/init.d/teamcity | |
sudo chmod +x /etc/init.d/teamcity | |
sudo update-rc.d teamcity defaults | |
sudo su - postgres -c "psql -c \"create role teamcity with login password '${teamcity_db_pass}'; create database teamcity owner teamcity;\"" | |
echo "connectionUrl=jdbc:postgresql://localhost/teamcity" | |
echo "connectionProperties.user=teamcity" | |
echo "connectionProperties.password=${teamcity_db_pass}" | |
sudo adduser --home ${teamcity_home} --disabled-password ${teamcity_user} | |
sudo su - ${teamcity_user} | |
wget "http://download.jetbrains.com/teamcity/TeamCity-${teamcity_version}.tar.gz" | |
tar --strip-components=1 -zxvf TeamCity-${teamcity_version}.tar.gz | |
rm -v ./bin/{*.exe,*.bat,*.cmd} | |
mkdir -p .BuildServer/lib/jdbc | |
wget https://jdbc.postgresql.org/download/postgresql-9.4-1201.jdbc41.jar -O .BuildServer/lib/jdbc/postgresql-9.4-1201.jdbc41.jar | |
sudo service teamcity restart |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We need to support websockets from TC 9.x onwards | |
# https://confluence.jetbrains.com/display/TCD9/How+To...#HowTo...-SetUpTeamCitybehindaProxyServer | |
map $http_upgrade $connection_upgrade { | |
default upgrade; | |
'' ''; | |
} | |
server { | |
listen 80; | |
server_name <mydomain>; | |
proxy_read_timeout 1200; | |
proxy_connect_timeout 240; | |
client_max_body_size 0; | |
location / { | |
proxy_pass http://localhost:<myport>; | |
proxy_http_version 1.1; | |
proxy_set_header X-Forwarded-For $remote_addr; | |
proxy_set_header Host $server_name:$server_port; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection $connection_upgrade; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# chkconfig: 2345 95 05 | |
# /etc/init.d/teamcity - startup script for teamcity | |
TEAMCITY_USER=<myteamcityuser> | |
TEAMCITY_HOME=<myteamcityhome> | |
TEAMCITY_RUNALL_SCRIPT=${TEAMCITY_HOME}/bin/runAll.sh | |
export TEAMCITY_DATA_PATH="${TEAMCITY_HOME}/.BuildServer" | |
export TEAMCITY_SERVER_OPTS=-Djava.awt.headless=true # Configure TeamCity for use on a headless OS. | |
export JAVA_HOME=<myjavahome> | |
case $1 in | |
start) | |
echo "Starting Team City..." | |
start-stop-daemon --start -c ${TEAMCITY_USER} --exec ${TEAMCITY_RUNALL_SCRIPT} start | |
echo "Starting Team City - done." | |
;; | |
stop) | |
echo "Stopping Team City..." | |
start-stop-daemon --start -c ${TEAMCITY_USER} --exec ${TEAMCITY_RUNALL_SCRIPT} stop | |
echo "Stopping Team City - done." | |
;; | |
restart) | |
echo "Restarting Team City..." | |
start-stop-daemon --start -c ${TEAMCITY_USER} --exec ${TEAMCITY_RUNALL_SCRIPT} stop | |
start-stop-daemon --start -c ${TEAMCITY_USER} --exec ${TEAMCITY_RUNALL_SCRIPT} start | |
echo "Restarting Team City - done." | |
;; | |
*) | |
echo "Usage: /etc/init.d/teamcity {start|stop|restart}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment