Browse Source

Divide EasyEngine functions into library

old-stable
Mitesh Shah 11 years ago
parent
commit
9c1b0daefa
  1. 6
      src/lib/APT_GET_UPDATE.sh
  2. 6
      src/lib/DOT_DEB_GPG_KEY.sh
  3. 15
      src/lib/ECHO.sh
  4. 6
      src/lib/EE_ERROR.sh
  5. 6
      src/lib/INSTALL_NGINX.sh
  6. 25
      src/lib/NGINX_REPO.sh
  7. 11
      src/lib/PACKAGE_CHECK.sh
  8. 29
      src/lib/PHP_REPO.sh
  9. 15
      src/lib/PYTHON_SOFTWARE_PROPERTIES.sh
  10. 7
      src/lib/VARIABLE.sh

6
src/lib/APT_GET_UPDATE.sh

@ -0,0 +1,6 @@
# Update apt-get cache
function APT_GET_UPDATE()
{
ECHO_BLUE "apt-get update, Please Wait..."
apt-get update &>> $EE_LOG || EE_ERROR "Unable to execute apt-get update"
}

6
src/lib/DOT_DEB_GPG_KEY.sh

@ -0,0 +1,6 @@
# Fetch and install dotdeb GnuPG key
function DOT_DEB_GPG_KEY()
{
wget --no-check-certificate -cqO /tmp/dotdeb.gpg http://www.dotdeb.org/dotdeb.gpg || EE_ERROR "Unable to download dotdeb GnuPG key"
apt-key add /tmp/dotdeb.gpg &>> $EE_LOG || EE_ERROR "Unable to add dotdeb GnuPG key"
}

15
src/lib/ECHO.sh

@ -0,0 +1,15 @@
# Define echo function for each color
function ECHO_RED()
{
echo $(tput setaf 1)$@$(tput sgr0)
}
function ECHO_BLUE()
{
echo $(tput setaf 4)$@$(tput sgr0)
}
function ECHO_WHITE()
{
echo $(tput setaf 7)$@$(tput sgr0)
}

6
src/lib/EE_ERROR.sh

@ -0,0 +1,6 @@
# Capture errors
function EE_ERROR()
{
echo "[ `date` ] $(tput setaf 1)$@$(tput sgr0)" | tee -ai $ERROR_LOG
exit 102
}

6
src/lib/INSTALL_NGINX.sh

@ -0,0 +1,6 @@
# Install nginx
function INSTALL_NGINX()
{
ECHO_BLUE "Installing $NGINXPACKAGE, please wait..."
$APT_GET install $NGINXPACKAGE || EE_ERROR "Unable to install $NGINXPACKAGE"
}

25
src/lib/NGINX_REPO.sh

@ -0,0 +1,25 @@
# Install nginx
function NGINX_REPO()
{
if [ "$LINUX_DISTRO" == "Ubuntu" ]; then
# Add rtCamp nginx launchpad repository
ECHO_BLUE "Adding rtCamp nginx launchpad repository, please wait..."
add-apt-repository -y ppa:rtcamp/nginx &>> $EE_LOG \
|| EE_ERROR "Unable to add rtCamp nginx launchpad repository"
# Specify nginx package
NGINX_PACKAGE=nginx-custom
elif [ "$LINUX_DISTRO" == "Debian" ]; then
# Add dotdeb nginx repository
ECHO_BLUE "Adding dotdeb nginx repository, please wait..."
echo "deb http://packages.dotdeb.org $(lsb_release -c | awk '{print($2)}') all" > /etc/apt/sources.list.d/dotdeb-$(lsb_release -c | awk '{print($2)}').list \
|| EE_ERROR "Unable to add dotdeb nginx repository"
# Fetch and install dotdeb GnuPG key
DOT_DEB_GPG_KEY
# Specify nginx package
NGINX_PACKAGE=nginx-full
fi
}

11
src/lib/PACKAGE_CHECK.sh

@ -0,0 +1,11 @@
# Check the specified package is instlled or not
function PACKAGE_CHECK()
{
for i in $@;do
dpkg --get-selections | grep -v deinstall | grep $i &>> INSTALL_LOG
# Generate a list of not installed package
if [ $? -ne 0 ]; then
PACKAGE_NAME="$PACKAGE_NAME $i"
fi
done
}

29
src/lib/PHP_REPO.sh

@ -0,0 +1,29 @@
# Install php5-fpm
function PHP_REPO()
{
# Check LINUX_DISTRO
if [ "$LINUX_DISTRO" == "Ubuntu" ]; then
# Add ondrej php5 launchpad repository
ECHO_BLUE "Adding ondrej php5 launchpad repository, please wait..."
add-apt-repository -y ppa:ondrej/php5 &>> $EE_LOG \
|| EE_ERROR "Unable to add ondrej php5 launchpad repository"
# Detect Debian version to select php repository
elif [ "$LINUX_DISTRO" == "Debian" ]; then
DEBIAN_VERSION=$(lsb_release -r | awk '{print($2)}' | cut -d'.' -f1)
# Add dotdeb php5.x repository
if [ $DEBIAN_VERSION -eq 6 ]; then
ECHO_BLUE "Adding dotdeb php5.4 repository, please wait..."
echo "deb http://packages.dotdeb.org $(lsb_release -c | awk '{print($2)}')-php54 all" > /etc/apt/sources.list.d/dotdeb-$(lsb_release -c | awk '{print($2)}')-php54.list \
|| EE_ERROR "Unable to add dotdeb php5.4 repository"
elif [ $DEBIAN_VERSION -eq 7 ]; then
ECHO_BLUE "Adding dotdeb php5.5 repository, please wait..."
echo "deb http://packages.dotdeb.org $(lsb_release -c | awk '{print($2)}')-php55 all" > /etc/apt/sources.list.d/dotdeb-$(lsb_release -c | awk '{print($2)}')-php55.list \
|| EE_ERROR "Unable to add dotdeb php5.5 repository"
fi
# Fetch and install dotdeb GnuPG key
DOT_DEB_GPG_KEY
fi
}

15
src/lib/PYTHON_SOFTWARE_PROPERTIES.sh

@ -0,0 +1,15 @@
# Install add-apt-repository command
PYTHON-SOFTWARE-PROPERTIES()
{
if [ "$LINUX_DISTRO" == "Ubuntu" ]; then
# Install python-software-properties and software-properties-common
ECHO_BLUE "Installing python-software-properties and software-properties-common, please wait..."
$APT_GET install python-software-properties software-properties-common \
|| EE_ERROR "Unable to install python-software-properties and software-properties-common"
elif [ "$LINUX_DISTRO" == "Debian" ]; then
# Install python-software-properties
ECHO_BLUE "Installing python-software-properties, please wait..."
$APT_GET install python-software-properties \
|| EE_ERROR "Unable to install python-software-properties"
fi
}

7
src/lib/VARIABLE.sh

@ -0,0 +1,7 @@
# Define variables
LOG_DIR=/var/log/easyengine
EE_LOG=/var/log/easyengine/ee.log
ERROR_LOG=/var/log/easyengine/error.log
LINUX_DISTRO=$(lsb_release -i |awk '{print $3}')
IP_ADDRESS=$(grep ip_address /etc/easyengine/ee.conf | cut -d'=' -f2 | sed 's/ //g' | tr ',' '\n')
APT_GET=$(grep apt-get-assume-yes /etc/easyengine/ee.conf | grep -i true &> /dev/null && echo apt-get -y)
Loading…
Cancel
Save