aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2026-07-05 10:52:25 +0530
committerAkshay Nair <phenax5@gmail.com>2026-07-05 14:41:55 +0530
commiteca86870bf10c064a9f561249491f03c6e750a86 (patch)
tree95676411d6f95babd1fdf5231c6fecc44f94cab9
parent2cd9a4039c0c5f524df0a33605c9baef1f57917e (diff)
downloadbacchus-remote-eca86870bf10c064a9f561249491f03c6e750a86.tar.gz
bacchus-remote-eca86870bf10c064a9f561249491f03c6e750a86.zip
Add fork/set-description git commands + optimizations
Diffstat (limited to '')
-rw-r--r--cgit/cgitrc20
-rwxr-xr-xcgit/docker-entrypoint.sh4
-rw-r--r--cgit/nginx/conf.d/default.conf10
-rw-r--r--cgit/nginx/nginx.conf4
-rwxr-xr-xcgit/ssh/git-shell-commands/fork32
-rwxr-xr-xcgit/ssh/git-shell-commands/set-description25
-rw-r--r--docker-compose.yml7
-rwxr-xr-xsetup.sh2
8 files changed, 86 insertions, 18 deletions
diff --git a/cgit/cgitrc b/cgit/cgitrc
index 7c73534..468e859 100644
--- a/cgit/cgitrc
+++ b/cgit/cgitrc
@@ -57,28 +57,38 @@ readme=:install
# Cache
cache-root=/var/cache/cgit
-cache-size=0
+cache-size=3000
+cache-root-ttl=3
+cache-about-ttl=5
+cache-dynamic-ttl=15
+cache-repo-ttl=10
+cache-static-ttl=30
-enable-index-links=0
+enable-index-links=1
enable-index-owner=0
enable-remote-branches=1
enable-log-filecount=1
-enable-log-linecount=1
+enable-log-linecount=0 # This shit is slow
enable-tree-linenumbers=1
enable-git-config=1
enable-commit-graph=1
enable-follow-links=1
enable-http-clone=1
enable-html-serving=1
-snapshots=tar.xz zip
+enable-blame=1
+snapshots=tar.gz zip
remove-suffix=1
repository-sort=age
+max-repo-count=50
+max-blob-size=512
+max-commit-count=20
+max-message-length=72
+
# side-by-side-diffs=1
robots=index, nofollow
virtual-root=/
section-from-path=0
-max-repo-count=50
# Scan path has to be last
scan-path=/srv/git
diff --git a/cgit/docker-entrypoint.sh b/cgit/docker-entrypoint.sh
index 0c13086..3da0ede 100755
--- a/cgit/docker-entrypoint.sh
+++ b/cgit/docker-entrypoint.sh
@@ -5,9 +5,7 @@ set -eux
CGIT_USER=git
CGIT_GROUP=git
-id
-
-chown $CGIT_USER:$CGIT_GROUP /var/cache/cgit
+chown ${CGIT_USER}:${CGIT_GROUP} /var/cache/cgit
chmod u+g /var/cache/cgit
spawn-fcgi \
diff --git a/cgit/nginx/conf.d/default.conf b/cgit/nginx/conf.d/default.conf
index a850744..7254ffa 100644
--- a/cgit/nginx/conf.d/default.conf
+++ b/cgit/nginx/conf.d/default.conf
@@ -3,15 +3,15 @@ server {
server_name localhost;
root /usr/share/webapps/cgit;
- location / {
- try_files $uri @cgit;
- }
-
- location ~* ^.+(favicon.ico|robots.txt) {
+ location ~* ^.+(ediblemonad.+|favicon.ico|robots.txt) {
root /usr/share/webapps/cgit;
expires 30d;
}
+ location / {
+ try_files $uri @cgit;
+ }
+
location @cgit {
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/cgit.cgi;
diff --git a/cgit/nginx/nginx.conf b/cgit/nginx/nginx.conf
index c5a713f..3642e30 100644
--- a/cgit/nginx/nginx.conf
+++ b/cgit/nginx/nginx.conf
@@ -1,6 +1,6 @@
user git;
worker_processes auto;
-error_log stderr crit;
+error_log stderr info;
pid /var/run/nginx.pid;
events {
@@ -18,7 +18,6 @@ http {
open_file_cache_errors on;
access_log off;
- error_log stderr crit;
sendfile on;
sendfile_max_chunk 512k;
@@ -59,7 +58,6 @@ http {
server_tokens off;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
- add_header X-XSS-Protection "1; mode=block";
client_body_buffer_size 128k;
large_client_header_buffers 4 256k;
diff --git a/cgit/ssh/git-shell-commands/fork b/cgit/ssh/git-shell-commands/fork
new file mode 100755
index 0000000..52803d3
--- /dev/null
+++ b/cgit/ssh/git-shell-commands/fork
@@ -0,0 +1,32 @@
+#!/usr/bin/env sh
+
+set -eu
+
+remote_host="git.ediblemonad.dev"
+owner_info="Akshay Nair <phenax5@gmail.com>"
+
+if [ $# -lt 2 ]; then
+ echo "Usage: fork <name> <url>" 1>&2
+ exit 1
+fi
+
+repo_name="$1"; shift 1;
+[ -z "$repo_name" ] && echo "Error: empty repo name" 1>&2 && exit 1
+
+remote_repo_url="$1"; shift 1;
+[ -z "$remote_repo_url" ] && echo "Error: empty repo url" 1>&2 && exit 1
+
+repo_dir="/git/${repo_name}.git"
+
+if [ -d "$repo_dir" ]; then
+ echo "Error: $repo_name already exists" 1>&2
+ exit 1;
+fi
+
+git clone --bare "$remote_repo_url" "$repo_dir"
+
+cd "$repo_dir"
+echo "Fork of $remote_repo_url" > description
+echo "$owner_info" > owner_info
+
+echo "git@${remote_host}:${repo_dir}"
diff --git a/cgit/ssh/git-shell-commands/set-description b/cgit/ssh/git-shell-commands/set-description
new file mode 100755
index 0000000..a120fa0
--- /dev/null
+++ b/cgit/ssh/git-shell-commands/set-description
@@ -0,0 +1,25 @@
+#!/usr/bin/env sh
+
+set -eu
+
+if [ $# -lt 2 ]; then
+ echo "Usage: set-description <name> <...description>" 1>&2
+ exit 1
+fi
+
+repo_name="$1"; shift 1;
+[ -z "$repo_name" ] && echo "Error: empty repo name" 1>&2 && exit 1
+
+description="$*";
+[ -z "$description" ] && echo "Error: empty description" 1>&2 && exit 1
+
+repo_dir="/git/${repo_name}.git"
+
+if ! [ -d "$repo_dir" ]; then
+ echo "Error: $repo_name doesn't exist" 1>&2
+ exit 1;
+fi
+
+echo "$description" > "${repo_dir}/description"
+
+echo "Done"
diff --git a/docker-compose.yml b/docker-compose.yml
index 33051ad..8f1eff2 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -40,7 +40,12 @@ services:
- LETSENCRYPT_HOST=git.ediblemonad.dev
- DHPARAM_GENERATION=false
- USE_CUSTOM_CONFIG=true
- - GIT_REPOS_ROOT=${GIT_REPOS_ROOT:-/git}
+ deploy:
+ resources:
+ limits:
+ cpus: '0.5'
+ reservations:
+ cpus: '0.2'
volumes:
- cgit-cache:/var/cache/cgit
- ${GIT_REPOS_ROOT:-/git}:/srv/git:ro
diff --git a/setup.sh b/setup.sh
index efd3346..efd3954 100755
--- a/setup.sh
+++ b/setup.sh
@@ -29,7 +29,7 @@ configure_git() {
sudo -u git git config --global init.defaultBranch main
# kept explicit shell setup
chsh -s "$(which git-shell)" git
- cp -rf "$ROOT_DIR/cgit/ssh/git-shell-commands" /home/git/
+ ln -sf "$ROOT_DIR/cgit/ssh/git-shell-commands" /home/git/
}
configure_firewall() {