-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·92 lines (87 loc) · 2.85 KB
/
configure
File metadata and controls
executable file
·92 lines (87 loc) · 2.85 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
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/sh
# parse command line args for make analogs
USE_GITHUB=true
for p in "$@"; do
USE_GH=$(echo "$p" | grep 'USE_GITHUB' | grep -o '\w*$')
if [ "$USE_GH" != "" ]; then
USE_GITHUB=$USE_GH
fi
done
# This sets up your local git configuration.
# It is a pre-requisite for installation.
./gitguild user status
echo
USER_NAME=$(git config user.name)
# This runs the ok.sh configuration, if USE_GITHUB is true
if [ "$USE_GITHUB" = "true" ]; then
if [ ! -f "$HOME"/.netrc ] || \
[ "$(grep api.github.com "$HOME"/.netrc)" = "" ]; then
echo "Enter your github api token. Will not display."
echo "Create a token at https://github.com/settings/tokens if you need to."
stty -echo
read token
stty echo
if [ "$token" = "" ]; then
echo "If you do not want github, rerun with USE_GITHUB=false"
exit 2
fi
{
echo "machine api.github.com"
echo " login ""$USER_NAME"
echo " password ""$token"
echo
} >> "$HOME"/.netrc
echo "github configured."
echo
fi
fi
# As explained in the echo, it is necessary to set the hostname.
hostname=$(hostname)
if [ "$hostname" != "$USER_NAME" ]; then
echo Need to set the system "hostname" to your git user name.
echo The reasoning is that a limited git and ssh server are created.
echo Once the system has a public name, it should be a logical name,
echo and should not leak personal information unintentionally.
echo
if [ -f "/etc/sysconfig/network" ]; then
sudo sed -i "s/HOSTNAME=$hostname/HOSTNAME=$USER_NAME/" /etc/sysconfig/network
sudo hostname "$USER_NAME"
elif [ -f "/etc/hostname" ]; then
sudo sed -i "s/$hostname/$USER_NAME/" /etc/hostname
sudo sed -i "s/ $hostname/ $USER_NAME/" /etc/hosts
sudo hostname "$USER_NAME"
fi
fi
gitu=$(id -u git)
if [ "$?" != 0 ] || [ "$gitu" = "" ]; then
echo To further protect the system, a "git" system user and group will be created.
echo These will isolate the server processes and files from the rest of your system.
echo
echo "Please choose a password for this new \"git\" user."
stty -echo
read gitpass
stty echo
if [ "$gitpass" = "" ]; then
echo "It is highly recommended to set a strong password for the git user!"
echo "The security of this user is the security of the rest of your system."
exit 2
fi
sudo groupadd git
sudo useradd -m -g git git
if [ "$?" != 0 ]; then
echo "Could not create git user. Bailing."
exit 1
fi
echo "git:$gitpass" | sudo chpasswd
echo "git user created!"
echo
# also add your current user to git group
sudo usermod -a -G git "$USER"
newgrp git
echo "Also added your current user to the 'git' group"
echo "You will have full access to the git group files, but"
echo "The git user will not have access to your files."
echo
# ensure group has ownership of all of git's files
sudo chown -R git:git /home/git/
fi