diff --git a/README.md b/README.md index 1f926ccb..ea9635d7 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,61 @@ -rtAdmin -======= +EasyEngine +========== Admin tools for Nginx based wordpress sites management. This is work in PROGRESS. This will break things on your end most likely! +# TODO + +## Usage + +### engine Commands: + +`engine site` #site-specific commands + +`engine system` system-wide commands + +`engine config` configuration commands + +### engine site + +`engine site create [--with-wordpress]` + +`engine site read --active` + +`engine site update ` + +`engine site delete ` + +### engine system + +`engine system install [php mysql nginx apc postfix] [--all] [--source]` + +`engine system upgrade [php mysql nginx apc postfix] [--all]` + +`engine system remove [php mysql nginx apc postfix] [--all]` + +`engine system purge [php mysql nginx apc postfix] [--all]` + +### engine config + +`engine config set [memory | timeout] [value]` + +`engine config get [[memory | timeout]|--all]` + +`engine config --interactive` #reconfigure everything + + +## Files + +### Logs location: + +Main Log: `/var/log/easyengine/main.log` + +Debug Log: `/var/log/easyengine/debug.log` + + -=== Notes: diff --git a/config-sample.php b/php/config-sample.php similarity index 100% rename from config-sample.php rename to php/config-sample.php diff --git a/create.php b/php/create.php similarity index 91% rename from create.php rename to php/create.php index 9fe0a506..42fccd25 100755 --- a/create.php +++ b/php/create.php @@ -78,8 +78,14 @@ $result = system("mkdir " . $domain['htdocs']); $result = system("mkdir " . $domain['logs']); //create log files -$result = system("touch " . $domain['logs'] . "/access.log"); -$result = system("touch " . $domain['logs'] . "/error.log"); +//in nginx folder +$result = system("touch " . "/var/log/nginx/" . $domain['name'] . ".access.log"); +$result = system("touch " . "/var/log/nginx/" . $domain['name'] . ".error.log"); + +//symlink +$result = system("ln -s " . "/var/log/nginx/" . $domain['name'] . ".access.log " . $domain['logs'] . "/access.log"); +$result = system("ln -s " . "/var/log/nginx/" . $domain['name'] . ".error.log " . $domain['logs'] . "/error.log"); + //Error check if ($result != '') { diff --git a/example.com b/php/example.com similarity index 56% rename from example.com rename to php/example.com index 4c153f0f..92244579 100755 --- a/example.com +++ b/php/example.com @@ -1,9 +1,8 @@ server{ - server_name example.com; - listen 80; + server_name www.example.com example.com; - access_log /var/www/example.com/logs/access.log ; - error_log /var/www/example.com/logs/error.log; + access_log /var/log/nginx/example.com.access.log ; + error_log /var/log/nginx/example.com.error.log; root /var/www/example.com/htdocs; index index.php index.html index.htm; @@ -13,12 +12,11 @@ server{ include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } #root dir location / { autoindex on; - try_files $uri $uri/ /index.php?q=$uri&$args; + try_files $uri $uri/ /index.php; } } diff --git a/init.php b/php/init.php similarity index 100% rename from init.php rename to php/init.php diff --git a/move.php b/php/move.php similarity index 100% rename from move.php rename to php/move.php diff --git a/remove.php b/php/remove.php similarity index 100% rename from remove.php rename to php/remove.php diff --git a/test.php b/php/test.php similarity index 100% rename from test.php rename to php/test.php diff --git a/touch.php b/php/touch.php similarity index 100% rename from touch.php rename to php/touch.php diff --git a/setup/install-mysql.sh b/setup/install-mysql.sh new file mode 100755 index 00000000..04cdbd9e --- /dev/null +++ b/setup/install-mysql.sh @@ -0,0 +1,20 @@ +#!/bin/bash + + + +# Capture Errors +OwnError() +{ + #echo $@ >&2 + clear + echo -e "[ $0 ][ `date` ] \033[31m $@ \e[0m" | tee -ai /var/log/easyengine/error.log + exit 100 +} + + +# Update The APT Cache +sudo apt-get update || OwnError "Unable To Update APT Cache :(" + +# Install MySQL +sudo apt-get -y install mysql-server mysqltuner || OwnError "Unable To Install MySQL :(" + diff --git a/setup/install-nginx.sh b/setup/install-nginx.sh new file mode 100755 index 00000000..c558d091 --- /dev/null +++ b/setup/install-nginx.sh @@ -0,0 +1,28 @@ +#!/bin/bash + + + +# Capture Errors +OwnError() +{ + #echo $@ >&2 + clear + echo -e "[ $0 ][ `date` ] \033[31m $@ \e[0m" | tee -ai /var/log/easyengine/error.log + exit 100 +} + + +# Install Python Software Properties +sudo apt-get -y install python-software-properties || OwnError "Unable To Install Python Software Properties :(" + +# Add Nginx Launchpad Repository +sudo add-apt-repository ppa:nginx/stable || OwnError "Unable To Add Nginx Launchpad Repository :(" + +# Update The APT Cache +sudo apt-get update || OwnError "Unable To Update APT Cache :(" + +# Install Nginx +sudo apt-get -y install nginx || OwnError "Unable To Install Nginx :(" + +# Check Nginx Version +nginx -v || OwnError "Unable To Detect Nginx Version :(" diff --git a/setup/install-php5.sh b/setup/install-php5.sh new file mode 100755 index 00000000..cd94df07 --- /dev/null +++ b/setup/install-php5.sh @@ -0,0 +1,29 @@ +#!/bin/bash + + + +# Capture Errors +OwnError() +{ + #echo $@ >&2 + clear + echo -e "[ $0 ][ `date` ] \033[31m $@ \e[0m" | tee -ai /var/log/easyengine/error.log + exit 100 +} + + +# Install Python Software Properties +sudo apt-get -y install python-software-properties || OwnError "Unable To Install Python Software Properties :(" + +# Add Nginx Launchpad Repository +sudo add-apt-repository ppa:ondrej/php5 || OwnError "Unable To Add PHP5 Launchpad Repository :(" + +# Update The APT Cache +sudo apt-get update || OwnError "Unable To Update APT Cache :(" + +# Install PHP5 +sudo apt-get -y install php5-common php5-mysql php5-xmlrpc php5-cgi php5-curl php5-gd php5-cli php5-fpm php-apc php-pear php5-dev php5-imap php5-mcrypt || OwnError "Unable To Install PHP5 :(" + +# Check PHP5 Version +php -v || OwnError "Unable To Detect PHP Version :(" + diff --git a/setup/install-postfix.sh b/setup/install-postfix.sh new file mode 100755 index 00000000..2758b7b5 --- /dev/null +++ b/setup/install-postfix.sh @@ -0,0 +1,20 @@ +#!/bin/bash + + + +# Capture Errors +OwnError() +{ + #echo $@ >&2 + clear + echo -e "[ $0 ][ `date` ] \033[31m $@ \e[0m" | tee -ai /var/log/easyengine/error.log + exit 100 +} + + +# Update The APT Cache +sudo apt-get update || OwnError "Unable To Update APT Cache :(" + +# Install Postfix +sudo apt-get -y install postfix || OwnError "Unable To Install Postfix :(" + diff --git a/setup/pre-checks.sh b/setup/pre-checks.sh new file mode 100755 index 00000000..fc457c31 --- /dev/null +++ b/setup/pre-checks.sh @@ -0,0 +1,65 @@ +#!/bin/bash + + + +# Capture Errors +OwnError() +{ + #echo $@ >&2 + clear + echo -e "[ $0 ][ `date` ] \033[31m $@ \e[0m" | tee -ai /var/log/easyengine/error.log + exit 100 +} + + +# Checking Permissions +Permission=$(id -u) +if [ $Permission -ne 0 ] +then + echo -e "\033[31m Root Privilege Required... \e[0m" + echo -e "\033[31m Uses: sudo $0 \e[0m" + exit 100 +fi + +# Checking Logs Directory +if [ ! -d /var/log/easyengine ] +then + mkdir -p /var/log/easyengine || OwnError "Unable To Create Log Directory /var/log/easyengine :(" +#else + #echo -e "\033[34m Easy Engine Log Directory Found \e[0m" + #exit +fi + + +# Checking Tee +if [ ! -x /usr/bin/tee ] +then + echo -e "\033[31m Tee Command Not Found !! \e[0m" + echo -e "\033[34m Installing Tee \e[0m" + sudo apt-get -y install coreutils || OwnError "Unable To Install Tee :(" +fi + +# Checking Wget +if [ ! -x /usr/bin/wget ] +then + echo -e "\033[31m Wget Command Not Found !! \e[0m" + echo -e "\033[34m Installing Wget \e[0m" + sudo apt-get -y install wget || OwnError "Unable To Install Wget :(" +fi + +# Checking Tar +if [ ! -x /bin/tar ] +then + echo -e "\033[31m Tar Command Not Found !! \e[0m" + echo -e "\033[34m Installing Tar \e[0m" + sudo apt-get -y install tar || OwnError "Unable To Install Tar :(" +fi + +# Checking Name Servers +if [[ -z $(cat /etc/resolv.conf | grep -v ^#) ]] +then + echo -e "\033[31m No Nameservers Detected !! \e[0m" + echo -e "\033[31m Please configure /etc/resolv.conf \e[0m" + exit 100 +fi +