You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

181 lines
5.3 KiB

#!/bin/bash
# Include library
for ee_include in $(find /usr/local/lib/easyengine/ -iname "*.sh"); do
source $ee_include
done
# Main EasyEngine (ee) function to log all the outputs
EasyEngine()
{
# Arguments
EE_FIRST=$1
EE_SECOND=$2
EE_THIRD=$3
EE_FOURTH=$4
EE_FIFTH=$5
# Let's capture the EasyEngine arguments
ee_lib_echo "EasyEngine (ee) execution started [$(date)]" &>> $EE_COMMAND_LOG
ee_lib_echo "EasyEngine (ee) command: $0 $@" &>> $EE_COMMAND_LOG
# EasyEngine version
if [ "$EE_FIRST" = "version" ] || [ "$EE_FIRST" = "--version" ] || [ "$EE_FIRST" = "-v" ];then
# Display Easy Engine Version
echo "EasyEngine (ee) version: $EE_VERSION"
# Display information about NGINX|PHP|MySQL
elif [ "$EE_FIRST" = "info" ];then
if [ "$EE_SECOND" = "nginx" ] || [ "$EE_SECOND" = "php" ] || [ "$EE_SECOND" = "mysql" ]; then
ee_lib_${EE_SECOND}_info
else
ee_lib_nginx_info
ee_lib_php_info
ee_lib_mysql_info
fi
# EasyEngine stack/system
elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then
# EasyEngine install
if [ "$EE_SECOND" = "install" ]; then
if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ] || [ "$EE_THIRD" = "adminer" ] || [ "$EE_THIRD" = "phpmyadmin" ] || [ "$EE_THIRD" = "wpcli" ] || [ "$EE_THIRD" = "utils" ]; then
if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ]; then
# Setup NGINX/PHP repository
ee_mod_repo_$EE_THIRD
# Fix GnuPG key
ee_lib_gpg_key_fix
fi
if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ]; then
# Execute: apt-get update
ee_lib_apt_get_update
# Install NGINX/PHP/MySQL/Postfix package
ee_mod_install_$EE_THIRD
fi
if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ]; then
# Setup NGINX/PHP/MySQL
ee_mod_setup_$EE_THIRD
fi
if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ]; then
# Restart php5-fpm
if [ "$EE_THIRD" = "php" ];then
ee_lib_service php5-fpm restart
# Initialize Git
ee_lib_git_init /etc/php5/
else
# Restart NGINX/MySQL/Postfix
ee_lib_service $EE_THIRD restart
# Initialize Git
ee_lib_git_init /etc/$EE_THIRD/
fi
fi
if [ "$EE_THIRD" = "adminer" ] || [ "$EE_THIRD" = "phpmyadmin" ] || [ "$EE_THIRD" = "wpcli" ] || [ "$EE_THIRD" = "utils" ];then
# Install Adminer/phpMyAdmin/WP-CLI/Utils
ee_ven_install_$EE_THIRD
fi
# Display success message
ee_lib_echo "$EE_THIRD successfully installed"
elif [ "$EE_THIRD" = "" ]; then
# Setup NGINX/PHP repository
ee_mod_repo_nginx
ee_mod_repo_php
# Fix GnuPG key
ee_lib_gpg_key_fix
# Execute: apt-get update
ee_lib_apt_get_update
# Install NGINX/PHP/MySQL/Postfix package
ee_mod_install_nginx
ee_mod_install_php
ee_mod_install_mysql
ee_mod_install_postfix
# Setup NGINX/PHP/MySQL
ee_mod_setup_nginx
ee_mod_setup_php
ee_mod_setup_mysql
# # Restart NGINX/MySQL/Postfix
ee_lib_service nginx php5-fpm mysql restart
# Initialize Git
ee_lib_git_init /etc/nginx/ /etc/php5/ /etc/mysql/ /etc/postfix
# Install Adminer/phpMyAdmin/WP-CLI/Utils
ee_ven_install_adminer
ee_ven_install_phpmyadmin
ee_ven_install_wpcli
ee_ven_install_utils
# Display success message
ee_lib_echo "Successfully installed all packages"
fi
# EasyEngine remove/purge
elif [ "$EE_SECOND" = "remove" ] || [ "$EE_SECOND" = "purge" ]; then
if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ] || [ "$EE_THIRD" = "adminer" ] || [ "$EE_THIRD" = "phpmyadmin" ] || [ "$EE_THIRD" = "wpcli" ] || [ "$EE_THIRD" = "utils" ]; then
# Remove/Purge NGINX/PHP/MySQL/Postfix package
if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ]; then
ee_mod_remove_$EE_THIRD
fi
# Remove/Purge Adminer/phpMyAdmin/WP-CLI/Utils
if [ "$EE_THIRD" = "adminer" ] || [ "$EE_THIRD" = "phpmyadmin" ] || [ "$EE_THIRD" = "wpcli" ] || [ "$EE_THIRD" = "utils" ];then
ee_ven_remove_$EE_THIRD
fi
# Execute: apt-get autoremove
ee_lib_autoremove
# Display success message
if [ "$EE_SECOND" = "remove" ];then
ee_lib_echo "$EE_THIRD successfully removed"
elif [ "$EE_SECOND" = "purge" ];then
ee_lib_echo "$EE_THIRD successfully purged"
fi
elif [ "$EE_THIRD" = "" ]; then
# Remove/Purge NGINX/PHP/MySQL/Postfix package
ee_mod_remove_nginx
ee_mod_remove_php
ee_mod_remove_mysql
ee_mod_remove_postfix
# Install Adminer/phpMyAdmin/WP-CLI/Utils
ee_ven_remove_adminer
ee_ven_remove_phpmyadmin
ee_ven_remove_wpcli
ee_ven_remove_utils
# Execute: apt-get autoremove
ee_lib_autoremove
# Display success message
if [ "$EE_SECOND" = "remove" ];then
ee_lib_echo "Successfully removed all packages"
elif [ "$EE_SECOND" = "purge" ];then
ee_lib_echo "Successfully purged all packages"
fi
fi
elif [ "$EE_SECOND" = "status" ]; then
ee_mod_system_status
elif [ "$EE_SECOND" = "start" ] || [ "$EE_SECOND" = "stop" ] || [ "$EE_SECOND" = "reload" ] || [ "$EE_SECOND" = "restart" ]; then
ee_lib_service nginx php5-fpm mysql postfix $EE_SECOND
fi
fi
}
EasyEngine $@ | tee -ai $EE_COMMAND_LOG