-
Notifications
You must be signed in to change notification settings - Fork 3
/
start.sh
executable file
·151 lines (143 loc) · 4.42 KB
/
start.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
# Author Munis Isazade
COMMAND_NAME=create-django-app
if [[ "$OSTYPE" == "darwin"* ]]; then
LOCAL_COMMAND_DIRECTORY=/usr/local/bin
TLP_DIRECTORY=/usr/local/share
else
LOCAL_COMMAND_DIRECTORY=~/.local/bin
TLP_DIRECTORY=~/.local/share
fi
GIR_REPO_URL=https://github.com/munisisazade/create-django-app.git
#usage: ChangeColor $COLOR text/background
function ChangeColor()
{
TYPE=""
case "$2" in
"text") TYPE="setaf"
;;
"back") TYPE="setab"
;;
*) TYPE="setaf"
esac
case "$1" in
"red") tput "$TYPE" 1
;;
"orange") tput "$TYPE" 3
;;
"blue") tput "$TYPE" 4
;;
"green") tput "$TYPE" 2
;;
"black") tput "$TYPE" 0
;;
"white") tput "$TYPE" 7
;;
"magenta") tput "$TYPE" 5
;;
"cyan") tput "$TYPE" 7
;;
*) tput "$TYPE" 0
esac
}
if [[ $1 ]]; then
cp base.sh $COMMAND_NAME
chmod +x $COMMAND_NAME
rm -rf $TLP_DIRECTORY/django_app/
rm -rf $LOCAL_COMMAND_DIRECTORY/create-django-app
if [ -d $LOCAL_COMMAND_DIRECTORY ]; then
mv $COMMAND_NAME $LOCAL_COMMAND_DIRECTORY
if [ -d $TLP_DIRECTORY ]; then
cp -r tlp/django_app $TLP_DIRECTORY/
else
cd ~/.local/
mkdir share
cp -r tlp/django_app $TLP_DIRECTORY/
fi
else
cd ~
mkdir .local
cd .local/
mkdir bin/
mv $COMMAND_NAME $LOCAL_COMMAND_DIRECTORY
mkdir share
cp -r tlp/django_app $TLP_DIRECTORY/
sudo echo "# set PATH so it includes user's private bin directories" >> ~/.profile
sudo echo "PATH=\"\$HOME/bin:\$HOME/.local/bin:\$PATH\"" >> ~/.profile
fi
echo -e "\n"
echo -e " Successfuly Updated $(ChangeColor green text)$COMMAND_NAME$(ChangeColor white text) "
echo -e "\n"
echo -e "Please specify the project directory:"
echo -e "$(ChangeColor blue text) create-django-app $(ChangeColor green text)<project-directory>$(ChangeColor white text)"
echo -e "\n"
echo -e "For example:"
echo -e "$(ChangeColor blue text) create-django-app $(ChangeColor green text)my-django-app$(ChangeColor white text)"
echo -e "\n"
echo -e "Run $(ChangeColor blue text)create-django-app --help$(ChangeColor white text) to see all options."
else
cp base.sh $COMMAND_NAME
chmod +x $COMMAND_NAME
if [ -d $LOCAL_COMMAND_DIRECTORY ]; then
mv $COMMAND_NAME $LOCAL_COMMAND_DIRECTORY
if [ -d $TLP_DIRECTORY ]; then
cp -r tlp/django_app $TLP_DIRECTORY/
else
cd ~/.local/
mkdir share
cp -r tlp/django_app $TLP_DIRECTORY/
fi
else
cd ~
mkdir .local
cd .local/
mkdir bin/
mv $COMMAND_NAME $LOCAL_COMMAND_DIRECTORY
mkdir share
cp -r tlp/django_app $TLP_DIRECTORY/
sudo echo "# set PATH so it includes user's private bin directories" >> ~/.profile
sudo echo "PATH=\"\$HOME/bin:\$HOME/.local/bin:\$PATH\"" >> ~/.profile
fi
mkdir ~/.$COMMAND_NAME
cd ~/.$COMMAND_NAME
git init
git remote add origin $GIR_REPO_URL
git fetch origin
git reset --hard origin/master
git branch --set-upstream-to origin/master
echo -e "$(ChangeColor green text)"
echo -ne '## (0%)\r'
sleep 0.5
echo -ne '#### (10%)\r'
sleep 0.5
echo -ne '###### (20%)\r'
sleep 0.5
echo -ne '######## (30%)\r'
sleep 0.5
echo -ne '########## (40%)\r'
sleep 0.5
echo -ne '############ (50%)\r'
sleep 0.5
echo -ne '############## (60%)\r'
sleep 0.5
echo -ne '################ (70%)\r'
sleep 0.5
echo -ne '################## (80%)\r'
sleep 0.5
echo -ne '#################### (90%)\r'
sleep 0.5
echo -ne '######################(100%)\r'
echo -ne '\n'
echo -e "$(ChangeColor white text)"
echo -e "\n"
echo -e " Successfuly installed $(ChangeColor green text)$COMMAND_NAME$(ChangeColor white text) "
echo -e "\n"
echo -e "Please specify the project directory:"
echo -e "$(ChangeColor blue text) create-django-app $(ChangeColor green text)<project-directory>$(ChangeColor white text)"
echo -e "\n"
echo -e "For example:"
echo -e "$(ChangeColor blue text) create-django-app $(ChangeColor green text)my-django-app$(ChangeColor white text)"
echo -e "\n"
echo -e "Run $(ChangeColor blue text)create-django-app --help$(ChangeColor white text) to see all options."
fi
exit 1