Create a small ssh-based local git server on the old Dell Computer

Source: Internet
Author: User
Hardware condition: Dell poweredge 745 Core 2 64-bit 1g memory 160g hard disk Ubuntu 12.04.5 lts 32-bit (because the memory is less than 2g), character interface (do not run X Windows, to save memory) Step: 1. Create a user git, create a home directory, modify the permissions as appropriate; 2. Refer to the steps in http://git-scm.com/book/zh/ section 4.2, execute: $ git clone -- bare https://github.com/ricky-gong/mongo.git (five in total) tried it. If you have SSH permission, you can transfer files with the host on your laptop. For example: $ git clone [user] @ [git.example.com]: [/opt/git/my_project.git] user name host domain name or address path of git Warehouse 3. Reference: description of the SSH key in section 4.3 of the http://git-scm.com/book/zh/; steps to generate an SSH key in the https://help.github.com/articles/generating-ssh-keys; how to transition from HTTPS to SSH in the https://help.github.com/articles/changing-a-remote-s-url (HTTPS is used at the beginning ); most of them follow the above steps, but there is one thing to modify: In the step of the second web page, run the first command in step 2:
Ssh-keygen-t rsa-c"[Email protected]"
It requires you to enter passphrase next to it. We strongly recommend that you enter passphrase on this webpage. However, because of our special environment, press enter directly. Otherwise, passphrase will be entered for each upload, SSH has no advantages over HTTPS.
Others.
========================================================== ==============================================
Cause:
The most fundamental reason is that we work on the Character interface.
Theoretically, this passphrase will be saved by an SSH-Agent Program (automatically started upon installation, every time we transmit data through SSH and GitHub, it will automatically help us input passphrase. However, you can see from man page that the program runs on X Windows. That is to say, in the character interface, this program cannot work (so the above "start automatically ", it should be changed to "auto start after X Windows is started "). This program does not work, and the input passphrase cannot be saved, which leads to a problem I encountered before: This passphrase is required for each upload. If passphrase is not entered here, the file can be uploaded automatically.
If you accidentally input, it does not matter, do not need to re-generate a copy, just need to be in the key generated, execute the command under the page https://help.github.com/articles/working-with-ssh-key-passphrases, modify passphrase just fine.
========================================================== ==============================================
4. Write an upload script as needed and set the crontab to synchronize it with GitHub once every week and save the logs. Complete ~

Attach a shell script to check whether the host can access the Internet:
Http://www.2cto.com/kf/201309/243768.html
In my script program, the code above is used.


Add the source code and modify the address parameters in the upload script according to the actual directory where the two are located. Create a New log folder to store logs and modify the address parameters in upload.

 1 #! /bin/bash 2  3 timeout=5 4 target=www.baidu.com 5 git_dir=/home/git 6 log_dir=/home/git/maintain/log 7 log_name=$(date ‘+%d_%m_%Y‘).log 8 mail_text=/home/git/maintain/mail.txt 9 10 11 upload()12 {13     cd $git_dir14     for each_git in $(ls -d *.git)15     do16         cd "## /home/git/$each_git"17         echo "/home/git/$each_git:" >> $log_dir/$log_name 18         # check whether there‘s a modification19         # if so, sync with github20 21         git push origin master >> $log_dir/$log_name 2>&122         echo "errno: $?" >> $log_dir/$log_name 23     done24 }25 26 sendmail()27 {28     # Ricky29     mail -s "Local Git weekly push on $(date ‘+%B %d, %Y‘)" *@qq.com < $mail_text30     # JK Chen31     mail -s "Local Git weekly push on $(date ‘+%B %d, %Y‘)" *@qq.com < $mail_text32     # D Qiao33     mail -s "Local Git weekly push on $(date ‘+%B %d, %Y‘)" *@qq.com < $mail_text34     # XQ Qian35     mail -s "Local Git weekly push on $(date ‘+%B %d, %Y‘)" *@qq.com < $mail_text36     # RS Liang37     mail -s "Local Git weekly push on $(date ‘+%B %d, %Y‘)" *@qq.com < $mail_text38     # K Huang39     #mail -s "Local Git weekly push on $(date ‘+%B %d, %Y‘)" *@mail.sysu.edu.cn < $mail_text40 }41 42 printHelp()43 {44     echo "This script accepts no, or only one argument, which is \"-nomail\"."45     echo "It will disable the email sending."46 }47 48 # trigger49 mail=150 51 52 53 #================================================================================================54 55 56 57 # Dealing with arguments58 if [ "$#" -gt 1 ]; then59     echo "$0: Too much argument"60     exit 161 fi62 63 if [ "$1" = ‘-nomail‘ ]; then64     mail=065 elif [ "$1" = ‘--help‘ ]; then66     printHelp67     exit 068 elif [ -n "$1" ]; then69     echo "$0: Invalid argument"70     exit 171 fi72 73 # Body74 touch $log_dir/$log_name75 echo "=================================================================" >> $log_dir/$log_name76 echo "update.sh: start process at $(date ‘+%T on %B %d, %Y‘)" >> $log_dir/$log_name77 echo "user: $(whoami)" >> $log_dir/$log_name78 echo "pwd: $(pwd)" >> $log_dir/$log_name79 echo "" >> $log_dir/$log_name80 echo "" >> $log_dir/$log_name81 82 83 ret_code=$(curl -I -s --connect-timeout $timeout $target -w %{http_code} | tail -n1)84 if [ "x$ret_code" = "x200" ]; then85     upload86     # mail everyone for notification.87     if [ $mail -eq 1 ]; then88         sendmail89     fi90     echo "=================================================================" >> $log_dir/$log_name91     exit 092 else93     echo "Repositories won‘t uploaded to the github: Internet unavailable" >> $log_dir/$log_name94     # no internet access, can‘t send e-mail95     echo "=================================================================" >> $log_dir/$log_name96     exit 197 fi

 




Create a small ssh-based local git server on the old Dell Computer

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.