summaryrefslogtreecommitdiff
path: root/bin/sync-cgit-repos.sh
blob: 007d2c7b3f9d49fd277e743e662364395452ce8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash

BASE_HOME="/home/publicaccess/home"
CGIT_DIR="/srv/git/listed"

mkdir -p "$CGIT_DIR"

for user_dir in "$BASE_HOME"/*; do
    [ -d "$user_dir/git/listed" ] || continue
    username=$(basename "$user_dir")
    
    for repo in "$user_dir/git/listed/"*.git; do
        [ -d "$repo" ] || continue
        reponame=$(basename "$repo")
        mount_point="${CGIT_DIR}/${username}-${reponame}"
        
        # Create the mount point directory if it doesn't exist
        mkdir -p "$mount_point"
        
        # Bind mount the repo to the cgit directory
        mountpoint -q "$mount_point" || mount --bind "$repo" "$mount_point"
    done
done