From 1aee261aae74881f65a1152f6fa57bc160adaa16 Mon Sep 17 00:00:00 2001 From: Lauris BH Date: Tue, 5 Jun 2018 05:02:04 +0300 Subject: [PATCH] More detailed documentation on how to set up from binary (#4121) * More detailed documentation on how to set up from binary Also change recommended file locations --- contrib/init/centos/gitea | 10 ++-- contrib/init/debian/gitea | 17 +++--- contrib/init/freebsd/gitea | 5 +- contrib/init/gentoo/gitea | 6 +-- contrib/init/openbsd/gitea | 6 +-- contrib/init/suse/gitea | 8 +-- contrib/systemd/gitea.service | 6 +-- .../doc/installation/from-binary.en-us.md | 52 ++++++++++++++++++- 8 files changed, 81 insertions(+), 29 deletions(-) diff --git a/contrib/init/centos/gitea b/contrib/init/centos/gitea index c24fc1f01..4f0d0d99b 100644 --- a/contrib/init/centos/gitea +++ b/contrib/init/centos/gitea @@ -24,8 +24,8 @@ # Default values NAME=gitea -GITEA_HOME=/home/git/gitea -GITEA_PATH=${GITEA_HOME}/$NAME +GITEA_HOME=/var/lib/${NAME} +GITEA_PATH=/usr/local/bin/${NAME} GITEA_USER=git SERVICENAME="Gitea - Git with a cup of tea" LOCKFILE=/var/lock/subsys/gitea @@ -49,11 +49,11 @@ DAEMON_OPTS="--check $NAME" start() { cd ${GITEA_HOME} echo -n "Starting ${SERVICENAME}: " - daemon $DAEMON_OPTS "${GITEA_PATH} web > ${LOGFILE} 2>&1 &" + daemon $DAEMON_OPTS "${GITEA_PATH} web -c /etc/${NAME}/app.ini > ${LOGFILE} 2>&1 &" RETVAL=$? echo [ $RETVAL = 0 ] && touch ${LOCKFILE} - + return $RETVAL } @@ -63,7 +63,7 @@ stop() { killproc ${NAME} RETVAL=$? echo - [ $RETVAL = 0 ] && rm -f ${LOCKFILE} + [ $RETVAL = 0 ] && rm -f ${LOCKFILE} } case "$1" in diff --git a/contrib/init/debian/gitea b/contrib/init/debian/gitea index 1a371ba4a..b7911f106 100644 --- a/contrib/init/debian/gitea +++ b/contrib/init/debian/gitea @@ -14,17 +14,20 @@ # Do NOT "set -e" # PATH should only include /usr/* if it runs after the mountnfs.sh script -PATH=/sbin:/usr/sbin:/bin:/usr/bin -DESC="Git with a cup of tea" +PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin +DESC="Gitea - Git with a cup of tea" NAME=gitea SERVICEVERBOSE=yes PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME -WORKINGDIR=/home/git/gitea -DAEMON=$WORKINGDIR/$NAME -DAEMON_ARGS="web" +WORKINGDIR=/var/lib/$NAME +DAEMON=/usr/local/bin/$NAME +DAEMON_ARGS="web -c /etc/$NAME/app.ini" USER=git -USERBIND="setcap cap_net_bind_service=+ep" +USERBIND="" +# If you want to bind Gitea to a port below 1024 uncomment +# the line below +#USERBIND="setcap cap_net_bind_service=+ep" STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/1/KILL/5}" # Read configuration variable file if it is present @@ -36,7 +39,7 @@ STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/1/KILL/5}" do_start() { $USERBIND $DAEMON - sh -c "USER=$USER start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \\ + sh -c "USER=$USER HOME=/home/$USER GITEA_WORK_DIR=$WORKINGDIR start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \\ --background --chdir $WORKINGDIR --chuid $USER \\ --exec $DAEMON -- $DAEMON_ARGS" } diff --git a/contrib/init/freebsd/gitea b/contrib/init/freebsd/gitea index 898606f35..2c034ce12 100644 --- a/contrib/init/freebsd/gitea +++ b/contrib/init/freebsd/gitea @@ -19,9 +19,9 @@ load_rc_config $name : ${gitea_user:="git"} : ${gitea_enable:="NO"} -: ${gitea_directory:="/home/git"} +: ${gitea_directory:="/var/lib/gitea"} -command="${gitea_directory}/gitea web" +command="/usr/local/bin/gitea web -c /etc/gitea/app.ini" procname="$(echo $command |cut -d' ' -f1)" pidfile="${gitea_directory}/${name}.pid" @@ -33,6 +33,7 @@ gitea_start() { cd ${gitea_directory} export USER=${gitea_user} export HOME=/usr/home/${gitea_user} + export GITEA_WORK_DIR=${gitea_directory} /usr/sbin/daemon -f -u ${gitea_user} -p ${pidfile} $command } diff --git a/contrib/init/gentoo/gitea b/contrib/init/gentoo/gitea index d8c150d41..c40fc93f5 100644 --- a/contrib/init/gentoo/gitea +++ b/contrib/init/gentoo/gitea @@ -1,11 +1,11 @@ #!/sbin/openrc-run -DIR=/home/git/gitea +DIR=/var/lib/gitea USER=git start_stop_daemon_args="--user ${USER} --chdir ${DIR}" -command="${DIR}/gitea" -command_args="web" +command="/usr/local/bin/gitea" +command_args="web -c /etc/gitea/app.ini" command_background=yes pidfile=/var/run/gitea.pid diff --git a/contrib/init/openbsd/gitea b/contrib/init/openbsd/gitea index c43190b55..89d4f6803 100755 --- a/contrib/init/openbsd/gitea +++ b/contrib/init/openbsd/gitea @@ -2,11 +2,11 @@ # # $OpenBSD$ -daemon="/home/git/gitea/gitea" +daemon="/usr/local/bin/gitea" daemon_user="git" -daemon_flags="web" +daemon_flags="web -c /etc/gitea/app.ini" -gitea_directory="/home/git/gitea" +gitea_directory="/var/lib/gitea" rc_bg=YES diff --git a/contrib/init/suse/gitea b/contrib/init/suse/gitea index 77fb6689c..23178583f 100644 --- a/contrib/init/suse/gitea +++ b/contrib/init/suse/gitea @@ -18,10 +18,10 @@ # Default values NAME=gitea -GITEA_HOME=/home/git/gitea -GITEA_PATH=${GITEA_HOME}/$NAME +GITEA_HOME=/var/lib/$NAME +GITEA_PATH=/usr/local/bin/$NAME GITEA_USER=git -SERVICENAME="Git - with a cup of tea" +SERVICENAME="Gitea - Git with a cup of tea" LOCKFILE=/var/lock/subsys/gitea LOGPATH=${GITEA_HOME}/log LOGFILE=${LOGPATH}/error.log @@ -58,7 +58,7 @@ case "$1" in # return skipped as service is already running (exit 5) else - su - ${GITEA_USER} -c "USER=${GITEA_USER} ${GITEA_PATH} web 2>&1 >>${LOGFILE} &" + su - ${GITEA_USER} -c "USER=${GITEA_USER} GITEA_WORK_DIR=${GITEA_HOME} ${GITEA_PATH} web -c /etc/${NAME}/app.ini 2>&1 >>${LOGFILE} &" fi # Remember status and be verbose diff --git a/contrib/systemd/gitea.service b/contrib/systemd/gitea.service index 8c627e7b5..387de14fa 100644 --- a/contrib/systemd/gitea.service +++ b/contrib/systemd/gitea.service @@ -18,10 +18,10 @@ RestartSec=2s Type=simple User=git Group=git -WorkingDirectory=/home/git/gitea -ExecStart=/home/git/gitea/gitea web +WorkingDirectory=/var/lib/gitea/ +ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.ini Restart=always -Environment=USER=git HOME=/home/git +Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea # If you want to bind Gitea to a port below 1024 uncomment # the two values below ### diff --git a/docs/content/doc/installation/from-binary.en-us.md b/docs/content/doc/installation/from-binary.en-us.md index 91f81f73f..9c8859215 100644 --- a/docs/content/doc/installation/from-binary.en-us.md +++ b/docs/content/doc/installation/from-binary.en-us.md @@ -20,8 +20,8 @@ embedded assets. This can be different for older releases. Choose the file match the destination platform from the [downloads page](https://dl.gitea.io/gitea), copy the URL and replace the URL within the commands below: -``` -wget -O gitea https://dl.gitea.io/gitea/1.3.2/gitea-1.3.2-linux-amd64 +```sh +wget -O gitea https://dl.gitea.io/gitea/1.4.2/gitea-1.4.2-linux-amd64 chmod +x gitea ``` @@ -34,6 +34,54 @@ location. When launched manually, Gitea can be killed using `Ctrl+C`. ./gitea web ``` +## Recommended server configuration + +### Prepare environment + +Check that git is installed on the server, if it is not install it first. +```sh +git --version +``` + +Create user to run gitea (ex. `git`) +```sh +adduser \ + --system \ + --shell /bin/bash \ + --gecos 'Git Version Control' \ + --group \ + --disabled-password \ + --home /home/git \ + git +``` + +### Create required directory structure + +```sh +mkdir -p /var/lib/gitea/{custom,data,indexers,public,log} +chown git:git /var/lib/gitea/{data,indexers,log} +chmod 750 /var/lib/gitea/{data,indexers,log} +mkdir /etc/gitea +chown root:git /etc/gitea +chmod 770 /etc/gitea +``` + +**NOTE:** `/etc/gitea` is temporary set with write rights for user `git` so that Web installer could write configuration file. After installation is done it is recommended to set rights to read-only using: +``` +chmod 750 /etc/gitea +chmod 644 /etc/gitea/app.ini +``` + +### Copy gitea binary to global location + +``` +cp gitea /usr/local/bin/gitea +``` + +### Create service file to start gitea automatically + +See how to create [Linux service]({{< relref "run-as-service-in-ubuntu.en-us.md" >}}) + ## Troubleshooting ### Old glibc versions