cGit-UI for Git Repositories

cGit-UI – is a web interface for Git Repositories. cGit CGI script is writen in C and therefore it's fast enough

3 Commits   0 Branches   1 Tag
05d292b2 (kx 2023-03-24 03:51:10 +0300   1) 
05d292b2 (kx 2023-03-24 03:51:10 +0300   2) # cGit-UI for Git repositories
05d292b2 (kx 2023-03-24 03:51:10 +0300   3) 
05d292b2 (kx 2023-03-24 03:51:10 +0300   4) **cGit-UI** – is a web interface for Git Repositories. **cGit** CGI script is writen in **C**
05d292b2 (kx 2023-03-24 03:51:10 +0300   5) and therefore it's fast enough.
05d292b2 (kx 2023-03-24 03:51:10 +0300   6) 
05d292b2 (kx 2023-03-24 03:51:10 +0300   7) 
05d292b2 (kx 2023-03-24 03:51:10 +0300   8) ## Table of Contents
05d292b2 (kx 2023-03-24 03:51:10 +0300   9) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  10) * [Reqired packages](#required-packages)
05d292b2 (kx 2023-03-24 03:51:10 +0300  11) * [Installation](#installation)
05d292b2 (kx 2023-03-24 03:51:10 +0300  12)     * [Download Sources](#download-sources)
05d292b2 (kx 2023-03-24 03:51:10 +0300  13)     * [Configuring Sources](#configuring-sources)
05d292b2 (kx 2023-03-24 03:51:10 +0300  14)     * [Post Install](#post-install)
05d292b2 (kx 2023-03-24 03:51:10 +0300  15) * [uWsgi Configuration](#uwsgi)
05d292b2 (kx 2023-03-24 03:51:10 +0300  16) * [Nginx Configuration](#nginx)
05d292b2 (kx 2023-03-24 03:51:10 +0300  17) * [Configuring Git Repositories](#configuring-git-repositories)
05d292b2 (kx 2023-03-24 03:51:10 +0300  18) * [See Also](#see-also)
05d292b2 (kx 2023-03-24 03:51:10 +0300  19) * [Copyright and License](#copyright-and-license)
05d292b2 (kx 2023-03-24 03:51:10 +0300  20) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  21) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  22) ## Required packages
05d292b2 (kx 2023-03-24 03:51:10 +0300  23) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  24) **cGit-ui** depends of following libraries: [libpcre2-8](https://www.pcre.org/),
05d292b2 (kx 2023-03-24 03:51:10 +0300  25) [librt](https://www.gnu.org/software/libc/), [libm](https://www.gnu.org/software/libc/),
05d292b2 (kx 2023-03-24 03:51:10 +0300  26) [libmd4c](https://github.com/mity/md4c/), [libmd4c-html](https://github.com/mity/md4c/),
05d292b2 (kx 2023-03-24 03:51:10 +0300  27) [libmagic](http://darwinsys.com/file/), and [libgit2](https://libgit2.org/).
05d292b2 (kx 2023-03-24 03:51:10 +0300  28) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  29) Also **cGit-ui** depends on the **cScm** package. Therefore, before installing **cGit-ui**,
05d292b2 (kx 2023-03-24 03:51:10 +0300  30) you have to install and configure [**cScm Configuration Daemon**](https://csvn.radix.pro/cscm/trunk/README.md).
05d292b2 (kx 2023-03-24 03:51:10 +0300  31) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  32) To use **cGit-ui** a web server must be installed and configured on the system. We recommend
05d292b2 (kx 2023-03-24 03:51:10 +0300  33) the [Nginx](https://nginx.org/en/) with [uWsgi](https://uwsgi-docs.readthedocs.io/en/latest/)
05d292b2 (kx 2023-03-24 03:51:10 +0300  34) application server. Of course [Git](https://git-scm.com/) SCM system should be installed too.
05d292b2 (kx 2023-03-24 03:51:10 +0300  35) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  36) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  37) ## Installation
05d292b2 (kx 2023-03-24 03:51:10 +0300  38) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  39) To obtain sources we have to checkout its from SVN repository:
05d292b2 (kx 2023-03-24 03:51:10 +0300  40) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  41) ```Bash
05d292b2 (kx 2023-03-24 03:51:10 +0300  42) svn checkout svn://radix.pro/cgit-ui/tags/cgit-ui-0.1.3 cgit-ui-0.1.3
05d292b2 (kx 2023-03-24 03:51:10 +0300  43) ```
05d292b2 (kx 2023-03-24 03:51:10 +0300  44) and run the bootstrap script:
05d292b2 (kx 2023-03-24 03:51:10 +0300  45) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  46) ```Bash
05d292b2 (kx 2023-03-24 03:51:10 +0300  47) cd cgit-ui-0.1.3
05d292b2 (kx 2023-03-24 03:51:10 +0300  48) ./bootstrap
05d292b2 (kx 2023-03-24 03:51:10 +0300  49) ```
05d292b2 (kx 2023-03-24 03:51:10 +0300  50) Also **cGit-ui** source packages are available for download on the
05d292b2 (kx 2023-03-24 03:51:10 +0300  51) [Radix.pro FTP-server](https://ftp.radix.pro/pub/cgit-ui/).
05d292b2 (kx 2023-03-24 03:51:10 +0300  52) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  53) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  54) #### Bootstrap Script
05d292b2 (kx 2023-03-24 03:51:10 +0300  55) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  56) The *bootstrap* script especialy created for *Autotools* install automation. To install
05d292b2 (kx 2023-03-24 03:51:10 +0300  57) *Autotools* into sourse directory on build machine (i.e. when **build** == **host**) the *bootstrap*
05d292b2 (kx 2023-03-24 03:51:10 +0300  58) script can be run without arguments.
05d292b2 (kx 2023-03-24 03:51:10 +0300  59) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  60) ```Bash
05d292b2 (kx 2023-03-24 03:51:10 +0300  61) ./bootstrap
05d292b2 (kx 2023-03-24 03:51:10 +0300  62) ```
05d292b2 (kx 2023-03-24 03:51:10 +0300  63) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  64) I this case *Autotools* will be installed from current root file system.
05d292b2 (kx 2023-03-24 03:51:10 +0300  65) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  66) For the cross environment the `--target-dest-dir` option allows to install some stuff from
05d292b2 (kx 2023-03-24 03:51:10 +0300  67) development root file system:
05d292b2 (kx 2023-03-24 03:51:10 +0300  68) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  69) ```Bash
05d292b2 (kx 2023-03-24 03:51:10 +0300  70) TARGET_DEST_DIR=/home/developer/prog/trunk-672/dist/.s9xx-glibc/enybox-x2 \
05d292b2 (kx 2023-03-24 03:51:10 +0300  71)        ./bootstrap --target-dest-dir=${TARGET_DEST_DIR}
05d292b2 (kx 2023-03-24 03:51:10 +0300  72) ```
05d292b2 (kx 2023-03-24 03:51:10 +0300  73) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  74) For example, in this case the *aclocal.m4* script will be collected from the
05d292b2 (kx 2023-03-24 03:51:10 +0300  75) `${TARGET_DEST_DIR}/usr/share/aclocal` directory.
05d292b2 (kx 2023-03-24 03:51:10 +0300  76) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  77) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  78) ### Configuring Sources
05d292b2 (kx 2023-03-24 03:51:10 +0300  79) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  80) ```Bash
05d292b2 (kx 2023-03-24 03:51:10 +0300  81) ./configure --prefix=/usr \
05d292b2 (kx 2023-03-24 03:51:10 +0300  82)             --with-scriptdir=/var/www/htdocs/cgit
05d292b2 (kx 2023-03-24 03:51:10 +0300  83) ```
05d292b2 (kx 2023-03-24 03:51:10 +0300  84) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  85) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  86) #### Install on the Build Machine
05d292b2 (kx 2023-03-24 03:51:10 +0300  87) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  88) ```Bash
05d292b2 (kx 2023-03-24 03:51:10 +0300  89) make
05d292b2 (kx 2023-03-24 03:51:10 +0300  90) make install
05d292b2 (kx 2023-03-24 03:51:10 +0300  91) ```
05d292b2 (kx 2023-03-24 03:51:10 +0300  92) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  93) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  94) #### Cross Compilation Example
05d292b2 (kx 2023-03-24 03:51:10 +0300  95) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  96) ```Bash
05d292b2 (kx 2023-03-24 03:51:10 +0300  97) #!/bin/sh
05d292b2 (kx 2023-03-24 03:51:10 +0300  98) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  99) TARGET_DEST_DIR=/home/developer/prog/trunk-672/dist/.s9xx-glibc/enybox-x2
05d292b2 (kx 2023-03-24 03:51:10 +0300 100) TOOLCHAIN_PATH=/opt/toolchains/aarch64-S9XX-linux-glibc/1.1.4/bin
05d292b2 (kx 2023-03-24 03:51:10 +0300 101) TARGET=aarch64-s9xx-linux-gnu
05d292b2 (kx 2023-03-24 03:51:10 +0300 102) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 103) ./bootstrap --target-dest-dir=${TARGET_DEST_DIR}
05d292b2 (kx 2023-03-24 03:51:10 +0300 104) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 105) PKG_CONFIG=/usr/bin/pkg-config \
05d292b2 (kx 2023-03-24 03:51:10 +0300 106) PKG_CONFIG_PATH=${TARGET_DEST_DIR}/usr/lib${LIBDIRSUFFIX}/pkgconfig:${TARGET_DEST_DIR}/usr/share/pkgconfig \
05d292b2 (kx 2023-03-24 03:51:10 +0300 107) PKG_CONFIG_LIBDIR=${TARGET_DEST_DIR}/usr/lib${LIBDIRSUFFIX}/pkgconfig:${TARGET_DEST_DIR}/usr/share/pkgconfig \
05d292b2 (kx 2023-03-24 03:51:10 +0300 108) STRIP="${TOOLCHAIN_PATH}/${TARGET}-strip" \
05d292b2 (kx 2023-03-24 03:51:10 +0300 109) CC="${TOOLCHAIN_PATH}/${TARGET}-gcc --sysroot=${TARGET_DEST_DIR}" \
05d292b2 (kx 2023-03-24 03:51:10 +0300 110) ./configure --prefix=/usr
05d292b2 (kx 2023-03-24 03:51:10 +0300 111)   --build=x86_64-pc-linux-gnu \
05d292b2 (kx 2023-03-24 03:51:10 +0300 112)   --host=${TARGET} \
05d292b2 (kx 2023-03-24 03:51:10 +0300 113)   --with-scriptdir=/var/www/htdocs/cgit
05d292b2 (kx 2023-03-24 03:51:10 +0300 114) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 115) make
05d292b2 (kx 2023-03-24 03:51:10 +0300 116) make install DESTDIR=${TARGET_DEST_DIR}
05d292b2 (kx 2023-03-24 03:51:10 +0300 117) ```
05d292b2 (kx 2023-03-24 03:51:10 +0300 118) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 119) Also we can make use of additional variables such as `CFLAGS`, `LDFLAGS`:
05d292b2 (kx 2023-03-24 03:51:10 +0300 120) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 121) ```Bash
05d292b2 (kx 2023-03-24 03:51:10 +0300 122) LDFLAGS="-L${TARGET_DEST_DIR}/lib -L${TARGET_DEST_DIR}/usr/lib"
05d292b2 (kx 2023-03-24 03:51:10 +0300 123) TARGET_INCPATH="-L${TARGET_DEST_DIR}/usr/include"
05d292b2 (kx 2023-03-24 03:51:10 +0300 124) CFLAGS="${TARGET_INCPATH}"
05d292b2 (kx 2023-03-24 03:51:10 +0300 125) CPPFLAGS="${TARGET_INCPATH}"
05d292b2 (kx 2023-03-24 03:51:10 +0300 126) ```
05d292b2 (kx 2023-03-24 03:51:10 +0300 127) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 128) ### Post Install
05d292b2 (kx 2023-03-24 03:51:10 +0300 129) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 130) The system user, on whose behalf the **Nginx** server is launched, must have permissions to access
05d292b2 (kx 2023-03-24 03:51:10 +0300 131) the directory in which the **cGit-ui CGI script** was installed:
05d292b2 (kx 2023-03-24 03:51:10 +0300 132) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 133) ```Bash
05d292b2 (kx 2023-03-24 03:51:10 +0300 134) chown -R nginx:nginx /var/www/htdocs/cgit
05d292b2 (kx 2023-03-24 03:51:10 +0300 135) ```
05d292b2 (kx 2023-03-24 03:51:10 +0300 136) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 137) Additionaly if **nginx** user has not enough permissions to access repositories we have to change owner
05d292b2 (kx 2023-03-24 03:51:10 +0300 138) of */var/www/htdocs/cgit/cgit-ui.cgi* script  and set **SUID** or **SGID** bit:
05d292b2 (kx 2023-03-24 03:51:10 +0300 139) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 140) ```Bash
05d292b2 (kx 2023-03-24 03:51:10 +0300 141) chown -R 0:0 /var/www/htdocs/cgit/cgit-ui.cgi
05d292b2 (kx 2023-03-24 03:51:10 +0300 142) chmod 4755 /var/www/htdocs/cgit/cgit-ui.cgi
05d292b2 (kx 2023-03-24 03:51:10 +0300 143) ```
05d292b2 (kx 2023-03-24 03:51:10 +0300 144) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 145) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 146) ## uWsgi
05d292b2 (kx 2023-03-24 03:51:10 +0300 147) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 148) Since we used the *--with-scriptdir=/var/www/htdocs/cgit* option on configuring stage,
05d292b2 (kx 2023-03-24 03:51:10 +0300 149) the **cGit-ui** CGI script installed in the */var/www/htdocs/cgit/* directory. In this case,
05d292b2 (kx 2023-03-24 03:51:10 +0300 150) the */etc/uwsgi/cgit-ui.ini* file should look like this:
05d292b2 (kx 2023-03-24 03:51:10 +0300 151) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 152) **/etc/uwsgi/cgit-ui.ini:**
05d292b2 (kx 2023-03-24 03:51:10 +0300 153) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 154) ```ini
05d292b2 (kx 2023-03-24 03:51:10 +0300 155) [uwsgi]
05d292b2 (kx 2023-03-24 03:51:10 +0300 156) master          = true
05d292b2 (kx 2023-03-24 03:51:10 +0300 157) plugins         = cgi
05d292b2 (kx 2023-03-24 03:51:10 +0300 158) socket          = /run/uwsgi/%n.sock
05d292b2 (kx 2023-03-24 03:51:10 +0300 159) uid             = nginx
05d292b2 (kx 2023-03-24 03:51:10 +0300 160) gid             = nginx
05d292b2 (kx 2023-03-24 03:51:10 +0300 161) procname-master = uwsgi cgit-ui
05d292b2 (kx 2023-03-24 03:51:10 +0300 162) processes       = 1
05d292b2 (kx 2023-03-24 03:51:10 +0300 163) threads         = 2
05d292b2 (kx 2023-03-24 03:51:10 +0300 164) cgi             = /var/www/htdocs/cgit/cgit-ui.cgi
05d292b2 (kx 2023-03-24 03:51:10 +0300 165) ```
05d292b2 (kx 2023-03-24 03:51:10 +0300 166) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 167) Where */var/www/htdocs/cgit/cgit-ui.cgi* is the full name of installed **cGit-ui** CGI script.
05d292b2 (kx 2023-03-24 03:51:10 +0300 168) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 169) To run the **uWSGI** daemon for **cGit-ui** frontend we can make use following start/stop script:
05d292b2 (kx 2023-03-24 03:51:10 +0300 170) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 171) **/ets/rc.d/rc.cgit-ui-uwsgi:**
05d292b2 (kx 2023-03-24 03:51:10 +0300 172) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 173) ```Bash
05d292b2 (kx 2023-03-24 03:51:10 +0300 174) #!/bin/sh
05d292b2 (kx 2023-03-24 03:51:10 +0300 175) #
05d292b2 (kx 2023-03-24 03:51:10 +0300 176) # uWSGI daemon control script.
05d292b2 (kx 2023-03-24 03:51:10 +0300 177) #
05d292b2 (kx 2023-03-24 03:51:10 +0300 178) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 179) CONF=cgit-ui
05d292b2 (kx 2023-03-24 03:51:10 +0300 180) BIN=/usr/bin/uwsgi
05d292b2 (kx 2023-03-24 03:51:10 +0300 181) CONFDIR=/etc/uwsgi
05d292b2 (kx 2023-03-24 03:51:10 +0300 182) PID=/var/run/$CONF-uwsgi.pid
05d292b2 (kx 2023-03-24 03:51:10 +0300 183) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 184) uwsgi_start() {
05d292b2 (kx 2023-03-24 03:51:10 +0300 185)   # Sanity checks.
05d292b2 (kx 2023-03-24 03:51:10 +0300 186)   if [ ! -r $CONFDIR/cgit-ui.ini ]; then # no config files, exit:
05d292b2 (kx 2023-03-24 03:51:10 +0300 187)     echo "There are config files in $CONFDIR directory. Abort."
05d292b2 (kx 2023-03-24 03:51:10 +0300 188)     exit 1
05d292b2 (kx 2023-03-24 03:51:10 +0300 189)   fi
05d292b2 (kx 2023-03-24 03:51:10 +0300 190) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 191)   if [ -s $PID ]; then
05d292b2 (kx 2023-03-24 03:51:10 +0300 192)     echo "uWSGI for cGit-ui appears to already be running?"
05d292b2 (kx 2023-03-24 03:51:10 +0300 193)     exit 1
05d292b2 (kx 2023-03-24 03:51:10 +0300 194)   fi
05d292b2 (kx 2023-03-24 03:51:10 +0300 195) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 196)   echo "Starting uWSGI for cGit-ui server daemon..."
05d292b2 (kx 2023-03-24 03:51:10 +0300 197)   if [ -x $BIN ]; then
05d292b2 (kx 2023-03-24 03:51:10 +0300 198)     /bin/mkdir -p /run/uwsgi
05d292b2 (kx 2023-03-24 03:51:10 +0300 199)     /bin/chown nginx:nginx /run/uwsgi
05d292b2 (kx 2023-03-24 03:51:10 +0300 200)     /bin/chmod 0755 /run/uwsgi
05d292b2 (kx 2023-03-24 03:51:10 +0300 201)     $BIN --thunder-lock --pidfile $PID --daemonize /var/log/cgit-ui-uwsgi.log --ini $CONFDIR/$CONF.ini
05d292b2 (kx 2023-03-24 03:51:10 +0300 202)   fi
05d292b2 (kx 2023-03-24 03:51:10 +0300 203) }
05d292b2 (kx 2023-03-24 03:51:10 +0300 204) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 205) uwsgi_stop() {
05d292b2 (kx 2023-03-24 03:51:10 +0300 206)   echo "Shutdown uWSGI for cGit-ui gracefully..."
05d292b2 (kx 2023-03-24 03:51:10 +0300 207)   /bin/kill -INT $(cat $PID)
05d292b2 (kx 2023-03-24 03:51:10 +0300 208)   /bin/rm -f $PID
05d292b2 (kx 2023-03-24 03:51:10 +0300 209) }
05d292b2 (kx 2023-03-24 03:51:10 +0300 210) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 211) uwsgi_reload() {
05d292b2 (kx 2023-03-24 03:51:10 +0300 212)   echo "Reloading uWSGI for cGit-ui configuration..."
05d292b2 (kx 2023-03-24 03:51:10 +0300 213)   kill -HUP $(cat $PID)
05d292b2 (kx 2023-03-24 03:51:10 +0300 214) }
05d292b2 (kx 2023-03-24 03:51:10 +0300 215) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 216) uwsgi_restart() {
05d292b2 (kx 2023-03-24 03:51:10 +0300 217)   uwsgi_stop
05d292b2 (kx 2023-03-24 03:51:10 +0300 218)   sleep 3
05d292b2 (kx 2023-03-24 03:51:10 +0300 219)   uwsgi_start
05d292b2 (kx 2023-03-24 03:51:10 +0300 220) }
05d292b2 (kx 2023-03-24 03:51:10 +0300 221) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 222) case "$1" in
05d292b2 (kx 2023-03-24 03:51:10 +0300 223)   start)
05d292b2 (kx 2023-03-24 03:51:10 +0300 224)     uwsgi_start
05d292b2 (kx 2023-03-24 03:51:10 +0300 225)     ;;
05d292b2 (kx 2023-03-24 03:51:10 +0300 226)   stop)
05d292b2 (kx 2023-03-24 03:51:10 +0300 227)     uwsgi_stop
05d292b2 (kx 2023-03-24 03:51:10 +0300 228)     ;;
05d292b2 (kx 2023-03-24 03:51:10 +0300 229)   reload)
05d292b2 (kx 2023-03-24 03:51:10 +0300 230)     uwsgi_reload
05d292b2 (kx 2023-03-24 03:51:10 +0300 231)     ;;
05d292b2 (kx 2023-03-24 03:51:10 +0300 232)   restart)
05d292b2 (kx 2023-03-24 03:51:10 +0300 233)     uwsgi_restart
05d292b2 (kx 2023-03-24 03:51:10 +0300 234)     ;;
05d292b2 (kx 2023-03-24 03:51:10 +0300 235)   *)
05d292b2 (kx 2023-03-24 03:51:10 +0300 236)   echo "usage: `basename $0` {start|stop|reload|restart}"
05d292b2 (kx 2023-03-24 03:51:10 +0300 237) esac
05d292b2 (kx 2023-03-24 03:51:10 +0300 238) ```
05d292b2 (kx 2023-03-24 03:51:10 +0300 239) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 240) To run this daemon on systems with BSD-like initialization such as **Slackware**
05d292b2 (kx 2023-03-24 03:51:10 +0300 241) we have to add following lines to the */etc/rc.d/rc.M* and */etc/rc.d/rc.6* scripts
05d292b2 (kx 2023-03-24 03:51:10 +0300 242) correspondingly.
05d292b2 (kx 2023-03-24 03:51:10 +0300 243) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 244) **/etc/rc.d/rc.M:**
05d292b2 (kx 2023-03-24 03:51:10 +0300 245) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 246) ```Bash
05d292b2 (kx 2023-03-24 03:51:10 +0300 247) # Start uWSGI for cGit-ui server:
05d292b2 (kx 2023-03-24 03:51:10 +0300 248) if [ -x /etc/rc.d/rc.cgit-ui-uwsgi ]; then
05d292b2 (kx 2023-03-24 03:51:10 +0300 249)   /etc/rc.d/rc.cgit-ui-uwsgi start
05d292b2 (kx 2023-03-24 03:51:10 +0300 250) fi
05d292b2 (kx 2023-03-24 03:51:10 +0300 251) ```
05d292b2 (kx 2023-03-24 03:51:10 +0300 252) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 253) **/etc/rc.d/rc.6:**
05d292b2 (kx 2023-03-24 03:51:10 +0300 254) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 255) ```Bash
05d292b2 (kx 2023-03-24 03:51:10 +0300 256) # Stop uWSGI for cGit-ui server:
05d292b2 (kx 2023-03-24 03:51:10 +0300 257) if [ -x /etc/rc.d/rc.cgit-ui-uwsgi ]; then
05d292b2 (kx 2023-03-24 03:51:10 +0300 258)   /etc/rc.d/rc.cgit-ui-uwsgi stop
05d292b2 (kx 2023-03-24 03:51:10 +0300 259) fi
05d292b2 (kx 2023-03-24 03:51:10 +0300 260) ```
05d292b2 (kx 2023-03-24 03:51:10 +0300 261) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 262) ## Nginx
05d292b2 (kx 2023-03-24 03:51:10 +0300 263) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 264) First of all we have to add virtual server to the main **Nginx** config file:
05d292b2 (kx 2023-03-24 03:51:10 +0300 265) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 266) **/etc/nginx/nginx.conf:**
05d292b2 (kx 2023-03-24 03:51:10 +0300 267) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 268) ```Nginx
05d292b2 (kx 2023-03-24 03:51:10 +0300 269)     include /etc/nginx/vhosts/cgit.example.org.conf;
05d292b2 (kx 2023-03-24 03:51:10 +0300 270) ```
05d292b2 (kx 2023-03-24 03:51:10 +0300 271) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 272) The following configuration used **uWsgi** and will serve **cGit-ui** on a subdomain
05d292b2 (kx 2023-03-24 03:51:10 +0300 273) like *cgit.example.org*:
05d292b2 (kx 2023-03-24 03:51:10 +0300 274) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 275) **/etc/nginx/vhosts/cgit.example.org.conf:**
05d292b2 (kx 2023-03-24 03:51:10 +0300 276) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 277) ```Nginx
05d292b2 (kx 2023-03-24 03:51:10 +0300 278) #
05d292b2 (kx 2023-03-24 03:51:10 +0300 279) # cGit server:
05d292b2 (kx 2023-03-24 03:51:10 +0300 280) #
05d292b2 (kx 2023-03-24 03:51:10 +0300 281) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 282)     server {
05d292b2 (kx 2023-03-24 03:51:10 +0300 283)         listen 80;
05d292b2 (kx 2023-03-24 03:51:10 +0300 284)         server_name cgit.example.org;
05d292b2 (kx 2023-03-24 03:51:10 +0300 285)         return 301 https://cgit.example.org$request_uri;
05d292b2 (kx 2023-03-24 03:51:10 +0300 286)     }
05d292b2 (kx 2023-03-24 03:51:10 +0300 287) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 288)     server {
05d292b2 (kx 2023-03-24 03:51:10 +0300 289)         listen 443 ssl;
05d292b2 (kx 2023-03-24 03:51:10 +0300 290)         server_name cgit.example.org;
05d292b2 (kx 2023-03-24 03:51:10 +0300 291)         root /var/www/htdocs/cgit;
05d292b2 (kx 2023-03-24 03:51:10 +0300 292) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 293)         charset UTF-8;
05d292b2 (kx 2023-03-24 03:51:10 +0300 294) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 295)         #
05d292b2 (kx 2023-03-24 03:51:10 +0300 296)         # see:
05d292b2 (kx 2023-03-24 03:51:10 +0300 297)         #   https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security ,
05d292b2 (kx 2023-03-24 03:51:10 +0300 298)         #   https://raymii.org/s/tutorials/HTTP_Strict_Transport_Security_for_Apache_NGINX_and_Lighttpd.html
05d292b2 (kx 2023-03-24 03:51:10 +0300 299)         #
05d292b2 (kx 2023-03-24 03:51:10 +0300 300)         # see also: http://classically.me/blogs/how-clear-hsts-settings-major-browsers
05d292b2 (kx 2023-03-24 03:51:10 +0300 301)         # and do not include includeSubdomains; parameter into line:
05d292b2 (kx 2023-03-24 03:51:10 +0300 302)         #
05d292b2 (kx 2023-03-24 03:51:10 +0300 303)         add_header Strict-Transport-Security "max-age=63072000; preload";
05d292b2 (kx 2023-03-24 03:51:10 +0300 304) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 305)         error_log /var/log/nginx/cgit.example.org-error.log;
05d292b2 (kx 2023-03-24 03:51:10 +0300 306)         access_log /var/log/nginx/cgit.example.org-access.log;
05d292b2 (kx 2023-03-24 03:51:10 +0300 307) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 308)         keepalive_timeout        60;
05d292b2 (kx 2023-03-24 03:51:10 +0300 309)         ssl_certificate          /etc/letsencrypt/live/cgit.example.org/fullchain.pem;
05d292b2 (kx 2023-03-24 03:51:10 +0300 310)         ssl_certificate_key      /etc/letsencrypt/live/cgit.example.org/privkey.pem;
05d292b2 (kx 2023-03-24 03:51:10 +0300 311)         ssl_trusted_certificate  /etc/letsencrypt/live/cgit.example.org/chain.pem;
05d292b2 (kx 2023-03-24 03:51:10 +0300 312)         ssl_protocols            SSLv3 TLSv1 TLSv1.1 TLSv1.2;
05d292b2 (kx 2023-03-24 03:51:10 +0300 313)         ssl_ciphers              "RC4:HIGH:!aNULL:!MD5:!kEDH";
05d292b2 (kx 2023-03-24 03:51:10 +0300 314) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 315)         gzip on;
05d292b2 (kx 2023-03-24 03:51:10 +0300 316)         gzip_disable "msie6";
05d292b2 (kx 2023-03-24 03:51:10 +0300 317)         gzip_comp_level 6;
05d292b2 (kx 2023-03-24 03:51:10 +0300 318)         gzip_min_length 1100;
05d292b2 (kx 2023-03-24 03:51:10 +0300 319)         gzip_buffers 16 8k;
05d292b2 (kx 2023-03-24 03:51:10 +0300 320)         gzip_proxied any;
05d292b2 (kx 2023-03-24 03:51:10 +0300 321)         gzip_types text/plain text/css text/js text/xml text/javascript
05d292b2 (kx 2023-03-24 03:51:10 +0300 322)                    image/svg+xml image/gif image/jpeg image/png
05d292b2 (kx 2023-03-24 03:51:10 +0300 323)                    application/json application/x-javascript application/xml application/xml+rss application/javascript
05d292b2 (kx 2023-03-24 03:51:10 +0300 324)                    font/truetype font/opentype application/font-woff application/font-woff2
05d292b2 (kx 2023-03-24 03:51:10 +0300 325)                    application/x-font-ttf application/x-font-opentype application/vnd.ms-fontobject application/font-sfnt;
05d292b2 (kx 2023-03-24 03:51:10 +0300 326) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 327) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 328)         location ~* ^.+(favicon.ico|robots.txt) {
05d292b2 (kx 2023-03-24 03:51:10 +0300 329)             root /var/www/htdocs/cgit;
05d292b2 (kx 2023-03-24 03:51:10 +0300 330)             expires 30d;
05d292b2 (kx 2023-03-24 03:51:10 +0300 331)         }
05d292b2 (kx 2023-03-24 03:51:10 +0300 332) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 333)         location = /robots.txt {
05d292b2 (kx 2023-03-24 03:51:10 +0300 334)             allow all;
05d292b2 (kx 2023-03-24 03:51:10 +0300 335)             log_not_found off;
05d292b2 (kx 2023-03-24 03:51:10 +0300 336)             access_log off;
05d292b2 (kx 2023-03-24 03:51:10 +0300 337)         }
05d292b2 (kx 2023-03-24 03:51:10 +0300 338) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 339)         location / {
05d292b2 (kx 2023-03-24 03:51:10 +0300 340)             try_files $uri @cgit-ui;
05d292b2 (kx 2023-03-24 03:51:10 +0300 341)         }
05d292b2 (kx 2023-03-24 03:51:10 +0300 342) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 343)         location @cgit-ui {
05d292b2 (kx 2023-03-24 03:51:10 +0300 344)             gzip off;
05d292b2 (kx 2023-03-24 03:51:10 +0300 345)             include uwsgi_params;
05d292b2 (kx 2023-03-24 03:51:10 +0300 346)             uwsgi_modifier1 9;
05d292b2 (kx 2023-03-24 03:51:10 +0300 347)             uwsgi_pass unix:/run/uwsgi/cgit-ui.sock;
05d292b2 (kx 2023-03-24 03:51:10 +0300 348)         }
05d292b2 (kx 2023-03-24 03:51:10 +0300 349)     }
05d292b2 (kx 2023-03-24 03:51:10 +0300 350) ```
05d292b2 (kx 2023-03-24 03:51:10 +0300 351) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 352) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 353) ## Configuring Git Repositories
05d292b2 (kx 2023-03-24 03:51:10 +0300 354) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 355) A detailed description of the configuration file format can be found in the
05d292b2 (kx 2023-03-24 03:51:10 +0300 356) [**cgit-ui.rc(5)**](https://csvn.radix.pro/cgit-ui/trunk/doc/cgit-ui.rc.5.md) manual page:
05d292b2 (kx 2023-03-24 03:51:10 +0300 357) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 358) ```Bash
05d292b2 (kx 2023-03-24 03:51:10 +0300 359) man 5 cgit-ui.rc
05d292b2 (kx 2023-03-24 03:51:10 +0300 360) ```
05d292b2 (kx 2023-03-24 03:51:10 +0300 361) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 362) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 363) ## See Also
05d292b2 (kx 2023-03-24 03:51:10 +0300 364) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 365) > [**cscmd(8)**](https://csvn.radix.pro/cscm/trunk/doc/cscmd.8.md), 
05d292b2 (kx 2023-03-24 03:51:10 +0300 366) > [**cgit-ui.rc(5)**](https://csvn.radix.pro/cgit-ui/trunk/doc/cgit-ui.rc.5.md)
05d292b2 (kx 2023-03-24 03:51:10 +0300 367) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 368) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 369) ## Copyright and License
05d292b2 (kx 2023-03-24 03:51:10 +0300 370) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 371) &#169; Andrey V. Kosteltsev, 2019 &#8211; 2022.<br/>
05d292b2 (kx 2023-03-24 03:51:10 +0300 372) Code and documentation released under [the **Radix.pro** License](https://csvn.radix.pro/cgit-ui/trunk/LICENSE).