mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 12:03:31 +01:00
git-srv-admin.sh: Add -f flag (horrible mess)
Signed-off-by: Jan Lindemann <jan@jannet.de>
This commit is contained in:
parent
b96daf0fa6
commit
0b6cfd1f96
1 changed files with 50 additions and 14 deletions
|
|
@ -6,8 +6,12 @@ usage()
|
|||
{
|
||||
cat << EOT | sed 's/^ |//'
|
||||
|
|
||||
| $myname cmd [cmd-arguments] ...
|
||||
| $myname [global options] cmd [cmd-arguments] ...
|
||||
|
|
||||
| global options are:
|
||||
|
|
||||
| -j : project is a jannet-project (default is a private project)
|
||||
|
|
||||
| commands are:
|
||||
|
|
||||
| create-personal-project name
|
||||
|
|
@ -50,19 +54,30 @@ md()
|
|||
}
|
||||
|
||||
# ----------------- commands
|
||||
md_p()
|
||||
{
|
||||
if [ -d "$1" ]; then
|
||||
return
|
||||
fi
|
||||
md_p `dirname $1` $2 $3 $4
|
||||
md $@
|
||||
}
|
||||
|
||||
create_project_dir()
|
||||
{
|
||||
if [ "$UID" != 0 ]; then
|
||||
fatal "tried to create directory \"$dir\" as `whoami`, needs to be done as root"
|
||||
fi
|
||||
|
||||
md_p `dirname $dir` 750 root jannet
|
||||
md_p $dir 770 root $id
|
||||
}
|
||||
|
||||
create_personal_project()
|
||||
{
|
||||
[ -e $dir ] && fatal "$dir already exists"
|
||||
|
||||
if [ "$UID" = 0 ]; then
|
||||
md /srv/git 750 root jannet
|
||||
md /srv/git/$id 750 root jannet
|
||||
md /srv/git/$id/proj 750 root jannet
|
||||
md /srv/git/$id/proj/$p 770 root $id
|
||||
exit 0
|
||||
fi
|
||||
|
||||
/usr/bin/sudo $0 create-personal-project $p || fatal "failed to set root uid"
|
||||
/usr/bin/sudo `readlink -f $0` create-project-dir $dir || fatal "failed to set root uid"
|
||||
cd $dir || fatal "failed to change to $dir"
|
||||
git init --bare || fatal "git init failed"
|
||||
}
|
||||
|
|
@ -74,17 +89,34 @@ list_personal_projects()
|
|||
}
|
||||
|
||||
# ----------------- here we go
|
||||
cmd=$1
|
||||
shift
|
||||
|
||||
id=`whoami`
|
||||
[ "$SUDO_UID" ] && {
|
||||
id=`/opt/ytools/bin/getpwuid $SUDO_UID | sed '/^name *=/ !d; s/^name *= *//'`
|
||||
[ "$id" ] || fatal "failed to find uid $SUDO_UID in user database"
|
||||
}
|
||||
|
||||
git_home=/srv/git/$id
|
||||
pdir=$git_home/priv
|
||||
|
||||
OPTIND=1
|
||||
while getopts jh flag; do
|
||||
|
||||
case $flag in
|
||||
j)
|
||||
pdir=$git_home/proj;;
|
||||
h)
|
||||
usage 0;;
|
||||
*)
|
||||
usage 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
cmd=$1
|
||||
shift
|
||||
p=$1
|
||||
pdir=/srv/git/$id/proj
|
||||
|
||||
dir=$pdir/$p
|
||||
|
||||
case $cmd in
|
||||
|
|
@ -95,6 +127,10 @@ create-personal-project)
|
|||
list-personal-projects)
|
||||
list_personal_projects "$@"
|
||||
;;
|
||||
create-project-dir)
|
||||
dir=$1 # this is all a horrible variable and usage mess
|
||||
create_project_dir "$@"
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue