diff options
Diffstat (limited to 'bin/sync-cgit-repos.sh')
-rwxr-xr-x | bin/sync-cgit-repos.sh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/bin/sync-cgit-repos.sh b/bin/sync-cgit-repos.sh new file mode 100755 index 0000000..007d2c7 --- /dev/null +++ b/bin/sync-cgit-repos.sh @@ -0,0 +1,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 |