aboutsummaryrefslogtreecommitdiffstats
path: root/roles/git/files/git-shell-commands/make-private
blob: 432d8478e9091c3ff3c66d2f5fccfdea68c5f8be (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
26
27
28
29
30
#!/bin/sh
#
# Copyright (c) 2017 Aaron LI <aly@aaronly.me>
# MIT License
#
# Turn a public Git repository to be private to `cgit`.
#
# 2017-06-19
#

. ${HOME}/vars.conf

if [ $# -ne 1 ]; then
    echo "usage: make-private <repository.git>"
    exit 1
fi

project="${1%.[gG][iI][tT]}.git"

if [ ! -d "${project}" ]; then
    echo "ERROR: repository '${project}' not exists!"
    exit 2
elif [ -L "${PUBLIC}/${project}" ]; then
    rm "${PUBLIC}/${project}"
    echo "Made repository '${project}' private."
    exit 0
else
    echo "Repository '${project}' not public."
    exit 0
fi