From b43549242a3c863c90aaa2d12fb4a2768e792e6c Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 1 Oct 2014 12:35:10 +0530 Subject: [PATCH] Minor Update on check stack packages --- bin/easyengine | 38 +++++--------------------- src/lib/ee_lib_stack_packages.sh | 46 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 32 deletions(-) create mode 100644 src/lib/ee_lib_stack_packages.sh diff --git a/bin/easyengine b/bin/easyengine index e0d4a416..07de81b5 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -451,47 +451,21 @@ elif [ "$EE_FIRST" = "site" ]; then fi if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_lib_package_check $EE_NGINX_PACKAGE - if [ "$EE_PACKAGE_NAME" != "" ]; then - # The following command creates its own sub-shell - # and our ee_lib_error function only exit from that sub-shell - # so we need to exit from parent shell also - ee stack install nginx || exit $? - fi + ee_lib_stack_packages nginx + fi if [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_lib_package_check php5-common php5-mysqlnd php5-xmlrpc \ - php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ - php5-memcache memcached php5-geoip - if [ "$EE_PACKAGE_NAME" != "" ]; then - # The following command creates its own sub-shell - # and our ee_lib_error function only exit from that sub-shell - # so we need to exit from parent shell also - ee stack install php || exit $? - fi + ee_lib_stack_packages php fi if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - mysqladmin ping &>> $EE_COMMAND_LOG - if [ $? -ne 0 ]; then - # The following command creates its own sub-shell - # and our ee_lib_error function only exit from that sub-shell - # so we need to exit from parent shell also - ee stack install mysql || exit $? - fi + ee_lib_stack_packages mysql fi if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_ven_install_wpcli fi - - ee_lib_package_check postfix - if [ "$EE_PACKAGE_NAME" != "" ]; then - # The following command creates its own sub-shell - # and our ee_lib_error function only exit from that sub-shell - # so we need to exit from parent shell also - ee stack install postfix || exit $? - fi - + ee_lib_stack_packages postfix + # Lets create HTML|PHP|MySQL website if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then # Configure variable diff --git a/src/lib/ee_lib_stack_packages.sh b/src/lib/ee_lib_stack_packages.sh new file mode 100644 index 00000000..619f4475 --- /dev/null +++ b/src/lib/ee_lib_stack_packages.sh @@ -0,0 +1,46 @@ +# Check the specified package is installed or not + +function ee_lib_stack_packages() +{ + local ee_stack_package + + for ee_stack_package in $@;do + # Check NGINX installed & install if not + if [ "$ee_stack_package" = "nginx" ] + ee_lib_package_check $EE_NGINX_PACKAGE + if [ "$EE_PACKAGE_NAME" != "" ]; then + # The following command creates its own sub-shell + # and our ee_lib_error function only exit from that sub-shell + # so we need to exit from parent shell also + ee stack install nginx || exit $? + fi + # Check PHP installed & install if not + elif [ "$ee_stack_package" = "php" ]; then + ee_lib_package_check php5-fpm + if [ "$EE_PACKAGE_NAME" != "" ]; then + # The following command creates its own sub-shell + # and our ee_lib_error function only exit from that sub-shell + # so we need to exit from parent shell also + ee stack install php || exit $? + fi + # Check MySQL installed & install if not + elif [ "$ee_stack_package" = "mysql" ]; then + mysqladmin ping &>> $EE_COMMAND_LOG + if [ $? -ne 0 ]; then + # The following command creates its own sub-shell + # and our ee_lib_error function only exit from that sub-shell + # so we need to exit from parent shell also + ee stack install mysql || exit $? + fi + # Check Postfix installed & install if not + elif [ "$ee_stack_package" = "postfix" ]; then + ee_lib_package_check postfix + if [ "$EE_PACKAGE_NAME" != "" ]; then + # The following command creates its own sub-shell + # and our ee_lib_error function only exit from that sub-shell + # so we need to exit from parent shell also + ee stack install postfix || exit $? + fi + fi + done +}