-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-repo.sh
executable file
·88 lines (74 loc) · 2.42 KB
/
make-repo.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
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
#!/bin/bash
username=$1
subdomain=$2
subdomain_path="/var/www/vhosts/cl-sf.com/subdomains/$subdomain"
echo ""
create_sub_domain()
{
echo "Creating subdomain $subdomain.cl-sf.com"
cd /usr/local/psa/bin/
./subdomain --create $subdomain -domain cl-sf.com
rm -rf $subdomain_path/httpdocs/*
echo "<html> <p>$subdomain server</p> </html>" >> "$subdomain_path/httpdocs/index.html"
echo ""
}
set_up_user()
{
echo "Setting up user: $username"
/usr/sbin/useradd $username
#/usr/sbin/usermod -d /home/$username $username
/usr/sbin/usermod -d $subdomain_path $username
/usr/sbin/usermod -a -G developers $username
passwd $username
echo ""
}
set_up_git_repo()
{
echo "Set up Git Repository"
cd $subdomain_path
echo " - creating .gitignore in /home/$username"
echo ".DS_Store" > .gitignore
echo "*.swp" >> .gitignore
echo "*.swo" >> .gitignore
echo ".bash_logout" >> .gitignore
echo ".bash_profile" >> .gitignore
echo ".bashrc" >> .gitignore
echo ".emacs" >> .gitignore
echo ".lesshst" >> .gitignore
echo ".viminfo" >> .gitignore
echo ".gitconfig" >> .gitignore
echo " - setting users git settings"
git config --global user.email "[email protected]"
git config --global user.name $username
git init
git add .gitignore
git add httpdocs
git commit -m "Initial Commit"
echo ""
echo "Clone Git repo with:"
echo "git clone [email protected]:~ $subdomain"
echo ""
echo "Project URL IS: $subdomain.cl-sf.com"
echo ""
}
enable_git_post_rec_hook()
{
echo "#!/bin/sh" > "$subdomain_path/.git/hooks/post-receive"
echo "cd .." >> "$subdomain_path/.git/hooks/post-receive"
echo "env -i git reset --hard ">> "$subdomain_path/.git/hooks/post-receive"
chmod u+x "$subdomain_path/.git/hooks/post-receive"
# twitter
#latestLog=`env -i git log -1 --pretty=format:"%an %h %s"`
#truncatedLog=`expr substr "$latestLog" 1 140`
#curl --silent --basic --user "bundlebuilder4:8california" --data-ascii \
#"status=$truncatedLog" http://twitter.com/statuses/update.json >/dev/null 2>&1
}
set_permissions()
{
chown -R $username:developers $subdomain_path
#chown -R clsf:developers "$subdomain_path/httpdocs"
chmod 755 "$subdomain_path"
chmod 775 "$subdomain_path/httpdocs"
}
create_sub_domain && set_up_user && set_up_git_repo && enable_git_post_rec_hook && set_permissions
exit 0