|
@@ -6471,6 +6471,214 @@ quit" > $INSTALL_DIR/batch.sql
|
6471
|
6471
|
fi
|
6472
|
6472
|
}
|
6473
|
6473
|
|
|
6474
|
+function install_gogs {
|
|
6475
|
+ if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_CHAT" ]]; then
|
|
6476
|
+ return
|
|
6477
|
+ fi
|
|
6478
|
+ if grep -Fxq "install_gogs" $COMPLETION_FILE; then
|
|
6479
|
+ return
|
|
6480
|
+ fi
|
|
6481
|
+ # http://gogs.io/docs/installation/install_from_source.md
|
|
6482
|
+
|
|
6483
|
+ # install Go
|
|
6484
|
+ apt-get -y install golang
|
|
6485
|
+ export GOPATH=/etc/gocode
|
|
6486
|
+ if [ ! -d $GOPATH ]; then
|
|
6487
|
+ mkdir -p $GOPATH
|
|
6488
|
+ fi
|
|
6489
|
+ go get -u github.com/gpmgo/gopm
|
|
6490
|
+
|
|
6491
|
+ # add a gogs user account
|
|
6492
|
+ sudo adduser --disabled-login --gecos 'Gogs' git
|
|
6493
|
+
|
|
6494
|
+ # clone the repo
|
|
6495
|
+ mkdir -p $GOPATH/src/github.com/gogits
|
|
6496
|
+ cd $GOPATH/src/github.com/gogits
|
|
6497
|
+ git clone https://github.com/gogits/gogs.git
|
|
6498
|
+ cd gogs
|
|
6499
|
+
|
|
6500
|
+ # install
|
|
6501
|
+ go get ./...
|
|
6502
|
+ go build
|
|
6503
|
+
|
|
6504
|
+ echo '#! /bin/sh' > /etc/init.d/gogs
|
|
6505
|
+ echo '### BEGIN INIT INFO' >> /etc/init.d/gogs
|
|
6506
|
+ echo '# Provides: gogs' >> /etc/init.d/gogs
|
|
6507
|
+ echo '# Required-Start: $syslog $network' >> /etc/init.d/gogs
|
|
6508
|
+ echo '# Required-Stop: $syslog' >> /etc/init.d/gogs
|
|
6509
|
+ echo '# Default-Start: 2 3 4 5' >> /etc/init.d/gogs
|
|
6510
|
+ echo '# Default-Stop: 0 1 6' >> /etc/init.d/gogs
|
|
6511
|
+ echo '# Short-Description: A self-hosted Git service written in Go.' >> /etc/init.d/gogs
|
|
6512
|
+ echo '# Description: A self-hosted Git service written in Go.' >> /etc/init.d/gogs
|
|
6513
|
+ echo '### END INIT INFO' >> /etc/init.d/gogs
|
|
6514
|
+ echo '# Author: Danny Boisvert' >> /etc/init.d/gogs
|
|
6515
|
+ echo '' >> /etc/init.d/gogs
|
|
6516
|
+ echo '# PATH should only include /usr/* if it runs after the mountnfs.sh script' >> /etc/init.d/gogs
|
|
6517
|
+ echo 'PATH=/sbin:/usr/sbin:/bin:/usr/bin;' >> /etc/init.d/gogs
|
|
6518
|
+ echo 'DESC="Go Git Service";' >> /etc/init.d/gogs
|
|
6519
|
+ echo 'NAME=gogs' >> /etc/init.d/gogs
|
|
6520
|
+ echo 'SERVICEVERBOSE=yes' >> /etc/init.d/gogs
|
|
6521
|
+ echo 'PIDFILE=/var/run/$NAME.pid' >> /etc/init.d/gogs
|
|
6522
|
+ echo 'SCRIPTNAME=/etc/init.d/$NAME' >> /etc/init.d/gogs
|
|
6523
|
+ echo "WORKINGDIR=/etc/gocode/src/github.com/gogits" >> /etc/init.d/gogs
|
|
6524
|
+ echo 'DAEMON=$WORKINGDIR/$NAME' >> /etc/init.d/gogs
|
|
6525
|
+ echo 'DAEMON_ARGS="web"' >> /etc/init.d/gogs
|
|
6526
|
+ echo 'USER=git' >> /etc/init.d/gogs
|
|
6527
|
+ echo '' >> /etc/init.d/gogs
|
|
6528
|
+ echo '# Read configuration variable file if it is present' >> /etc/init.d/gogs
|
|
6529
|
+ echo '[ -r /etc/default/$NAME ] && . /etc/default/$NAME' >> /etc/init.d/gogs
|
|
6530
|
+ echo '# Exit if the package is not installed' >> /etc/init.d/gogs
|
|
6531
|
+ echo '[ -x "$DAEMON" ] || exit 0' >> /etc/init.d/gogs
|
|
6532
|
+ echo '# Load the VERBOSE setting and other rcS variables' >> /etc/init.d/gogs
|
|
6533
|
+ echo '. /lib/init/vars.sh' >> /etc/init.d/gogs
|
|
6534
|
+ echo '# Define LSB log_* functions. Depend on lsb-base (>= 3.2-14) to ensure that this file is present and status_of_proc is working.' >> /etc/init.d/gogs
|
|
6535
|
+ echo '. /lib/lsb/init-functions' >> /etc/init.d/gogs
|
|
6536
|
+ echo '' >> /etc/init.d/gogs
|
|
6537
|
+ echo '# Function that starts the daemon/service' >> /etc/init.d/gogs
|
|
6538
|
+ echo 'do_start() {' >> /etc/init.d/gogs
|
|
6539
|
+ echo 'sh -c "start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --test --exec /bin/sh -- - $USER -c \"cd \\\"$WORKINGDIR\\\" && $DAEMON -- $DAEMON_ARGS\" > /dev/null || return 1"' >> /etc/init.d/gogs
|
|
6540
|
+ echo 'sh -c "start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec /bin/su -- - $USER -c \"cd \\\"$WORKINGDIR\\\" && $DAEMON -- $DAEMON_ARGS\" || return 2"' >> /etc/init.d/gogs
|
|
6541
|
+ echo '}' >> /etc/init.d/gogs
|
|
6542
|
+ echo '' >> /etc/init.d/gogs
|
|
6543
|
+ echo '# Function that stops the daemon/service' >> /etc/init.d/gogs
|
|
6544
|
+ echo 'do_stop() {' >> /etc/init.d/gogs
|
|
6545
|
+ echo ' start-stop-daemon --stop --quiet --retry=TERM/1/KILL/5 --pidfile $PIDFILE --name $NAME' >> /etc/init.d/gogs
|
|
6546
|
+ echo ' RETVAL="$?"' >> /etc/init.d/gogs
|
|
6547
|
+ echo ' [ "$RETVAL" = 2 ] && return 2' >> /etc/init.d/gogs
|
|
6548
|
+ echo ' start-stop-daemon --stop --quiet --oknodo --retry=0/1/KILL/5 --exec $DAEMON' >> /etc/init.d/gogs
|
|
6549
|
+ echo ' [ "$?" = 2 ] && return 2' >> /etc/init.d/gogs
|
|
6550
|
+ echo ' # Many daemons dont delete their pidfiles when they exit.' >> /etc/init.d/gogs
|
|
6551
|
+ echo ' rm -f $PIDFILE' >> /etc/init.d/gogs
|
|
6552
|
+ echo ' return "$RETVAL"' >> /etc/init.d/gogs
|
|
6553
|
+ echo '}' >> /etc/init.d/gogs
|
|
6554
|
+ echo '' >> /etc/init.d/gogs
|
|
6555
|
+ echo 'case "$1" in' >> /etc/init.d/gogs
|
|
6556
|
+ echo ' start)' >> /etc/init.d/gogs
|
|
6557
|
+ echo ' [ "$SERVICEVERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"' >> /etc/init.d/gogs
|
|
6558
|
+ echo ' do_start' >> /etc/init.d/gogs
|
|
6559
|
+ echo ' case "$?" in' >> /etc/init.d/gogs
|
|
6560
|
+ echo ' 0|1) [ "$SERVICEVERBOSE" != no ] && log_end_msg 0 ;;' >> /etc/init.d/gogs
|
|
6561
|
+ echo ' 2) [ "$SERVICEVERBOSE" != no ] && log_end_msg 1 ;;' >> /etc/init.d/gogs
|
|
6562
|
+ echo ' esac' >> /etc/init.d/gogs
|
|
6563
|
+ echo ' ;;' >> /etc/init.d/gogs
|
|
6564
|
+ echo ' stop)' >> /etc/init.d/gogs
|
|
6565
|
+ echo ' [ "$SERVICEVERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"' >> /etc/init.d/gogs
|
|
6566
|
+ echo ' do_stop' >> /etc/init.d/gogs
|
|
6567
|
+ echo ' case "$?" in' >> /etc/init.d/gogs
|
|
6568
|
+ echo ' 0|1) [ "$SERVICEVERBOSE" != no ] && log_end_msg 0 ;;' >> /etc/init.d/gogs
|
|
6569
|
+ echo ' 2) [ "$SERVICEVERBOSE" != no ] && log_end_msg 1 ;;' >> /etc/init.d/gogs
|
|
6570
|
+ echo ' esac' >> /etc/init.d/gogs
|
|
6571
|
+ echo ' ;;' >> /etc/init.d/gogs
|
|
6572
|
+ echo ' status)' >> /etc/init.d/gogs
|
|
6573
|
+ echo ' status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?' >> /etc/init.d/gogs
|
|
6574
|
+ echo ' ;;' >> /etc/init.d/gogs
|
|
6575
|
+ echo ' restart|force-reload)' >> /etc/init.d/gogs
|
|
6576
|
+ echo ' log_daemon_msg "Restarting $DESC" "$NAME"' >> /etc/init.d/gogs
|
|
6577
|
+ echo ' do_stop' >> /etc/init.d/gogs
|
|
6578
|
+ echo ' case "$?" in' >> /etc/init.d/gogs
|
|
6579
|
+ echo ' 0|1)' >> /etc/init.d/gogs
|
|
6580
|
+ echo ' do_start' >> /etc/init.d/gogs
|
|
6581
|
+ echo ' case "$?" in' >> /etc/init.d/gogs
|
|
6582
|
+ echo ' 0) log_end_msg 0 ;;' >> /etc/init.d/gogs
|
|
6583
|
+ echo ' *) log_end_msg 1 ;;' >> /etc/init.d/gogs
|
|
6584
|
+ echo ' esac' >> /etc/init.d/gogs
|
|
6585
|
+ echo ' ;;' >> /etc/init.d/gogs
|
|
6586
|
+ echo ' *)' >> /etc/init.d/gogs
|
|
6587
|
+ echo ' # Failed to stop' >> /etc/init.d/gogs
|
|
6588
|
+ echo ' log_end_msg 1' >> /etc/init.d/gogs
|
|
6589
|
+ echo ' ;;' >> /etc/init.d/gogs
|
|
6590
|
+ echo ' esac' >> /etc/init.d/gogs
|
|
6591
|
+ echo ' ;;' >> /etc/init.d/gogs
|
|
6592
|
+ echo ' *)' >> /etc/init.d/gogs
|
|
6593
|
+ echo ' echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2' >> /etc/init.d/gogs
|
|
6594
|
+ echo ' exit 3' >> /etc/init.d/gogs
|
|
6595
|
+ echo ' ;;' >> /etc/init.d/gogs
|
|
6596
|
+ echo 'esac' >> /etc/init.d/gogs
|
|
6597
|
+ echo ':' >> /etc/init.d/gogs
|
|
6598
|
+ chmod +x /etc/init.d/gogs
|
|
6599
|
+ update-rc.d gogs defaults
|
|
6600
|
+ service gogs start
|
|
6601
|
+ systemctl daemon-reload
|
|
6602
|
+
|
|
6603
|
+
|
|
6604
|
+ if [ ! -d /var/www/$GIT_DOMAIN_NAME ]; then
|
|
6605
|
+ mkdir /var/www/$GIT_DOMAIN_NAME
|
|
6606
|
+ fi
|
|
6607
|
+ if [ -d /var/www/$GIT_DOMAIN_NAME/htdocs ]; then
|
|
6608
|
+ rm -rf /var/www/$GIT_DOMAIN_NAME/htdocs
|
|
6609
|
+ fi
|
|
6610
|
+
|
|
6611
|
+ ln -s $GOPATH/src/github.com/gogits/gogs /var/www/$GIT_DOMAIN_NAME/htdocs
|
|
6612
|
+
|
|
6613
|
+ echo 'server {' > /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6614
|
+ echo ' listen 80;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6615
|
+ echo " server_name $GIT_DOMAIN_NAME;" >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6616
|
+ echo ' access_log off;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6617
|
+ echo " error_log /var/log/nginx/$GIT_DOMAIN_NAME_error.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6618
|
+ echo ' limit_conn conn_limit_per_ip 10;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6619
|
+ echo ' limit_req zone=req_limit_per_ip burst=10 nodelay;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6620
|
+ echo ' rewrite ^ https://$server_name$request_uri? permanent;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6621
|
+ echo '}' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6622
|
+ echo '' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6623
|
+ echo 'server {' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6624
|
+ echo ' listen 443 ssl;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6625
|
+ echo " root /var/www/$GIT_DOMAIN_NAME/htdocs;" >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6626
|
+ echo " server_name $GIT_DOMAIN_NAME;" >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6627
|
+ echo ' access_log off;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6628
|
+ echo " error_log /var/log/nginx/$GIT_DOMAIN_NAME_error.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6629
|
+ echo '' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6630
|
+ echo ' limit_conn conn_limit_per_ip 10;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6631
|
+ echo ' limit_req zone=req_limit_per_ip burst=10 nodelay;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6632
|
+ echo '' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6633
|
+ echo ' ssl on;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6634
|
+ echo " ssl_certificate /etc/ssl/certs/$GIT_DOMAIN_NAME.crt;" >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6635
|
+ echo " ssl_certificate_key /etc/ssl/private/$GIT_DOMAIN_NAME.key;" >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6636
|
+ echo " ssl_dhparam /etc/ssl/certs/$GIT_DOMAIN_NAME.dhparam;" >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6637
|
+ echo '' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6638
|
+ echo ' ssl_session_timeout 5m;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6639
|
+ echo ' ssl_prefer_server_ciphers on;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6640
|
+ echo " ssl_protocols $SSL_PROTOCOLS; # not possible to do exclusive" >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6641
|
+ echo " ssl_ciphers '$SSL_CIPHERS';" >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6642
|
+ echo ' add_header X-Frame-Options DENY;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6643
|
+ echo ' add_header X-Content-Type-Options nosniff;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6644
|
+ echo ' add_header Strict-Transport-Security max-age=15768000;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6645
|
+ echo '' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6646
|
+ echo ' location / {' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6647
|
+ echo ' proxy_pass http://localhost:3000;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6648
|
+ echo ' }' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6649
|
+ echo '' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6650
|
+ echo ' client_max_body_size 10G; # set max upload size' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6651
|
+ echo ' client_body_buffer_size 128k;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6652
|
+ echo ' fastcgi_buffers 64 4K;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6653
|
+ echo '' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6654
|
+ echo ' error_page 403 /core/templates/403.php;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6655
|
+ echo ' error_page 404 /core/templates/404.php;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6656
|
+ echo '' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6657
|
+ echo ' location = /robots.txt {' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6658
|
+ echo ' allow all;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6659
|
+ echo ' log_not_found off;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6660
|
+ echo ' access_log off;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6661
|
+ echo ' }' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6662
|
+ echo '}' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
|
|
6663
|
+
|
|
6664
|
+ configure_php
|
|
6665
|
+
|
|
6666
|
+ if [ ! -f /etc/ssl/certs/$GIT_DOMAIN_NAME.dhparam ]; then
|
|
6667
|
+ makecert $GIT_DOMAIN_NAME
|
|
6668
|
+ check_certificates $GIT_DOMAIN_NAME
|
|
6669
|
+ fi
|
|
6670
|
+
|
|
6671
|
+ nginx_ensite $GIT_DOMAIN_NAME
|
|
6672
|
+ service php5-fpm restart
|
|
6673
|
+ service nginx restart
|
|
6674
|
+
|
|
6675
|
+ # update the dynamic DNS
|
|
6676
|
+ CURRENT_DDNS_DOMAIN=$GIT_DOMAIN_NAME
|
|
6677
|
+ add_ddns_domain
|
|
6678
|
+
|
|
6679
|
+ echo 'install_gogs' >> $COMPLETION_FILE
|
|
6680
|
+}
|
|
6681
|
+
|
6474
|
6682
|
function install_xmpp {
|
6475
|
6683
|
if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" ]]; then
|
6476
|
6684
|
return
|