diff options
| author | quentin@aristote.fr <quentin@aristote.fr> | 2026-01-25 20:19:01 +0100 |
|---|---|---|
| committer | quentin@aristote.fr <quentin@aristote.fr> | 2026-01-25 20:48:23 +0100 |
| commit | d00f8fb1791e6f412d4a8898b53cdbe3cac20daa (patch) | |
| tree | 9d493ea1c2af4721be7a27f72470dcb818fd2c47 /config/services/git/shell-commands/repo/src/create_command.sh | |
| parent | fbb1709e1504280ca5576f91d85bb7f5dfeff37a (diff) | |
git: add shell-commands
Diffstat (limited to 'config/services/git/shell-commands/repo/src/create_command.sh')
| -rw-r--r-- | config/services/git/shell-commands/repo/src/create_command.sh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/config/services/git/shell-commands/repo/src/create_command.sh b/config/services/git/shell-commands/repo/src/create_command.sh new file mode 100644 index 0000000..ab8bf3f --- /dev/null +++ b/config/services/git/shell-commands/repo/src/create_command.sh @@ -0,0 +1,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 |
