为了大家都能偷懒而已~把步骤写成脚本~ 用法: bootstrap.sh && gitosis-knstall.sh
[Shell] 纯文本查看 复制代码 git 安装~
wget [url]http://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.gz[/url]
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 [url]https://raw.github.com/pypa/virtualenv/master/virtualenv.py[/url] > bin/virtualenv.py
python ./bin/virtualenv.py --distribute gitosis-env
. gitosis-env/bin/activate
mkdir src
cd src
git clone [url]https://github.com/tv42/gitosis.git[/url]
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}
|