This repository has been archived by the owner on Nov 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgww.sh
68 lines (61 loc) · 1.48 KB
/
gww.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
echo
echo "----------------------------"
echo " Creator - Neeraj Dalal "
echo " Email - admin@nrjdalal.com "
echo "----------------------------"
echo
echo "A simple script to set up an efficient development workflow using Git to manage a live website"
echo "For more information visit - https://nrjdalal.com/GIT-Website-Workflow"
echo
echo "Prerequisite - Git must be installed on both local and remote machine/ web server"
echo "To download Git visit - https://git-scm.com/downloads"
echo
read -p "SSH Username > " USERNAME
read -p "SSH Hostname > " HOSTNAME
#to read PORT
read -p "SSH Port is set to 22, change port? " yesNo
while true; do
case $yesNo in
[yY]*)
read -p "SSH Port > " PORT
break
;;
[nN]*)
PORT="22"
echo "SSH Port > $PORT"
break
;;
*)
read -p "Please answer yes or no: " yesNo
continue
;;
esac
done
#end read PORT
echo
read -p "Work Directory > " WORKDIR
cat >server.sh <<GITSERVER
#!/bin/sh
mkdir -p $WORKDIR
cd $WORKDIR
mkdir .bareGit
cd .bareGit
git init --bare
cd hooks
cat > post-receive << HOOK
#!/bin/sh
git --work-tree=$WORKDIR --git-dir=$WORKDIR/.bareGit checkout -f
HOOK
chmod +x post-receive
exit
GITSERVER
echo
ssh -p $PORT $USERNAME@$HOSTNAME "bash -s" <server.sh
rm server.sh
echo
echo "To add remote, please specify remote name as -"
echo "$(tput setaf 3)REMOTENAME=$(tput sgr0)"
echo
echo "After that run -"
echo "$(tput setaf 6)git remote add \$REMOTENAME ssh://$USERNAME@$HOSTNAME:$PORT/$WORKDIR/.bareGit$(tput sgr0)"
echo