jingshen 发表于 2013-3-11 09:48:34

利用shell自动创建代码库管理gitosis 服务环境

为了大家都能偷懒而已~把步骤写成脚本~用法:bootstrap.sh && gitosis-knstall.sh
git 安装~
wget http://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.gz
tar xzvf git-latest.tar.gz
cd git-{date}
autoconf
./configure --with-curl=/usr/local
make
sudo make install
下面是 bootstrap.sh
#!/bin/sh
#
#

mkdir -p bin
curl https://raw.github.com/pypa/virtualenv/master/virtualenv.py > bin/virtualenv.py
python ./bin/virtualenv.py --distribute gitosis-env
   . gitosis-env/bin/activate
mkdir src
cd src
   git clone https://github.com/tv42/gitosis.git
   cd gitosys
      python ./setup.py install
cd ../..
下面是 gitosis-knstall.sh
#!/bin/sh
#
# Create gitosis env
#

LOCAL_DIR=$( cd $(dirname $0) && pwd)
GITOSIS_USER=git
GITOSIS_SERVER=efate
GITOSIS_HOMEDIR=/srv/${GITOSIS_SERVER}/git
git_user=$(getent passwd ${GITOSIS_USER})

if [ -z "${git_user}" ]
then
    sudo adduser \
      --system \
      --shell /bin/sh \
      --gecos 'git version control' \
      --group \
      --disabled-password \
      --home ${GITOSIS_HOMEDIR} \
      ${GITOSIS_USER}
else
    GITOSIS_HOMEDIR=$(echo ${git_user} | cut -d: -f6)
fi

#TODO: check env if exists ... (update ?)
sudo rsync -av ${LOCAL_DIR}/gitosis-env ${GITOSIS_HOMEDIR}
sudo python ${LOCAL_DIR}/bin/virtualenv.py --relocatable ${GITOSIS_HOMEDIR}/gitosis-env

[ ! -f ~/.ssh/gitosis.pub ] && ssh-keygen -t rsa -f ~/.ssh/gitosis

sudo -H -u ${GITOSIS_USER} ${GITOSIS_HOMEDIR}/gitosis-env/bin/gitosis-init < ~/.ssh/gitosis.pub
sudo sh -c "printf '. \${HOME}/gitosis-env/bin/activate'> ${GITOSIS_HOMEDIR}/.profile"
sudo chown -R git:git ${GITOSIS_HOMEDIR}

0 发表于 2013-3-19 00:57:03

穿别人的鞋,走自己的路,让他们找去吧。

123sw 发表于 2013-5-17 10:40:15

如果回帖是一种美德,那我早就成为圣人了!

gbless 发表于 2013-5-20 17:54:49

昨天,系花对我笑了一下,乐得我晚上直数羊,一只羊,两只羊,三只羊……

760176104 发表于 2013-5-24 18:42:59

如果有一双眼睛陪我一同哭泣,就值得我为生命受苦。

linghaiyan 发表于 2013-5-31 11:20:36

我抢、我抢、我抢沙发~

蓝晶灵 发表于 2013-6-5 13:46:57

路边的野花不要,踩。
页: [1]
查看完整版本: 利用shell自动创建代码库管理gitosis 服务环境