Skip to content

Commit f64948c

Browse files
committed
Take Before/After Nginx PHP Conf In GIT Version Control & Gererate ~/.my.cnf
1 parent 2e59310 commit f64948c

File tree

1 file changed

+114
-13
lines changed

1 file changed

+114
-13
lines changed

usr/local/sbin/eeupdate

Lines changed: 114 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,38 @@ OwnError()
1212
exit 101
1313
}
1414

15+
GITCOMMIT ()
16+
{
17+
# Change Directory
18+
cd $EEGITDIR || OwnError "Unable To Change Directory $EEGITDIR"
19+
20+
# Check .git
21+
if [ ! -d .git ]
22+
then
23+
# Initialise Git
24+
echo -e "\033[34mInitialise Git On $EEGITDIR...\e[0m"
25+
git init &>> $INSTALLLOG || OwnError "Unable To Initialize Git On $EEGITDIR"
26+
fi
27+
28+
# Check For Untracked Files
29+
git status | grep clean &>> $INSTALLLOG
30+
if [ $? -ne 0 ]
31+
then
32+
# Add Files In Git Version Control
33+
git add . && git commit -am "$EEGITMESSAGE" &>> $INSTALLLOG \
34+
|| OwnError "Unable To Git Commit On $EEGITDIR"
35+
fi
36+
}
37+
1538
EEUPDATE()
1639
{
1740
# Clone EasyEngine (ee) Stable Repository
1841
rm -rf /tmp/easyengine
42+
echo -e "\033[34mUpdating EasyEngine (ee), Please Wait...\e[0m" | tee -ai $INSTALLLOG
1943
git clone -b stable git://github.com/rtCamp/easyengine.git /tmp/easyengine &>> $INSTALLLOG || OwnError "Unable To Clone Easy Engine"
2044

2145
# EasyEngine (ee) /etc Files
2246
cp -a /tmp/easyengine/etc/bash_completion.d/ee /etc/bash_completion.d/ &>> $INSTALLLOG || OwnError "Unable To Copy EE Auto Complete File"
23-
cp -a /tmp/easyengine/etc/easyengine/ee.conf /etc/easyengine/ &>> $INSTALLLOG || OwnError "Unable To Copy ee.conf File"
2447

2548
# EE /usr/share/easyengine Files
2649
cp -a /tmp/easyengine/etc/nginx/* /usr/share/easyengine/nginx/ &>> $INSTALLLOG || OwnError "Unable To Copy Configuration Files "
@@ -84,6 +107,69 @@ EEUPDATE()
84107
fi
85108
}
86109

110+
MYSQLUSERPASS()
111+
{
112+
MYSQLUSER=root
113+
MYSQLHOST=localhost
114+
115+
# Turn Off Echo For Passwords
116+
stty -echo
117+
read -p "Enter The MySQL Password For root User: " MYSQLPASS
118+
stty echo
119+
echo
120+
}
121+
122+
MYSQLPASSCHECK()
123+
{
124+
while [ -n $(mysqladmin -h $MYSQLHOST -u $MYSQLUSER -p$MYSQLPASS ping 2> /dev/null | grep alive) &> /dev/null ]
125+
do
126+
# Verify MySQL Credentials
127+
MYSQLUSERPASS
128+
done
129+
130+
# Generate ~/.my.cnf
131+
echo -e "[client]\nuser=root\npassword=$MYSQLPASS" > ~/.my.cnf
132+
}
133+
134+
MYCNFCHECK()
135+
{
136+
# MySQL Root Password
137+
if [ -f ~/.my.cnf ]
138+
then
139+
MYSQLUSER=root
140+
MYSQLHOST=localhost
141+
MYSQLPASS=$(cat ~/.my.cnf | grep pass | cut -d'=' -f2)
142+
MYSQLPASSCHECK
143+
else
144+
# Turn Off Echo For Passwords
145+
stty -echo
146+
read -p "Enter The MySQL Password For root User: " MYSQLPASS
147+
stty echo
148+
echo
149+
150+
MYSQLPASSCHECK
151+
fi
152+
153+
154+
}
155+
156+
EE101()
157+
{
158+
# EasyEngine (ee) /etc Files
159+
cp -a /tmp/easyengine/etc/easyengine/ee.conf /etc/easyengine/ &>> $INSTALLLOG || OwnError "Unable To Copy ee.conf File"
160+
161+
# Let Copy Some Missing Files & Chnage Nginx As Per Latest EasyEngine
162+
(sed "/allow/,+2d" /usr/share/easyengine/nginx/common/acl.conf; grep -v ^# /etc/nginx/common/allowed_ip.conf ) > /etc/nginx/common/acl.conf
163+
cp /usr/share/easyengine/nginx/common/locations.conf /etc/nginx/common
164+
sed -i "s/fastcgi_cache_use_stale.*/fastcgi_cache_use_stale error timeout invalid_header updating http_500 http_503;\nfastcgi_cache_valid any 1h;/g" /etc/nginx/conf.d/fastcgi.conf
165+
sed -i "/client_max_body_size/a \ \n\t# SSL Settings\n\tssl_session_cache shared:SSL:20m;\n\tssl_session_timeout 10m;\n\tssl_prefer_server_ciphers on;\n\tssl_ciphers HIGH:\!aNULL:\!MD5:\!kEDH;\n\n" /etc/nginx/nginx.conf
166+
sed -i "s/log_format rt_cache.*/log_format rt_cache '\$remote_addr \$upstream_response_time \$upstream_cache_status [\$time_local] '/" /etc/nginx/nginx.conf
167+
sed -i "s/.*\$body_bytes_sent'/\t\t'\$http_host \"\$request\" \$status \$body_bytes_sent '/" /etc/nginx/nginx.conf
168+
169+
# Move PHP’s Session Storage To Memcache
170+
sed -i "/extension/a \session.save_handler = memcache\nsession.save_path = \"tcp://localhost:11211\"" /etc/php5/mods-available/memcache.ini
171+
}
172+
87173
HTTPAUTH()
88174
{
89175
# Get The htpasswd Details
@@ -120,22 +206,16 @@ HTTPAUTH()
120206
printf "$HTPASSWDUSER:$(openssl passwd -crypt $HTPASSWDPASS 2> /dev/null)\n" > /etc/nginx/htpasswd-ee 2> /dev/null
121207
}
122208

