Bladeren bron

Change init

Bob Mottram 10 jaren geleden
bovenliggende
commit
4ad98efbff
1 gewijzigde bestanden met toevoegingen van 11 en 101 verwijderingen
  1. 11
    101
      src/freedombone

+ 11
- 101
src/freedombone Bestand weergeven

@@ -6658,9 +6658,12 @@ function install_gogs {
6658 6658
   fi
6659 6659
   # http://gogs.io/docs/installation/install_from_source.md
6660 6660
 
6661
+  # add a gogs user account
6662
+  adduser --disabled-login --gecos 'Gogs' git
6663
+
6661 6664
   # install Go
6662 6665
   apt-get -y install golang
6663
-  export GOPATH=/etc/gocode
6666
+  export GOPATH=/home/git/go
6664 6667
   if [ ! -d $GOPATH ]; then
6665 6668
       mkdir -p $GOPATH
6666 6669
   fi
@@ -6669,9 +6672,6 @@ function install_gogs {
6669 6672
       exit 479832
6670 6673
   fi
6671 6674
 
6672
-  # add a gogs user account
6673
-  adduser --disabled-login --gecos 'Gogs' git
6674
-
6675 6675
   # clone the repo
6676 6676
   if [ ! -d $GOPATH/src/github.com/gogits ]; then
6677 6677
       mkdir -p $GOPATH/src/github.com/gogits
@@ -6713,106 +6713,18 @@ quit" > $INSTALL_DIR/batch.sql
6713 6713
   mysql -u root --password="$MARIADB_PASSWORD" < $INSTALL_DIR/batch.sql
6714 6714
   shred -zu $INSTALL_DIR/batch.sql
6715 6715
 
6716
-  echo '#! /bin/sh' > /etc/init.d/gogs
6717
-  echo '### BEGIN INIT INFO' >> /etc/init.d/gogs
6718
-  echo '# Provides:          gogs' >> /etc/init.d/gogs
6719
-  echo '# Required-Start:    $syslog $network' >> /etc/init.d/gogs
6720
-  echo '# Required-Stop:     $syslog' >> /etc/init.d/gogs
6721
-  echo '# Default-Start:     2 3 4 5' >> /etc/init.d/gogs
6722
-  echo '# Default-Stop:      0 1 6' >> /etc/init.d/gogs
6723
-  echo '# Short-Description: A self-hosted Git service written in Go.' >> /etc/init.d/gogs
6724
-  echo '# Description:       A self-hosted Git service written in Go.' >> /etc/init.d/gogs
6725
-  echo '### END INIT INFO' >> /etc/init.d/gogs
6726
-  echo '# Author: Danny Boisvert' >> /etc/init.d/gogs
6727
-  echo '' >> /etc/init.d/gogs
6728
-  echo '# PATH should only include /usr/* if it runs after the mountnfs.sh script' >> /etc/init.d/gogs
6729
-  echo 'PATH=/sbin:/usr/sbin:/bin:/usr/bin;' >> /etc/init.d/gogs
6730
-  echo 'DESC="Go Git Service";' >> /etc/init.d/gogs
6731
-  echo 'NAME=gogs' >> /etc/init.d/gogs
6732
-  echo 'SERVICEVERBOSE=yes' >> /etc/init.d/gogs
6733
-  echo 'PIDFILE=/var/run/$NAME.pid' >> /etc/init.d/gogs
6734
-  echo 'SCRIPTNAME=/etc/init.d/$NAME' >> /etc/init.d/gogs
6735
-  echo "WORKINGDIR=/etc/gocode/src/github.com/gogits" >> /etc/init.d/gogs
6736
-  echo 'DAEMON=$WORKINGDIR/$NAME' >> /etc/init.d/gogs
6737
-  echo 'DAEMON_ARGS="web"' >> /etc/init.d/gogs
6738
-  echo 'USER=git' >> /etc/init.d/gogs
6739
-  echo '' >> /etc/init.d/gogs
6740
-  echo '# Read configuration variable file if it is present' >> /etc/init.d/gogs
6741
-  echo '[ -r /etc/default/$NAME ] && . /etc/default/$NAME' >> /etc/init.d/gogs
6742
-  echo '# Exit if the package is not installed' >> /etc/init.d/gogs
6743
-  echo '[ -x "$DAEMON" ] || exit 0' >> /etc/init.d/gogs
6744
-  echo '# Load the VERBOSE setting and other rcS variables' >> /etc/init.d/gogs
6745
-  echo '. /lib/init/vars.sh' >> /etc/init.d/gogs
6746
-  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
6747
-  echo '. /lib/lsb/init-functions' >> /etc/init.d/gogs
6748
-  echo '' >> /etc/init.d/gogs
6749
-  echo '# Function that starts the daemon/service' >> /etc/init.d/gogs
6750
-  echo 'do_start() {' >> /etc/init.d/gogs
6751
-  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
6752
-  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
6753
-  echo '}' >> /etc/init.d/gogs
6754
-  echo '' >> /etc/init.d/gogs
6755
-  echo '# Function that stops the daemon/service' >> /etc/init.d/gogs
6756
-  echo 'do_stop() {' >> /etc/init.d/gogs
6757
-  echo '    start-stop-daemon --stop --quiet --retry=TERM/1/KILL/5 --pidfile $PIDFILE --name $NAME' >> /etc/init.d/gogs
6758
-  echo '    RETVAL="$?"' >> /etc/init.d/gogs
6759
-  echo '    [ "$RETVAL" = 2 ] && return 2' >> /etc/init.d/gogs
6760
-  echo '    start-stop-daemon --stop --quiet --oknodo --retry=0/1/KILL/5 --exec $DAEMON' >> /etc/init.d/gogs
6761
-  echo '    [ "$?" = 2 ] && return 2' >> /etc/init.d/gogs
6762
-  echo '    # Many daemons dont delete their pidfiles when they exit.' >> /etc/init.d/gogs
6763
-  echo '    rm -f $PIDFILE' >> /etc/init.d/gogs
6764
-  echo '    return "$RETVAL"' >> /etc/init.d/gogs
6765
-  echo '}' >> /etc/init.d/gogs
6766
-  echo '' >> /etc/init.d/gogs
6767
-  echo 'case "$1" in' >> /etc/init.d/gogs
6768
-  echo '    start)' >> /etc/init.d/gogs
6769
-  echo '        [ "$SERVICEVERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"' >> /etc/init.d/gogs
6770
-  echo '        do_start' >> /etc/init.d/gogs
6771
-  echo '        case "$?" in' >> /etc/init.d/gogs
6772
-  echo '            0|1) [ "$SERVICEVERBOSE" != no ]  && log_end_msg 0 ;;' >> /etc/init.d/gogs
6773
-  echo '            2) [ "$SERVICEVERBOSE" != no ]    && log_end_msg 1 ;;' >> /etc/init.d/gogs
6774
-  echo '        esac' >> /etc/init.d/gogs
6775
-  echo '        ;;' >> /etc/init.d/gogs
6776
-  echo '    stop)' >> /etc/init.d/gogs
6777
-  echo '        [ "$SERVICEVERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"' >> /etc/init.d/gogs
6778
-  echo '        do_stop' >> /etc/init.d/gogs
6779
-  echo '        case "$?" in' >> /etc/init.d/gogs
6780
-  echo '            0|1) [ "$SERVICEVERBOSE" != no ]  && log_end_msg 0 ;;' >> /etc/init.d/gogs
6781
-  echo '            2) [ "$SERVICEVERBOSE" != no ]    && log_end_msg 1 ;;' >> /etc/init.d/gogs
6782
-  echo '        esac' >> /etc/init.d/gogs
6783
-  echo '        ;;' >> /etc/init.d/gogs
6784
-  echo '    status)' >> /etc/init.d/gogs
6785
-  echo '        status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?' >> /etc/init.d/gogs
6786
-  echo '        ;;' >> /etc/init.d/gogs
6787
-  echo '    restart|force-reload)' >> /etc/init.d/gogs
6788
-  echo '        log_daemon_msg "Restarting $DESC" "$NAME"' >> /etc/init.d/gogs
6789
-  echo '        do_stop' >> /etc/init.d/gogs
6790
-  echo '        case "$?" in' >> /etc/init.d/gogs
6791
-  echo '            0|1)' >> /etc/init.d/gogs
6792
-  echo '                do_start' >> /etc/init.d/gogs
6793
-  echo '                case "$?" in' >> /etc/init.d/gogs
6794
-  echo '                    0) log_end_msg 0 ;;' >> /etc/init.d/gogs
6795
-  echo '                    *) log_end_msg 1 ;;' >> /etc/init.d/gogs
6796
-  echo '                esac' >> /etc/init.d/gogs
6797
-  echo '                ;;' >> /etc/init.d/gogs
6798
-  echo '            *)' >> /etc/init.d/gogs
6799
-  echo '                # Failed to stop' >> /etc/init.d/gogs
6800
-  echo '                log_end_msg 1' >> /etc/init.d/gogs
6801
-  echo '                ;;' >> /etc/init.d/gogs
6802
-  echo '        esac' >> /etc/init.d/gogs
6803
-  echo '        ;;' >> /etc/init.d/gogs
6804
-  echo '    *)' >> /etc/init.d/gogs
6805
-  echo '        echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2' >> /etc/init.d/gogs
6806
-  echo '        exit 3' >> /etc/init.d/gogs
6807
-  echo '        ;;' >> /etc/init.d/gogs
6808
-  echo 'esac' >> /etc/init.d/gogs
6809
-  echo ':' >> /etc/init.d/gogs
6716
+  cp $GOPATH/src/github.com/gogits/gogs/scripts/init/debian/gogs /etc/init.d/
6717
+  sed -i 's/# Required-Start:    $syslog $network/# Required-Start:    $syslog $network $local_fs nginx/g' /etc/init.d/gogs
6718
+  sed -i 's/# Required-Stop:     $syslog/# Required-Stop:     $syslog $local_fs/g' /etc/init.d/gogs
6719
+  sed -i 's|WORKINGDIR=*|WORKINGDIR=/home/git/go/src/github.com/gogits/gogs|g' /etc/init.d/gogs
6720
+  chown git:git /etc/init.d/gogs
6721
+  chown -R git:git /home/git
6722
+
6810 6723
   chmod +x /etc/init.d/gogs
6811 6724
   update-rc.d gogs defaults
6812 6725
   service gogs start
6813 6726
   systemctl daemon-reload
6814 6727
 
6815
-
6816 6728
   if [ ! -d /var/www/$GIT_DOMAIN_NAME ]; then
6817 6729
       mkdir /var/www/$GIT_DOMAIN_NAME
6818 6730
   fi
@@ -6820,8 +6732,6 @@ quit" > $INSTALL_DIR/batch.sql
6820 6732
       rm -rf /var/www/$GIT_DOMAIN_NAME/htdocs
6821 6733
   fi
6822 6734
 
6823
-  ln -s $GOPATH/src/github.com/gogits/gogs /var/www/$GIT_DOMAIN_NAME/htdocs
6824
-
6825 6735
   echo 'server {' > /etc/nginx/sites-available/$GIT_DOMAIN_NAME
6826 6736
   echo '    listen 80;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
6827 6737
   echo "    server_name $GIT_DOMAIN_NAME;" >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME