Skip to content

Commit 98dd7c9

Browse files
committed
New script to update easyengine
1 parent de51011 commit 98dd7c9

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed

usr/local/sbin/eeupdate

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#!/bin/bash
2+
3+
4+
5+
# Make Variables Available For Later Use
6+
INSTALLLOG=/var/log/easyengine/install.log
7+
8+
# Capture Errors
9+
OwnError()
10+
{
11+
echo -e "[ `date` ] \033[31m$@\e[0m" | tee -ai $INSTALLLOG
12+
exit 101
13+
}
14+
15+
EEUPDATE()
16+
{
17+
# Clone EasyEngine (ee) Stable Repository
18+
git clone -b stable git://github.com/rtCamp/easyengine.git /tmp/easyengine &>> $INSTALLLOG || OwnError "Unable To Clone Easy Engine"
19+
20+
# EasyEngine (ee) /etc Files
21+
cp -a /tmp/easyengine/etc/bash_completion.d/ee /etc/bash_completion.d/ &>> $INSTALLLOG || OwnError "Unable To Copy EE Auto Complete File"
22+
cp -a /tmp/easyengine/etc/easyengine/ee.conf /etc/easyengine/ &>> $INSTALLLOG || OwnError "Unable To Copy ee.conf File"
23+
24+
# EE /usr/share/easyengine Files
25+
cp -a /tmp/easyengine/etc/nginx/* /usr/share/easyengine/nginx/ &>> $INSTALLLOG || OwnError "Unable To Copy Configuration Files "
26+
cp -a /tmp/easyengine/usr/share/easyengine/* /usr/share/easyengine/ &>> $INSTALLLOG || OwnError "Unable To Copy Configuration Files "
27+
28+
# EE Command
29+
cp -a /tmp/easyengine/usr/local/sbin/* /usr/local/sbin/ &>> $INSTALLLOG || OwnError "Unable To Copy EasyEngine Command"
30+
31+
# EE Man Pages
32+
cp -a /tmp/easyengine/man/ee.8 /usr/share/man/man8/ &>> $INSTALLLOG || OwnError "Unable To Copy EasyEngine Man Pages"
33+
34+
# Change Permission For EE
35+
chmod 750 /usr/local/sbin/easyengine /usr/local/sbin/eeupdate || OwnError "Unable To Change EasyEngine Command Permission"
36+
37+
# Create Symbolic Link If Not Exist
38+
if [ ! -L /usr/local/sbin/ee ]
39+
then
40+
ln -s /usr/local/sbin/easyengine /usr/local/sbin/ee
41+
fi
42+
43+
# Adjust FastCGI Cache Size 20% Of /var/run
44+
VARRUNSIZE=$(df --block-size=M /var/run | awk '{print $4}' | tail -n1 |cut -d'M' -f1)
45+
FCSIZE=$(expr $VARRUNSIZE \* 25 / 100)
46+
47+
# Change Size
48+
sed -i "s/500m/$FCSIZE\m/" /usr/share/easyengine/nginx/conf.d/fastcgi.conf || OwnError "Unable To Change Fastcgi Cache Size"
49+
50+
# Git Config Settings
51+
EEGITNAME=$(git config user.name)
52+
EEGITEMAIL=$(git config user.email)
53+
54+
if [ -z "$EEGITNAME" ] || [ -z "$EEGITEMAIL" ]
55+
then
56+
echo
57+
echo -e "\033[34mEasyEngine (ee) Required Your Name & Email Address To Track Changes You Made Under The Git\e[0m" | tee -ai $INSTALLLOG
58+
echo -e "\033[34mEasyEngine (ee) Will Be Able To Send You Daily Reports & Alerts In Upcoming Version\e[0m" | tee -ai $INSTALLLOG
59+
echo -e "\033[34mEasyEngine (ee) Will NEVER Send Your Information Across\e[0m" | tee -ai $INSTALLLOG
60+
fi
61+
# Check Git User Is Empty Or Not
62+
if [ -z "$EEGITNAME" ]
63+
then
64+
read -p "Enter Your Name [$(whoami)]: " EEGITNAME
65+
# If Enter Is Pressed
66+
if [[ $EEGITNAME = "" ]]
67+
then
68+
EEGITNAME=$(whoami)
69+
fi
70+
git config --global user.name "$EEGITNAME" &>> $INSTALLLOG
71+
fi
72+
73+
# Check Git User Is Empty Or Not
74+
if [ -z "$EEGITEMAIL" ]
75+
then
76+
read -p "Enter Your Email [$(whoami)@$(hostname -f)]: " EEGITEMAIL
77+
# If Enter Is Pressed
78+
if [[ $EEGITEMAIL = "" ]]
79+
then
80+
EEGITEMAIL=$(whoami)@$(hostname -f)
81+
fi
82+
git config --global user.email $EEGITEMAIL &>> $INSTALLLOG
83+
fi
84+
}
85+
86+
87+
EE101()
88+
{
89+
# Let Copy Some Missing Files
90+
(sed "/allow/,+2d" /usr/share/easyengine/nginx/common/acl.conf; grep -v ^# /etc/nginx/common/allowed_ip.conf ) > /etc/nginx/common/acl.conf
91+
cp -v /usr/share/easyengine/nginx/common/locations.conf /etc/nginx/common
92+
93+
}
94+
95+
96+
97+
# Update EasyEngine (ee)
98+
EECURRENTVERSION=$(ee version | awk '{print($3)}')
99+
EELATESTVERSION=$(curl -sL https://api.github.com/repos/rtCamp/easyengine/releases | grep tag_name | awk '{print($2)}' | cut -d'"' -f2 | cut -c2-)
100+
echo EECURRENTVERSION = $EECURRENTVERSION EELATESTVERSION = $EELATESTVERSION &>> $INSTALLLOG
101+
102+
if [[ $EECURRENTVERSION < $EELATESTVERSION ]]
103+
then
104+
stty echo
105+
read -p "Would You Like To Update EasyEngine To $EELATESTVERSION (y/n): " EEUPDATE
106+
107+
# Check User Choice
108+
if [ "$EEUPDATE" = "y" ] || [ "$EEUPDATE" = "Y" ]
109+
then
110+
# Lets Start Update
111+
echo &>> $INSTALLLOG
112+
echo &>> $INSTALLLOG
113+
echo -e "\033[34mEasyEngine (ee) Update Started [$(date)]\e[0m" | tee -ai $INSTALLLOG
114+
115+
# Update EasyEngine (ee)
116+
EEUPDATE
117+
118+
if [[ $EECURRENTVERSION = 1.0.1 ]]
119+
then
120+
EE101
121+
fi
122+
fi
123+
124+
else
125+
echo "EasyEngine Already Updated To The Latest Version"
126+
fi

0 commit comments

Comments
 (0)