歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

利用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}

本文出自 “峰雲,就她了。” 博客,請務必保留此出處http://rfyiamcool.blog.51cto.com/1030776/1151432

Copyright © Linux教程網 All Rights Reserved