mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-24 14:50:38 +01:00
git-srv-admin.sh: Some code and usage cleanup
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
aea176c7b3
commit
ec115ab6ff
1 changed files with 30 additions and 19 deletions
|
|
@ -10,12 +10,12 @@ usage()
|
||||||
|
|
|
|
||||||
| global options are:
|
| global options are:
|
||||||
|
|
|
|
||||||
| -j : project is a jannet-project (default is a private project)
|
| -F flavour : flavour is one of: priv, jw, contrib
|
||||||
|
|
|
|
||||||
| commands are:
|
| commands are:
|
||||||
|
|
|
|
||||||
| create-personal-project name
|
| create-repo name
|
||||||
| list-personal-projects
|
| list-repos
|
||||||
|
|
|
|
||||||
EOT
|
EOT
|
||||||
[ "$1" ] && exit $1
|
[ "$1" ] && exit $1
|
||||||
|
|
@ -68,7 +68,7 @@ md_p()
|
||||||
md $@
|
md $@
|
||||||
}
|
}
|
||||||
|
|
||||||
create_project_dir()
|
create_repo_dir()
|
||||||
{
|
{
|
||||||
if [ "$UID" != 0 ]; then
|
if [ "$UID" != 0 ]; then
|
||||||
fatal "tried to create directory \"$dir\" as `whoami`, needs to be done as root"
|
fatal "tried to create directory \"$dir\" as `whoami`, needs to be done as root"
|
||||||
|
|
@ -80,7 +80,7 @@ create_project_dir()
|
||||||
md_p $dir 02750 $id `id -g $id`
|
md_p $dir 02750 $id `id -g $id`
|
||||||
}
|
}
|
||||||
|
|
||||||
create_personal_project()
|
create_repo()
|
||||||
{
|
{
|
||||||
[ -e $dir ] && {
|
[ -e $dir ] && {
|
||||||
err "$dir already exists"
|
err "$dir already exists"
|
||||||
|
|
@ -93,7 +93,7 @@ create_personal_project()
|
||||||
git init --bare --shared=0640 || fatal "git init failed"
|
git init --bare --shared=0640 || fatal "git init failed"
|
||||||
}
|
}
|
||||||
|
|
||||||
list_personal_projects()
|
list_repos()
|
||||||
{
|
{
|
||||||
cd $pdir || return 1
|
cd $pdir || return 1
|
||||||
ls */HEAD | sed 's%/HEAD%%' 2>/dev/null
|
ls */HEAD | sed 's%/HEAD%%' 2>/dev/null
|
||||||
|
|
@ -102,21 +102,22 @@ list_personal_projects()
|
||||||
|
|
||||||
# ----------------- here we go
|
# ----------------- here we go
|
||||||
no_error_if_exists=0
|
no_error_if_exists=0
|
||||||
jannet_project=0
|
|
||||||
id=`whoami`
|
id=`whoami`
|
||||||
#user=$id
|
#user=$id
|
||||||
|
flavour=priv
|
||||||
|
|
||||||
OPTIND=1
|
OPTIND=1
|
||||||
while getopts jhu: flag; do
|
while getopts jhu:F: flag; do
|
||||||
|
|
||||||
case $flag in
|
case $flag in
|
||||||
h)
|
h)
|
||||||
usage 0;;
|
usage 0;;
|
||||||
u)
|
u)
|
||||||
user=$OPTARG
|
user=$OPTARG;;
|
||||||
;;
|
j) # legacy support
|
||||||
j)
|
flavour=jw;;
|
||||||
jannet_project=1;;
|
F)
|
||||||
|
flavour=$OPTARG;;
|
||||||
p)
|
p)
|
||||||
no_error_if_exist=1;;
|
no_error_if_exist=1;;
|
||||||
*)
|
*)
|
||||||
|
|
@ -138,7 +139,17 @@ fi
|
||||||
|
|
||||||
git_home=/srv/git/$id
|
git_home=/srv/git/$id
|
||||||
pdir=$git_home/priv
|
pdir=$git_home/priv
|
||||||
[ "$jannet_project" = 1 ] && pdir=$git_home/proj
|
|
||||||
|
case $flavour in
|
||||||
|
jw)
|
||||||
|
pdir=$git_home/proj;;
|
||||||
|
priv)
|
||||||
|
pdir=$git_home/priv;;
|
||||||
|
contrib)
|
||||||
|
pdir=$git_home/contrib;;
|
||||||
|
*)
|
||||||
|
fatal "unknown repository flavour \"$flavour\""
|
||||||
|
esac
|
||||||
|
|
||||||
cmd=$1
|
cmd=$1
|
||||||
shift
|
shift
|
||||||
|
|
@ -147,17 +158,17 @@ p=$1
|
||||||
dir=$pdir/$p
|
dir=$pdir/$p
|
||||||
|
|
||||||
case $cmd in
|
case $cmd in
|
||||||
create-personal-project)
|
create-personal-project|create-repo)
|
||||||
check_user_is_self
|
check_user_is_self
|
||||||
create_personal_project "$@"
|
create_repo "$@"
|
||||||
;;
|
;;
|
||||||
list-personal-projects)
|
list-personal-projects|list-repos)
|
||||||
list_personal_projects "$@"
|
list_repos "$@"
|
||||||
;;
|
;;
|
||||||
create-project-dir)
|
create-project-dir|create-repo-dir)
|
||||||
dir=$1 # this is all a horrible variable and usage mess
|
dir=$1 # this is all a horrible variable and usage mess
|
||||||
check_user_is_self
|
check_user_is_self
|
||||||
create_project_dir "$@"
|
create_repo_dir "$@"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
usage 1
|
usage 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue