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

搭建無限制權限的簡單git服務器使用git-daemon腳本

搭建無限制權限的簡單git服務器使用git-daemon腳本   如果想要用ubantu架設無限制權限(即不適用gitosis)的簡單git服務器,實現git庫下載clone,push等簡單的基本功能,   可以直接使用git-daemon腳本(非常不安全,建議項目代碼的git管理不要使用!)   本地安裝完sudo apt-get install git git-core之後沒有安裝git-daemon-run或者git-daemon-sysvinit時,可以執行如下操作:   sudo vi /etc/init.d/git-daemon   ==========================================CP下面的代碼復制過去,修改下base-path和user==================================   #! /bin/sh   PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin   NAME=git-daemon PIDFILE=/var/run/$NAME.pid DESC="the git daemon" DAEMON=/usr/lib/git-core/git-daemon DAEMON_OPTS="--base-path=/home/dongwuming/git --enable=receive-pack --export-all --verbose --syslog --detach --pid-file=$PIDFILE --user=dongwuming --group=nogroup"   test -x $DAEMON || exit 0   [ -r /etc/default/git-daemon ] && . /etc/default/git-daemon   . /lib/lsb/init-functions   start_git() {   start-stop-daemon --start --quiet --pidfile $PIDFILE \     --startas $DAEMON -- $DAEMON_OPTS }   stop_git() {   start-stop-daemon --stop --quiet --pidfile $PIDFILE   rm -f $PIDFILE }   status_git() {   start-stop-daemon --stop --test --quiet --pidfile $PIDFILE >/dev/null 2>&1 }   case "$1" in   start)   log_begin_msg "Starting $DESC"   start_git   log_end_msg 0   ;;   stop)   log_begin_msg "Stopping $DESC"   stop_git   log_end_msg 0   ;;   status)   log_begin_msg "Testing $DESC: "   if status_git   then     log_success_msg "Running"     exit 0   else     log_failure_msg "Not running"     exit 1   fi   ;;   restart|force-reload)   log_begin_msg "Restarting $DESC"   stop_git   sleep 1   start_git   log_end_msg 0     ;;   *)   echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2   exit 1   ;; esac   exit 0   ======================================:wq!保存退出=============================================   sudo chmod 777  /etc/init.d/git-daemon   sudo /etc/init.d/git-daemon stop sudo /etc/init.d/git-daemon start   ps -ef | grep git-daemon 1000      6100     1  0 17:01 ?        00:00:00 /usr/lib/git-core/git-daemon --base-path=/home/dongwuming/git --enable=receive-pack --export-all --verbose --syslog --detach --pid-file=/var/run/git-daemon.pid --user=dongwuming --group=nogroup 1000      6243 17377  0 17:29 pts/2    00:00:00 grep --color=auto git-daemon   OK 用另外一台局域網的機器   git clone git://192.168.xx.xx/your-bare-or-mirror-git-repositories【建庫的時候一定要是一個bare赤裸的或者mirror鏡像的git庫】   cd your-bare-or-mirror-git-repositories   vi test   just a test!   git add.;git commit -m "just a test"   git push origin HEAD:master   Counting objects: 5, done. Delta compression using up to 4 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 281 bytes, done. Total 3 (delta 0), reused 0 (delta 0) To git://192.168.50.125/test    6ca6f70..9b97ad9  master -> master   OK了   git-daemon中控制用戶可以PUSH的權限的參數為:   --enable=receive-pack    ====================================UBANTU sudo apt-gt install git-daemon=========================================   直接下載git-daemon 來管理git   $apt-get install git git-core git-daemon-run        配置git-daemon-run   $vi /etc/sv/git-daemon/run   ====================   #!/bin/sh exec 2>&1 echo 'git-daemon starting.' exec chpst -m64000000 /   git-daemon --verbose --base-path=/var/cache/git /var/cache/git --enable=receive-pack --export-all --verbose --syslog --detach 【根據個人需求修改配置】           啟動git-daemon   $sudo sv stop git-daemon   $sudo sv start git-daemon
Copyright © Linux教程網 All Rights Reserved