summaryrefslogtreecommitdiff
path: root/config/services/git/shell-commands/repo/src/create_command.sh
blob: ab8bf3f8e67d4747d3aca2522d0fa82a04335d6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
repo=$(realpath --canonicalize-missing /srv/git/"${args[repo]}")

if [[ ! "$repo" == /srv/git/* ]]
then
    red "Forbidden path."
    exit 2
fi

subpath=/srv/git
IFS='/' read -ra dirs <<< "${repo#/srv/git/}"
for dir in "${dirs[@]}"; do
    subpath="$subpath/$dir"
    if [[ ! -d "$subpath" ]]
    then
       break
    fi
done

mkdir --parents "$repo"
chmod u=rwX,g=,o= --recursive "$subpath"
git init --bare "$repo"

args[path]="$repo"
args[--tree]=1
repo_show_command