Last active
September 18, 2015 10:27
-
-
Save tonidy/a0f3fcc21f41927ba732 to your computer and use it in GitHub Desktop.
make-yt-custom.sh
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 | |
| java -version | |
| update-alternatives --display java | |
| javac -version | |
| update-alternatives --display javac | |
| echo | |
| #wget http://download.jetbrains.com/hub/1.0/hub-ring-bundle-1.0.529.zip | |
| #wget https://download.jetbrains.com/charisma/youtrack-6.5.16713.zip | |
| mkdir -p /usr/jetbrains/{youtrack,hub} | |
| mv ./hub-ring-bundle-1.0.529.zip /usr/jetbrains/hub/arch.zip | |
| mv ./youtrack-6.5.16655.zip /usr/jetbrains/youtrack/arch.zip | |
| pushd /usr/jetbrains/hub | |
| unzip arch.zip | |
| popd | |
| pushd /usr/jetbrains/youtrack | |
| unzip arch.zip | |
| popd | |
| popd | |
| make_initd() { | |
| echo "making init.d for $1" | |
| rq="hub " | |
| if [ "$1" == "hub" ]; then | |
| rq="" | |
| fi | |
| cat >/etc/init.d/$1 <<EOF | |
| #! /bin/sh | |
| ### BEGIN INIT INFO | |
| # Provides: $1 | |
| # Required-Start: $rq\$local_fs \$remote_fs \$network \$syslog \$named | |
| # Required-Stop: $rq\$local_fs \$remote_fs \$network \$syslog \$named | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: S 0 1 6 | |
| # Short-Description: initscript for $1 | |
| # Description: initscript for $1 | |
| ### END INIT INFO | |
| PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
| NAME=$1 | |
| SCRIPT=/usr/jetbrains/\$NAME/bin/\$NAME.sh | |
| do_start() { | |
| \$SCRIPT start soft | |
| } | |
| case "\$1" in | |
| start) | |
| do_start | |
| ;; | |
| stop|restart|status|run|rerun|help) | |
| \$SCRIPT \$1 \$2 | |
| ;; | |
| *) | |
| echo "Usage: sudo /etc/init.d/$1 {start|stop|restart|status|run|rerun}" >&2 | |
| exit 1 | |
| ;; | |
| esac | |
| exit 0 | |
| EOF | |
| chmod +x /etc/init.d/$1 | |
| update-rc.d $1 defaults | |
| if [ "$1" != "hub" ]; then | |
| update-rc.d $1 disable | |
| fi | |
| } | |
| echo | |
| make_initd youtrack | |
| echo | |
| make_initd hub | |
| echo | |
| echo "configure nginx" | |
| apt-get install -t $code-backports nginx -y | |
| cat >./default<<EOF | |
| server { | |
| listen 80; | |
| listen [::]:80; | |
| server_name $yt_domain; | |
| server_tokens off; | |
| location / { | |
| proxy_set_header X-Forwarded-Host \$http_host; | |
| proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; | |
| proxy_set_header X-Forwarded-Proto \$scheme; | |
| proxy_http_version 1.1; | |
| proxy_pass http://localhost:$yt_port/; | |
| } | |
| } | |
| server { | |
| listen 80; | |
| listen [::]:80; | |
| server_name $hub_domain; | |
| server_tokens off; | |
| location / { | |
| proxy_set_header X-Forwarded-Host \$http_host; | |
| proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; | |
| proxy_set_header X-Forwarded-Proto \$scheme; | |
| proxy_http_version 1.1; | |
| proxy_pass http://localhost:$hub_port/; | |
| } | |
| } | |
| server { | |
| listen 80 default_server; | |
| listen [::]:80 default_server; | |
| root /var/www/html; | |
| index index.html index.htm index.nginx-debian.html; | |
| server_name $base_domain; | |
| server_tokens off; | |
| location / { | |
| try_files \$uri \$uri/ =404; | |
| } | |
| } | |
| EOF | |
| mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.old | |
| cp -f default /etc/nginx/sites-available/default | |
| service nginx restart | |
| mkdir -p /root/crons | |
| cat >/root/crons/jetbrains<<EOF | |
| #!/bin/bash | |
| status=404 | |
| while [ \$status -eq 404 ]; do | |
| echo "wait hub..." | |
| sleep 60 | |
| status=\`curl -s -o /dev/null -w "%{http_code}" http://$hub_domain/hub\` | |
| echo "hub status \$status" | |
| done | |
| service youtrack start | |
| exit 0 | |
| EOF | |
| chmod +x /root/crons/jetbrains | |
| echo "MAILTO=$cron_email" > /tmp/cron_ | |
| echo "" >> /tmp/cron_ | |
| echo "@reboot /root/crons/jetbrains" > /tmp/cron_ | |
| crontab /tmp/cron_ | |
| service youtrack stop | |
| service hub stop | |
| /usr/jetbrains/hub/bin/hub.sh configure --listen-port $hub_port --base-url http://$hub_domain | |
| /usr/jetbrains/youtrack/bin/youtrack.sh configure --listen-port $yt_port --base-url http://$yt_domain | |
| service hub start | |
| service youtrack start | |
| echo "goto setup" | |
| echo $hub_domain | |
| echo $yt_domain |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment