-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·82 lines (61 loc) · 2.07 KB
/
setup.sh
File metadata and controls
executable file
·82 lines (61 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#/bin/bash/
# Title : auto setup git repositories
# Date : Sun Apr 19 21:22:38 CST 2015
# Author: andychen ([email protected])
# 要求用root用户执行 =================================================
if [ `whoami` != 'root' ];then
echo "+----------------------------+"
echo "| plase use root user |"
echo "+----------------------------+"
exit 0
fi
# 参数赋值 ===========================================================
group=git #一定要是git
user=git #一定要是git ,同上。尚不明原因
git_user_name=andychen
local_ip=192.168.73.128
rep_path=/home/${user}/repositories
gitosis_path=https://github.com/res0nat0r/gitosis.git
# 基础安装 ===========================================================
apt-get update
apt-get install git-core
apt-get install gitosis
apt-get install openssh-server
apt-get install openssh-client
apt-get install openssh-client
apt-get install python-setuptools
# 开始 ===============================================================
# add group and user
groupdel ${group}
userdel ${user}
useradd -m ${user}
passwd ${user}
groupadd ${group}
# build git repositories
mkdir -p ${rep_path}
chown ${group}:${user} ${rep_path}
chmod 755 ${rep_path}
# config git user info
git config --global user.name "${git_user_name}"
git config --global user.email "${git_user_email}"
# install gitosis
cd /tmp
git clone ${gitosis_path}
cd ./gitosis
python setup.py install
cd -
# 配置gitosis ========================================================
# create pravite key
cd ~
ssh-keygen -t rsa -P '' # 加-P ''后才是真正的免输密码
cp ~/.ssh/id_rsa.pub /tmp
chmod 777 /tmp/id_rsa.pub
sudo -H -u ${user} gitosis-init < /tmp/id_rsa.pub
chmod 755 ${rep_path}/gitosis-admin.git/hooks/post-update
# show repositories dir
echo "+-----------------------------------------------------------------------+"
echo "+ use: "
echo "+ git clone git@${local_ip}:gitosis-admin.git"
echo "+ * the really passwd is "`whoami`"'s passwd "
echo "+-----------------------------------------------------------------------+"