123-
EE101()
209+
RESTARTSERVICE()
124210
{
125-
# Let Copy Some Missing Files
126-
(sed "/allow/,+2d" /usr/share/easyengine/nginx/common/acl.conf; grep -v ^# /etc/nginx/common/allowed_ip.conf ) > /etc/nginx/common/acl.conf
127-
cp -v /usr/share/easyengine/nginx/common/locations.conf /etc/nginx/common
128-
sed -i "s/fastcgi_cache_use_stale.*/fastcgi_cache_use_stale error timeout invalid_header updating http_500 http_503;\nfastcgi_cache_valid any 1h;/g" /etc/nginx/conf.d/fastcgi.conf
129-
sed -i "/client_max_body_size/a \ \n\t# SSL Settings\n\tssl_session_cache shared:SSL:20m;\n\tssl_session_timeout 10m;\n\tssl_prefer_server_ciphers on;\n\tssl_ciphers HIGH:\!aNULL:\!MD5:\!kEDH;\n\n" /etc/nginx/nginx.conf
130-
sed -i "s/log_format rt_cache.*/log_format rt_cache '\$remote_addr \$upstream_response_time \$upstream_cache_status [\$time_local] '/" /etc/nginx/nginx.conf
131-
sed -i "s/.*\$body_bytes_sent'/\t\t'\$http_host \"\$request\" \$status \$body_bytes_sent '/" /etc/nginx/nginx.conf
132-
133-
# Move PHP’s Session Storage To Memcache
134-
sed -i "/extension/a \session.save_handler = memcache\nsession.save_path = \"tcp://localhost:11211\"" /etc/php5/mods-available/memcache.ini
211+
service php5-fpm restart &>> $INSTALLLOG || OwnError "Unable To Restart PHP5-FPM After Update"
212+
(nginx -t && service nginx restart) &>> $INSTALLLOG || OwnError "Unable To Restart Nginx After Update"
135213
}
136214

137215

138216

217+
218+
139219
# Update EasyEngine (ee)
140220
EECURRENTVERSION=$(ee version | awk '{print($3)}')
141221
EELATESTVERSION=$(curl -sL https://api.github.com/repos/rtCamp/easyengine/releases | grep tag_name | awk '{print($2)}' | cut -d'"' -f2 | cut -c2-)
@@ -154,16 +234,37 @@ then
154234
echo &>> $INSTALLLOG
155235
echo -e "\033[34mEasyEngine (ee) Update Started [$(date)]\e[0m" | tee -ai $INSTALLLOG
156236

237+
# Before Update Take Nginx Conf In GIT
238+
EEGITDIR=/etc/nginx
239+
EEGITMESSAGE="Before Updating EasyEngine To $EELATESTVERSION"
240+
GITCOMMIT
241+
242+
# Before Update Take PHP Conf In GIT
243+
EEGITDIR=/etc/php5
244+
GITCOMMIT
245+
157246
# Update EasyEngine (ee)
158247
EEUPDATE
159-
HTTPAUTH
248+
160249

161250
if [[ $EECURRENTVERSION = 1.0.1 ]]
162251
then
163252
EE101
253+
HTTPAUTH
254+
MYCNFCHECK
164255
fi
165256
fi
166257

258+
# Restart Nginx & PHP Services
259+
RESTARTSERVICE
260+
261+
# Let's Take Conf In Git Version Control
262+
EEGITDIR=/etc/nginx
263+
EEGITMESSAGE="After Updating EasyEngine To $EELATESTVERSION"
264+
GITCOMMIT
265+
EEGITDIR=/etc/php5
266+
GITCOMMIT
267+
167268
# Source EasyEngine (ee) Auto Complete To Take Effect
168269
echo
169270
echo -e "\033[34mFor EasyEngine (ee) Auto Completion Run Following Command\e[0m" | tee -ai $INSTALLLOG

0 commit comments

Comments
 (0)