Browse Source

Merged install and update script to single script

bugfixes
gau1991 10 years ago
parent
commit
46c473ba9c
  1. 205
      install

205
upgrade → install

@ -1,11 +1,13 @@
#!/bin/bash #!/bin/bash
# EasyEngine update script. # EasyEngine update script.
# This script is designed to update current EasyEngine from 2.2.2 to 3.x # This script is designed to install latest EasyEngine or
# Define echo function # to update current EasyEngine from 2.x to 3.x
old_ee_version="2.2.3" old_ee_version="2.2.3"
branch=$1 branch=$1
# Define echo function
# Blue color # Blue color
function ee_lib_echo() function ee_lib_echo()
@ -23,6 +25,36 @@ function ee_lib_echo_fail()
echo $(tput setaf 1)$@$(tput sgr0) echo $(tput setaf 1)$@$(tput sgr0)
} }
# Capture errors
function ee_lib_error()
{
echo "[ `date` ] $(tput setaf 1)$@$(tput sgr0)"
exit $2
}
function install_dep()
{
# Execute: apt-get update
ee_lib_echo "Executing apt-get update"
apt-get update &>> /dev/null
# Install Python3 on users system
ee_lib_echo "Installing Python3"
apt-get -y install python3 python3-apt python3-setuptools python3-dev
if [[ $? -ne 0 ]]; then
ee_lib_echo_fail "Unable to install Python3 on system"
exit 1
fi
# Install sqlite3
ee_lib_echo "Installing sqlite3"
apt-get -y install sqlite3
if [[ $? -ne 0 ]]; then
ee_lib_echo_fail "Unable to install sqlite3 on system"
exit 1
fi
}
function sync_db() function sync_db()
{ {
mkdir /var/lib/ee mkdir /var/lib/ee
@ -122,103 +154,96 @@ function sync_db()
} }
# Checking permissions function install_ee3()
if [[ $EUID -ne 0 ]]; then {
ee_lib_echo_fail "Sudo privilege required..." # Remove old clone of EasyEngine (ee) if any
ee_lib_echo_fail "Uses: wget -qO ee rt.cx/ee && sudo bash ee" rm -rf /tmp/easyengine &>> /dev/null
exit 1
fi
# Check old EasyEngine is installed or not
if [ ! -f /usr/local/sbin/easyengine ]; then
ee_lib_echo_fail "EasyEngine 2.0 not found"
exit 1
fi
# Check old EasyEngine version # Clone EE 3.0 Python branch
ee version | grep ${old_ee_version} &>> /dev/null ee_lib_echo "Cloning EasyEngine 3.0"
if [[ $? -ne 0 ]]; then if [ "$branch" = "" ]; then
ee_lib_echo_fail "EasyEngine $old_ee_version not found on your system" branch=python
ee_lib_echo_fail "Please update is using command: ee update" fi
exit 1
fi
# Capture errors git clone -b $branch https://github.com/rtCamp/easyengine.git /tmp/easyengine --quiet > /dev/null || ee_lib_error "Unable to clone EasyEngine, exit status" 1
function ee_lib_error()
{
echo "[ `date` ] $(tput setaf 1)$@$(tput sgr0)"
exit $2
}
# Execute: apt-get update cd /tmp/easyengine
ee_lib_echo "Executing apt-get update" ee_lib_echo "Installing EasyEngine 3.0"
apt-get update &>> /dev/null python3 setup.py install || ee_lib_error "Unable to install EasyEngine 3.0, exit status " 1
# Install Python3 on users system }
ee_lib_echo "Installing Python3"
apt-get -y install python3 python3-apt python3-setuptools python3-dev
if [[ $? -ne 0 ]]; then
ee_lib_echo_fail "Unable to install Python3 on system"
exit 1
fi
# Install sqlite3 function update_to_ee3()
ee_lib_echo "Installing sqlite3" {
apt-get -y install sqlite3 # Preserve old configuration
ee_lib_echo "Updating EasyEngine 3.0 configuration"
grant_host=$(grep grant-host /etc/easyengine/ee.conf | awk '{ print $3 }')
db_name=$(grep db-name /etc/easyengine/ee.conf | awk '{ print $3 }')
db_user=$(grep db-name /etc/easyengine/ee.conf | awk '{ print $3 }')
wp_prefix=$(grep prefix /etc/easyengine/ee.conf | awk '{ print $3 }')
wp_user=$(grep 'user ' /etc/easyengine/ee.conf | grep -v db-user |awk '{ print $3 }')
wp_pass=$(grep password /etc/easyengine/ee.conf | awk '{ print $3 }')
wp_email=$(grep email /etc/easyengine/ee.conf | awk '{ print $3 }')
ip_addr=$(grep ip-address /etc/easyengine/ee.conf |awk -F'=' '{ print $2 }')
sed -i "s/ip-address.*/ip-address = ${ip_addr}/" /etc/ee/ee.conf && \
sed -i "s/grant-host.*/grant-host = ${grant_host}/" /etc/ee/ee.conf && \
sed -i "s/db-name.*/db-name = ${db-name}/" /etc/ee/ee.conf && \
sed -i "s/db-user.*/db-user = ${db_user}/" /etc/ee/ee.conf && \
sed -i "s/prefix.*/prefix = ${wp_prefix}/" /etc/ee/ee.conf && \
sed -i "s/^user.*/user = ${wp_user}/" /etc/ee/ee.conf && \
sed -i "s/password.*/password = ${wp_password}/" /etc/ee/ee.conf && \
sed -i "s/email.*/email = ${wp_email}/" /etc/ee/ee.conf || ee_lib_error "Unable to update configuration, exit status " 1
# Remove old EasyEngine
ee_lib_echo "Removing EasyEngine 2"
rm -rf /etc/bash_completion.d/ee /etc/easyengine/ /usr/share/easyengine/ /usr/local/lib/easyengine /usr/local/sbin/easyengine /usr/local/sbin/ee /var/log/easyengine
if [[ $? -ne 0 ]]; then }
ee_lib_echo_fail "Unable to install sqlite3 on system"
exit 1
fi
sync_db function git_init()
{
# Do git intialisation on EasyEngine configuration
cd /etc/ee
if [ ! -d /etc/ee/.git ]; then
git init > /dev/null
fi
git add .
git commit -am "Installed/Updated to EasyEngine 3" > /dev/null
# Remove old version of EasyEngine (ee) }
rm -rf /tmp/easyengine &>> /dev/null
# Clone EE 3.0 Python branch # Checking permissions
ee_lib_echo "Cloning EasyEngine 3.0" if [[ $EUID -ne 0 ]]; then
if [ "$branch" = "" ]; then ee_lib_echo_fail "Sudo privilege required..."
branch=python ee_lib_echo_fail "Uses: wget -qO ee rt.cx/ee && sudo bash ee"
exit 1
fi fi
git clone -b $branch https://github.com/rtCamp/easyengine.git /tmp/easyengine > /dev/null || ee_lib_error "Unable to clone EasyEngine, exit status" 1 # Check old EasyEngine is installed or not
if [ ! -f /usr/local/sbin/easyengine ]; then
cd /tmp/easyengine # Check latest EasyEngine is installed or not
ee_lib_echo "Installing EasyEngine 3.0" if [ ! -f /usr/local/bin/ee ]; then
python3 setup.py install || ee_lib_error "Unable to install EasyEngine 3.0, exit status " 1 install_dep
install_ee3
# Preserve old configuration git_init
ee_lib_echo "Updating EasyEngine 3.0 configuration" else
ee_lib_echo_fail "EasyEngine 3 allready installed on ur system"
grant_host=$(grep grant-host /etc/easyengine/ee.conf | awk '{ print $3 }') exit 1
db_name=$(grep db-name /etc/easyengine/ee.conf | awk '{ print $3 }') fi
db_user=$(grep db-name /etc/easyengine/ee.conf | awk '{ print $3 }') else
wp_prefix=$(grep prefix /etc/easyengine/ee.conf | awk '{ print $3 }') # Check old EasyEngine version
wp_user=$(grep 'user ' /etc/easyengine/ee.conf | grep -v db-user |awk '{ print $3 }') ee version | grep ${old_ee_version} &>> /dev/null
wp_pass=$(grep password /etc/easyengine/ee.conf | awk '{ print $3 }') if [[ $? -ne 0 ]]; then
wp_email=$(grep email /etc/easyengine/ee.conf | awk '{ print $3 }') ee_lib_echo_fail "EasyEngine $old_ee_version not found on your system"
ip_addr=$(grep ip-address /etc/easyengine/ee.conf |awk -F'=' '{ print $2 }') ee_lib_echo_fail "Please update it using command: ee update"
exit 1
sed -i "s/ip-address.*/ip-address = ${ip_addr}/" /etc/ee/ee.conf && \ fi
sed -i "s/grant-host.*/grant-host = ${grant_host}/" /etc/ee/ee.conf && \ sync_db
sed -i "s/db-name.*/db-name = ${db-name}/" /etc/ee/ee.conf && \ install_dep
sed -i "s/db-user.*/db-user = ${db_user}/" /etc/ee/ee.conf && \ install_ee3
sed -i "s/prefix.*/prefix = ${wp_prefix}/" /etc/ee/ee.conf && \ update_to_ee3
sed -i "s/^user.*/user = ${wp_user}/" /etc/ee/ee.conf && \ git_init
sed -i "s/password.*/password = ${wp_password}/" /etc/ee/ee.conf && \
sed -i "s/email.*/email = ${wp_email}/" /etc/ee/ee.conf || ee_lib_error "Unable to update configuration, exit status " 1
# Remove old EasyEngine
ee_lib_echo "Removing EasyEngine 2"
rm -rf /etc/bash_completion.d/ee /etc/easyengine/ /usr/share/easyengine/ /usr/local/lib/easyengine /usr/local/sbin/easyengine /usr/local/sbin/ee /var/log/easyengine
ee_lib_echo "Doing GIT init"
cd /etc/ee
if [ ! -d /etc/ee/.git ]; then
git init > /dev/null
fi fi
git commit -am "Update EasyEngine 2 to EasyEngine 3" > /dev/null
ee_lib_echo "Successfully update to EasyEngine 3"
Loading…
Cancel
Save