#!/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