* More detailed documentation on how to set up from binary Also change recommended file locationstags/v1.21.12.1
| @@ -24,8 +24,8 @@ | |||||
| # Default values | # Default values | ||||
| NAME=gitea | 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 | GITEA_USER=git | ||||
| SERVICENAME="Gitea - Git with a cup of tea" | SERVICENAME="Gitea - Git with a cup of tea" | ||||
| LOCKFILE=/var/lock/subsys/gitea | LOCKFILE=/var/lock/subsys/gitea | ||||
| @@ -49,11 +49,11 @@ DAEMON_OPTS="--check $NAME" | |||||
| start() { | start() { | ||||
| cd ${GITEA_HOME} | cd ${GITEA_HOME} | ||||
| echo -n "Starting ${SERVICENAME}: " | 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=$? | RETVAL=$? | ||||
| echo | echo | ||||
| [ $RETVAL = 0 ] && touch ${LOCKFILE} | [ $RETVAL = 0 ] && touch ${LOCKFILE} | ||||
| return $RETVAL | return $RETVAL | ||||
| } | } | ||||
| @@ -63,7 +63,7 @@ stop() { | |||||
| killproc ${NAME} | killproc ${NAME} | ||||
| RETVAL=$? | RETVAL=$? | ||||
| echo | echo | ||||
| [ $RETVAL = 0 ] && rm -f ${LOCKFILE} | |||||
| [ $RETVAL = 0 ] && rm -f ${LOCKFILE} | |||||
| } | } | ||||
| case "$1" in | case "$1" in | ||||
| @@ -14,17 +14,20 @@ | |||||
| # Do NOT "set -e" | # Do NOT "set -e" | ||||
| # PATH should only include /usr/* if it runs after the mountnfs.sh script | # 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 | NAME=gitea | ||||
| SERVICEVERBOSE=yes | SERVICEVERBOSE=yes | ||||
| PIDFILE=/var/run/$NAME.pid | PIDFILE=/var/run/$NAME.pid | ||||
| SCRIPTNAME=/etc/init.d/$NAME | 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 | 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}" | STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/1/KILL/5}" | ||||
| # Read configuration variable file if it is present | # Read configuration variable file if it is present | ||||
| @@ -36,7 +39,7 @@ STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/1/KILL/5}" | |||||
| do_start() | do_start() | ||||
| { | { | ||||
| $USERBIND $DAEMON | $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 \\ | --background --chdir $WORKINGDIR --chuid $USER \\ | ||||
| --exec $DAEMON -- $DAEMON_ARGS" | --exec $DAEMON -- $DAEMON_ARGS" | ||||
| } | } | ||||
| @@ -19,9 +19,9 @@ load_rc_config $name | |||||
| : ${gitea_user:="git"} | : ${gitea_user:="git"} | ||||
| : ${gitea_enable:="NO"} | : ${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)" | procname="$(echo $command |cut -d' ' -f1)" | ||||
| pidfile="${gitea_directory}/${name}.pid" | pidfile="${gitea_directory}/${name}.pid" | ||||
| @@ -33,6 +33,7 @@ gitea_start() { | |||||
| cd ${gitea_directory} | cd ${gitea_directory} | ||||
| export USER=${gitea_user} | export USER=${gitea_user} | ||||
| export HOME=/usr/home/${gitea_user} | export HOME=/usr/home/${gitea_user} | ||||
| export GITEA_WORK_DIR=${gitea_directory} | |||||
| /usr/sbin/daemon -f -u ${gitea_user} -p ${pidfile} $command | /usr/sbin/daemon -f -u ${gitea_user} -p ${pidfile} $command | ||||
| } | } | ||||
| @@ -1,11 +1,11 @@ | |||||
| #!/sbin/openrc-run | #!/sbin/openrc-run | ||||
| DIR=/home/git/gitea | |||||
| DIR=/var/lib/gitea | |||||
| USER=git | USER=git | ||||
| start_stop_daemon_args="--user ${USER} --chdir ${DIR}" | 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 | command_background=yes | ||||
| pidfile=/var/run/gitea.pid | pidfile=/var/run/gitea.pid | ||||
| @@ -2,11 +2,11 @@ | |||||
| # | # | ||||
| # $OpenBSD$ | # $OpenBSD$ | ||||
| daemon="/home/git/gitea/gitea" | |||||
| daemon="/usr/local/bin/gitea" | |||||
| daemon_user="git" | 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 | rc_bg=YES | ||||
| @@ -18,10 +18,10 @@ | |||||
| # Default values | # Default values | ||||
| NAME=gitea | 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 | GITEA_USER=git | ||||
| SERVICENAME="Git - with a cup of tea" | |||||
| SERVICENAME="Gitea - Git with a cup of tea" | |||||
| LOCKFILE=/var/lock/subsys/gitea | LOCKFILE=/var/lock/subsys/gitea | ||||
| LOGPATH=${GITEA_HOME}/log | LOGPATH=${GITEA_HOME}/log | ||||
| LOGFILE=${LOGPATH}/error.log | LOGFILE=${LOGPATH}/error.log | ||||
| @@ -58,7 +58,7 @@ case "$1" in | |||||
| # return skipped as service is already running | # return skipped as service is already running | ||||
| (exit 5) | (exit 5) | ||||
| else | 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 | fi | ||||
| # Remember status and be verbose | # Remember status and be verbose | ||||
| @@ -18,10 +18,10 @@ RestartSec=2s | |||||
| Type=simple | Type=simple | ||||
| User=git | User=git | ||||
| Group=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 | 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 | # If you want to bind Gitea to a port below 1024 uncomment | ||||
| # the two values below | # the two values below | ||||
| ### | ### | ||||
| @@ -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 destination platform from the [downloads page](https://dl.gitea.io/gitea), copy | ||||
| the URL and replace the URL within the commands below: | 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 | chmod +x gitea | ||||
| ``` | ``` | ||||
| @@ -34,6 +34,54 @@ location. When launched manually, Gitea can be killed using `Ctrl+C`. | |||||
| ./gitea web | ./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 | ## Troubleshooting | ||||
| ### Old glibc versions | ### Old glibc versions | ||||