-
Notifications
You must be signed in to change notification settings - Fork 5
/
install_git_core.sh
executable file
·65 lines (47 loc) · 1.56 KB
/
install_git_core.sh
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
#!/bin/bash
# tested on ubuntu 16.04 (gnome)
# tested on ubuntu 14.04.3 (gnome)
SCRIPT_NAME=$(basename $BASH_SOURCE)
SCRIPT_LOGFILE="./logs/"$(basename -s .sh $BASH_SOURCE)".log"
mkdir -p ./logs && chmod 755 ./logs
echo "running "$SCRIPT_NAME
sudo apt-get -y install git &>> $SCRIPT_LOGFILE
# creating directory for all git projects
mkdir -p ~/git
# generate keys
machine_name=$(uname -n)
if [ -f ~/.ssh/git_id ];
then
echo "git_id already exist"
chmod 600 ~/.ssh/git_id
else
echo "generating new git_id rsa key"
echo -e 'y\n'| ssh-keygen -q -t rsa -C admin@localhost -f ~/.ssh/git_id -N ''
chmod 600 ~/.ssh/git_id
fi
echo ""
echo "----------------------------------------------------------------------"
echo ""
cat ~/.ssh/git_id.pub
echo ""
echo "----------------------------------------------------------------------"
# create ssh config for git
if [ -f ~/.ssh/config ];
then
echo "ssh config file already exist, i won't modify it"
else
echo "creating ssh config for github and bitbucket services"
echo "" > ~/.ssh/config
echo "Host github" >> ~/.ssh/config
echo " HostName github.com" >> ~/.ssh/config
echo " IdentityFile ~/.ssh/git_id" >> ~/.ssh/config
echo " PreferredAuthentications publickey" >> ~/.ssh/config
echo "" >> ~/.ssh/config
echo "Host bitbucket" >> ~/.ssh/config
echo " HostName bitbucket.org" >> ~/.ssh/config
echo " IdentityFile ~/.ssh/git_id" >> ~/.ssh/config
echo " PreferredAuthentications publickey" >> ~/.ssh/config
echo "" >> ~/.ssh/config
git config --global user.name "admin"
git config --global user.email "admin@localhost"
fi