Change init

This commit is contained in:
Bob Mottram 2015-03-18 20:58:01 +00:00
parent 7a743baccd
commit 4ad98efbff
1 changed files with 11 additions and 101 deletions

View File

@ -6658,9 +6658,12 @@ function install_gogs {
fi
# http://gogs.io/docs/installation/install_from_source.md
# add a gogs user account
adduser --disabled-login --gecos 'Gogs' git
# install Go
apt-get -y install golang
export GOPATH=/etc/gocode
export GOPATH=/home/git/go
if [ ! -d $GOPATH ]; then
mkdir -p $GOPATH
fi
@ -6669,9 +6672,6 @@ function install_gogs {
exit 479832
fi
# add a gogs user account
adduser --disabled-login --gecos 'Gogs' git
# clone the repo
if [ ! -d $GOPATH/src/github.com/gogits ]; then
mkdir -p $GOPATH/src/github.com/gogits
@ -6713,106 +6713,18 @@ quit" > $INSTALL_DIR/batch.sql
mysql -u root --password="$MARIADB_PASSWORD" < $INSTALL_DIR/batch.sql
shred -zu $INSTALL_DIR/batch.sql
echo '#! /bin/sh' > /etc/init.d/gogs
echo '### BEGIN INIT INFO' >> /etc/init.d/gogs
echo '# Provides: gogs' >> /etc/init.d/gogs
echo '# Required-Start: $syslog $network' >> /etc/init.d/gogs
echo '# Required-Stop: $syslog' >> /etc/init.d/gogs
echo '# Default-Start: 2 3 4 5' >> /etc/init.d/gogs
echo '# Default-Stop: 0 1 6' >> /etc/init.d/gogs
echo '# Short-Description: A self-hosted Git service written in Go.' >> /etc/init.d/gogs
echo '# Description: A self-hosted Git service written in Go.' >> /etc/init.d/gogs
echo '### END INIT INFO' >> /etc/init.d/gogs
echo '# Author: Danny Boisvert' >> /etc/init.d/gogs
echo '' >> /etc/init.d/gogs
echo '# PATH should only include /usr/* if it runs after the mountnfs.sh script' >> /etc/init.d/gogs
echo 'PATH=/sbin:/usr/sbin:/bin:/usr/bin;' >> /etc/init.d/gogs
echo 'DESC="Go Git Service";' >> /etc/init.d/gogs
echo 'NAME=gogs' >> /etc/init.d/gogs
echo 'SERVICEVERBOSE=yes' >> /etc/init.d/gogs
echo 'PIDFILE=/var/run/$NAME.pid' >> /etc/init.d/gogs
echo 'SCRIPTNAME=/etc/init.d/$NAME' >> /etc/init.d/gogs
echo "WORKINGDIR=/etc/gocode/src/github.com/gogits" >> /etc/init.d/gogs
echo 'DAEMON=$WORKINGDIR/$NAME' >> /etc/init.d/gogs
echo 'DAEMON_ARGS="web"' >> /etc/init.d/gogs
echo 'USER=git' >> /etc/init.d/gogs
echo '' >> /etc/init.d/gogs
echo '# Read configuration variable file if it is present' >> /etc/init.d/gogs
echo '[ -r /etc/default/$NAME ] && . /etc/default/$NAME' >> /etc/init.d/gogs
echo '# Exit if the package is not installed' >> /etc/init.d/gogs
echo '[ -x "$DAEMON" ] || exit 0' >> /etc/init.d/gogs
echo '# Load the VERBOSE setting and other rcS variables' >> /etc/init.d/gogs
echo '. /lib/init/vars.sh' >> /etc/init.d/gogs
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
echo '. /lib/lsb/init-functions' >> /etc/init.d/gogs
echo '' >> /etc/init.d/gogs
echo '# Function that starts the daemon/service' >> /etc/init.d/gogs
echo 'do_start() {' >> /etc/init.d/gogs
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
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
echo '}' >> /etc/init.d/gogs
echo '' >> /etc/init.d/gogs
echo '# Function that stops the daemon/service' >> /etc/init.d/gogs
echo 'do_stop() {' >> /etc/init.d/gogs
echo ' start-stop-daemon --stop --quiet --retry=TERM/1/KILL/5 --pidfile $PIDFILE --name $NAME' >> /etc/init.d/gogs
echo ' RETVAL="$?"' >> /etc/init.d/gogs
echo ' [ "$RETVAL" = 2 ] && return 2' >> /etc/init.d/gogs
echo ' start-stop-daemon --stop --quiet --oknodo --retry=0/1/KILL/5 --exec $DAEMON' >> /etc/init.d/gogs
echo ' [ "$?" = 2 ] && return 2' >> /etc/init.d/gogs
echo ' # Many daemons dont delete their pidfiles when they exit.' >> /etc/init.d/gogs
echo ' rm -f $PIDFILE' >> /etc/init.d/gogs
echo ' return "$RETVAL"' >> /etc/init.d/gogs
echo '}' >> /etc/init.d/gogs
echo '' >> /etc/init.d/gogs
echo 'case "$1" in' >> /etc/init.d/gogs
echo ' start)' >> /etc/init.d/gogs
echo ' [ "$SERVICEVERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"' >> /etc/init.d/gogs
echo ' do_start' >> /etc/init.d/gogs
echo ' case "$?" in' >> /etc/init.d/gogs
echo ' 0|1) [ "$SERVICEVERBOSE" != no ] && log_end_msg 0 ;;' >> /etc/init.d/gogs
echo ' 2) [ "$SERVICEVERBOSE" != no ] && log_end_msg 1 ;;' >> /etc/init.d/gogs
echo ' esac' >> /etc/init.d/gogs
echo ' ;;' >> /etc/init.d/gogs
echo ' stop)' >> /etc/init.d/gogs
echo ' [ "$SERVICEVERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"' >> /etc/init.d/gogs
echo ' do_stop' >> /etc/init.d/gogs
echo ' case "$?" in' >> /etc/init.d/gogs
echo ' 0|1) [ "$SERVICEVERBOSE" != no ] && log_end_msg 0 ;;' >> /etc/init.d/gogs
echo ' 2) [ "$SERVICEVERBOSE" != no ] && log_end_msg 1 ;;' >> /etc/init.d/gogs
echo ' esac' >> /etc/init.d/gogs
echo ' ;;' >> /etc/init.d/gogs
echo ' status)' >> /etc/init.d/gogs
echo ' status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?' >> /etc/init.d/gogs
echo ' ;;' >> /etc/init.d/gogs
echo ' restart|force-reload)' >> /etc/init.d/gogs
echo ' log_daemon_msg "Restarting $DESC" "$NAME"' >> /etc/init.d/gogs
echo ' do_stop' >> /etc/init.d/gogs
echo ' case "$?" in' >> /etc/init.d/gogs
echo ' 0|1)' >> /etc/init.d/gogs
echo ' do_start' >> /etc/init.d/gogs
echo ' case "$?" in' >> /etc/init.d/gogs
echo ' 0) log_end_msg 0 ;;' >> /etc/init.d/gogs
echo ' *) log_end_msg 1 ;;' >> /etc/init.d/gogs
echo ' esac' >> /etc/init.d/gogs
echo ' ;;' >> /etc/init.d/gogs
echo ' *)' >> /etc/init.d/gogs
echo ' # Failed to stop' >> /etc/init.d/gogs
echo ' log_end_msg 1' >> /etc/init.d/gogs
echo ' ;;' >> /etc/init.d/gogs
echo ' esac' >> /etc/init.d/gogs
echo ' ;;' >> /etc/init.d/gogs
echo ' *)' >> /etc/init.d/gogs
echo ' echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2' >> /etc/init.d/gogs
echo ' exit 3' >> /etc/init.d/gogs
echo ' ;;' >> /etc/init.d/gogs
echo 'esac' >> /etc/init.d/gogs
echo ':' >> /etc/init.d/gogs
cp $GOPATH/src/github.com/gogits/gogs/scripts/init/debian/gogs /etc/init.d/
sed -i 's/# Required-Start: $syslog $network/# Required-Start: $syslog $network $local_fs nginx/g' /etc/init.d/gogs
sed -i 's/# Required-Stop: $syslog/# Required-Stop: $syslog $local_fs/g' /etc/init.d/gogs
sed -i 's|WORKINGDIR=*|WORKINGDIR=/home/git/go/src/github.com/gogits/gogs|g' /etc/init.d/gogs
chown git:git /etc/init.d/gogs
chown -R git:git /home/git
chmod +x /etc/init.d/gogs
update-rc.d gogs defaults
service gogs start
systemctl daemon-reload
if [ ! -d /var/www/$GIT_DOMAIN_NAME ]; then
mkdir /var/www/$GIT_DOMAIN_NAME
fi
@ -6820,8 +6732,6 @@ quit" > $INSTALL_DIR/batch.sql
rm -rf /var/www/$GIT_DOMAIN_NAME/htdocs
fi
ln -s $GOPATH/src/github.com/gogits/gogs /var/www/$GIT_DOMAIN_NAME/htdocs
echo 'server {' > /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo ' listen 80;' >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME
echo " server_name $GIT_DOMAIN_NAME;" >> /etc/nginx/sites-available/$GIT_DOMAIN_NAME