-
-
Save DeSater/7a64c8a08d28b3fa798b0cbce7cc46c1 to your computer and use it in GitHub Desktop.
Install JetBrains UpSource + Nginx
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 | |
| apt-get install mc htop git subversion unzip wget curl -y | |
| echo | |
| echo "=====================================================" | |
| echo " WELCOME" | |
| echo "=====================================================" | |
| echo | |
| echo "Upsource" | |
| echo "download https://www.jetbrains.com/upsource/download/" | |
| echo "read the first https://www.jetbrains.com/upsource/help/2.0/prerequisites.html" | |
| echo "install into /usr/jetbrains/upsource/" | |
| echo "=====================================" | |
| echo | |
| echo "===================================" | |
| echo "In order to continue installing need set a few properties for nginx:" | |
| base_domain=127.0.0.1 | |
| us_domain=127.0.0.1 | |
| us_port=8090 | |
| echo -n "Cron email: " | |
| read cron_email | |
| print_params() { | |
| echo "=================" | |
| echo | |
| echo "Base domain url: $base_domain" | |
| echo "Upsource domain url: $us_domain" | |
| echo "Upsource port: $us_port" | |
| echo "Cron email: $cron_email" | |
| echo | |
| echo "=================" | |
| } | |
| print_params | |
| echo -n "Do you want to continue? [Y|n]" | |
| read type | |
| if [ "$type" == "n" ]; then | |
| exit 0 | |
| fi | |
| code=`lsb_release -a | grep Codename | sed 's/[[:space:]]//g' | cut -f2 -d:` | |
| echo | |
| echo "debian codename:" | |
| echo "$code" | |
| echo | |
| mkdir -p /var/tmp | |
| cd /var/tmp | |
| echo | |
| echo "Installing Java JDK 1.8" | |
| echo | |
| if [ "$code" != "jessie" ]; then | |
| echo "from oracle site" | |
| echo | |
| url=http://download.oracle.com/otn-pub/java/jdk/8u60-b27/ | |
| java_version=jdk-8u60-linux-x64.tar.gz | |
| wget -c -O "$java_version" --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "$url$java_version" | |
| mkdir -p /opt/jdk | |
| tar -zxf $java_version -C /opt/jdk | |
| update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_60/bin/java 100 | |
| update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_60/bin/javac 100 | |
| else | |
| apt-get install java8-jdk -y | |
| fi; | |
| echo | |
| java -version | |
| update-alternatives --display java | |
| javac -version | |
| update-alternatives --display javac | |
| echo | |
| mkdir -p /usr/jetbrains | |
| wget http://download-cf.jetbrains.com/upsource/upsource-3.0.4346.zip -O /usr/jetbrains/us_arch.zip | |
| unzip us_arch.zip | |
| mv upsource-* upsource | |
| chmod +x -R upsource/ | |
| cd ~ | |
| make_initd() { | |
| echo "making init.d for $1" | |
| rq="hub " | |
| 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 | |
| update-rc.d $1 disable | |
| } | |
| echo | |
| make_initd upsource | |
| echo | |
| echo "configure nginx" | |
| apt-get update | |
| apt-get install -t $code-backports nginx -y | |
| cat >./default<<EOF | |
| server { | |
| listen 80; | |
| listen [::]:80; | |
| server_name $us_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_set_header Upgrade \$http_upgrade; | |
| proxy_set_header Connection "upgrade"; | |
| proxy_pass http://localhost:$us_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 | |
| service upsource 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 upsource stop | |
| /usr/jetbrains/upsource/bin/upsource.sh configure --listen-port $us_port --base-url http://$us_domain | |
| service upsource start | |
| echo "goto setup" | |
| echo $us_domain |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment