5534 发表于 2015-12-30 13:52:26

创建git repository的脚本

                      #!/bin/bash
# 该脚本使用NFS文件系统,然后做软连接到/home/git目录下,然后设置相应的权限等。
#
Git_dir=/mnt/nfs/git/
Git_home=/home/git
read -p"please input the new project name..." New_pro

cd $Git_dir

if [ -d $New_pro ] ; then
    rm -rf $New_pro
    mkdir -p $New_pro
else
    mkdir -p $New_pro
fi

#chown -R git:git $New_pro

cd $Git_home

link_repo() {
    ln -s $Git_dir$New_pro $Git_home
    cd $New_pro
    git init --bare --shared
    touch git-daemon-export-ok
    git update-server-info
    chown -R git:git $Git_dir$New_pro
}


if [ -L $New_pro ]; then
    rm -rf $New_pro
    link_repo
else
    link_repo
fi



页: [1]
查看完整版本: 创建git repository的脚本