From 8766005eabe4093f34edfb147fb5614aafe245c5 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 12 Sep 2012 20:14:03 +0530 Subject: [PATCH 01/10] symlinks for nginx logs --- create.php | 10 ++++++++-- example.com | 10 ++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/create.php b/create.php index 9fe0a506..42fccd25 100755 --- a/create.php +++ b/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/example.com index 4c153f0f..92244579 100755 --- a/example.com +++ b/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; } } From 7afb9fc4c12ca0a89f24a88cc72f603bb5d9e8cb Mon Sep 17 00:00:00 2001 From: Rahul Bansal Date: Tue, 9 Oct 2012 17:45:35 +0530 Subject: [PATCH 02/10] moved php code into a folder --- config-sample.php | 39 ------------ create.php | 158 ---------------------------------------------- example.com | 22 ------- init.php | 54 ---------------- move.php | 156 --------------------------------------------- remove.php | 107 ------------------------------- test.php | 11 ---- touch.php | 99 ----------------------------- 8 files changed, 646 deletions(-) delete mode 100755 config-sample.php delete mode 100755 create.php delete mode 100755 example.com delete mode 100755 init.php delete mode 100755 move.php delete mode 100755 remove.php delete mode 100755 test.php delete mode 100755 touch.php diff --git a/config-sample.php b/config-sample.php deleted file mode 100755 index a2582b92..00000000 --- a/config-sample.php +++ /dev/null @@ -1,39 +0,0 @@ - diff --git a/create.php b/create.php deleted file mode 100755 index 42fccd25..00000000 --- a/create.php +++ /dev/null @@ -1,158 +0,0 @@ - /dev/null"; -$result = system($command); - -//Error check -if ($result != '') { - die("\nError encountered while extracting latest wordpress in directory " . $domain['rootdir'] . "\n"); -} - -$command = "mv " . $domain['htdocs'] . "/wordpress/* " . $domain['htdocs'] . "/"; -echo "\n COMMAND :: $command \n"; -$result = system($command); - -//Error check -if ($result != '') { - die("\nError encountered while moving latest wordpress in directory " . $domain['rootdir'] . "\n" . $result); -} - -/** - * MySQL Creation - */ - -$command = "mysql -h " . $local_env['mysql_host'] . " -u " . $local_env['mysql_user'] . " -p" . $local_env['mysql_pass'] . " -e 'create database `'" . $domain['name'] . "'` '"; -$result = system($command); - -/* - * Create wp-config.php - */ -$wp_config_sample = $domain['htdocs'] . "/wp-config-sample.php"; - -$command = "sed s/database_name_here/{$domain['name']}/ $wp_config_sample | sed s/username_here/{$local_env['mysql_user']}/ | sed s/password_here/{$local_env['mysql_pass']}/ > {$domain['htdocs']}/wp-config.php"; - -$result = system($command); - -/** - * Chown - */ -$command = "chown -R " . $local_env['nginx_user'] . ":" . $local_env['nginx_group'] . " " . $domain['rootdir']; -echo "\n COMMAND :: $command \n"; -$result = system($command); - -//Error check -if ($result != '') { - die("\nError encountered while charging owner of " . $domain['rootdir'] . "\n" . $result); -} - - -/** - * ALL SEENS WELL - Restart nginx - */ -echo "\n Relaoding nginx configuration...\n\n"; -system('service nginx reload'); - -/** - * THE END - */ -//just echo URL for new domain like http://$domain -//user will click it and verify if its working fine! ;-) - -echo $domain['name'] . " Successfully created\n\n"; - -?> diff --git a/example.com b/example.com deleted file mode 100755 index 92244579..00000000 --- a/example.com +++ /dev/null @@ -1,22 +0,0 @@ -server{ - server_name www.example.com example.com; - - 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; - - ## PHP with FATSCGI - location ~ \.php$ { - include /etc/nginx/fastcgi_params; - fastcgi_pass 127.0.0.1:9000; - fastcgi_index index.php; - } - - #root dir - location / { - autoindex on; - try_files $uri $uri/ /index.php; - } -} diff --git a/init.php b/init.php deleted file mode 100755 index 28346bde..00000000 --- a/init.php +++ /dev/null @@ -1,54 +0,0 @@ - diff --git a/move.php b/move.php deleted file mode 100755 index 78590706..00000000 --- a/move.php +++ /dev/null @@ -1,156 +0,0 @@ - $domain - */ -function move_domain($usr_domain) { - global $local_env, $remote_env; - - if(trim($usr_domain) == ''){ - echo "\n CURRENT DOMAIN IS SKIPPED\n"; - return; - } - - /* - * Set domain environment values - */ - $domain['name'] = $usr_domain; - $domain['conf'] = $local_env['nginx_dir_sites_avilable'] . '/' . $domain['name']; - $domain['rootdir'] = $local_env['webroot'] . '/' . $domain['name']; - $domain['htdocs'] = $domain['rootdir'] . '/' . $local_env['htdocs'] ; - $domain['logs'] = $domain['rootdir'] . '/' . $local_env['logs'] ; - - /** - * Check if domain config file already exists - */ - if (file_exists($domain['conf'])) { - echo "\nConfiguration files for domain '" . $domain['name'] . "'already exists :: " . $domain['conf']; - echo "\nDo you want to overwrite previous configuration? [Y/N] (default=Y)"; - - if (in_array(strtolower(fgets(STDIN)), array('n', 'no'))) { - die("\nYou choose to terminate this script! Bye-Bye!!! \n"); - } - } - - /** - * At this point - either domain config file doesn't exist or user showed interest in overwriting it - * In either case... - * Create nginx conf for $domain in /etc/nginx/sites-available/$domain - * TODO :: Provide options to add supercache and/or w3total cache rules - */ - /** - * Create config file - */ - $nginx_conf = file_get_contents($local_env['default_conf']); - $nginx_conf = str_replace($local_env['default_domain'], $domain['name'], $nginx_conf); - file_put_contents($domain['conf'], $nginx_conf); - -//Error Check - if config file is created successfully or not - if (!file_exists($domain['conf'])) { - die("\nError encounterd while creating " . $domain['conf']); - } - - /** - * Linking config file - */ - echo "\nCreating Symbolic Link..\n"; - $command = "sudo ln -s " . $domain['conf'] . " " . $local_env['nginx_dir_sites_enabled']; - $result = system($command); - -//Error check - if linking config file succeed - if ($result != '') { - die("\nError encountered while creating script. Please check if file '" . $domain['conf'] . "'is created or not!\n"); - } - -//Go Ahead. -// echo "Nginx configuration for '" . $domain['name'] . "' is created successfully"; - - /** - * Create webroot dirs for new domain - */ -//create dirs - $result = system("mkdir " . $domain['rootdir']); - $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"); - -//Error check - if ($result != '') { - die("\nError encountered while creating websites directories & files for " . $domain['name'] . "\n"); - } - - /** - * moving wordpress in new webroot dir - */ -//export remote db - $command = "rsync --exclude '*.iso' -avz {$remote_env['ssh_user']}@{$remote_env['host']}:{$remote_env['webroot']}/{$domain['name']}/htdocs/* {$domain['htdocs']}/"; - $result = system($command); - - - /** - * MySQL Moving - */ - $wp_config = get_defines($domain['htdocs'] . '/wp-config.php'); - - $command = "mysqldump -u {$wp_config['DB_USER']} -p{$wp_config['DB_PASSWORD']} -h {$remote_env['host']} --databases '{$wp_config['DB_NAME']}' > {$domain['rootdir']}/{$domain['name']}.sql"; -// echo "\n" . $command . "\n"; - $result = system($command); - - $command = "mysql -h {$local_env['mysql_host']} -u {$local_env['mysql_user']} -p{$local_env['mysql_pass']} < {$domain['rootdir']}/{$domain['name']}.sql"; -// echo "\n\n" . $command . "\n"; - $result = system($command); - - /* - * Create wp-config.php - */ - //this may not be needed as we already have wp-config.php present for remote WordPress - //@TODO we need to replace DB_HOST though - - - /** - * Chown - */ - $command = "chown -R " . $local_env['nginx_user'] . ":" . $local_env['nginx_group'] . " " . $domain['rootdir']; - echo "\n COMMAND :: $command \n"; - $result = system($command); - -//Error check - if ($result != '') { - die("\nError encountered while chaging owner of " . $domain['rootdir'] . "\n" . $result); - } -} -?> \ No newline at end of file diff --git a/remove.php b/remove.php deleted file mode 100755 index 25c64788..00000000 --- a/remove.php +++ /dev/null @@ -1,107 +0,0 @@ - \ No newline at end of file diff --git a/test.php b/test.php deleted file mode 100755 index a83076cf..00000000 --- a/test.php +++ /dev/null @@ -1,11 +0,0 @@ - diff --git a/touch.php b/touch.php deleted file mode 100755 index 1587dd02..00000000 --- a/touch.php +++ /dev/null @@ -1,99 +0,0 @@ - \ No newline at end of file From e8825baf19fe880d0918f90d032f5ed69401ece4 Mon Sep 17 00:00:00 2001 From: Rahul Bansal Date: Tue, 9 Oct 2012 17:46:09 +0530 Subject: [PATCH 03/10] moved php code into a folder --- php/config-sample.php | 39 +++++++++++ php/create.php | 158 ++++++++++++++++++++++++++++++++++++++++++ php/example.com | 22 ++++++ php/init.php | 54 +++++++++++++++ php/move.php | 156 +++++++++++++++++++++++++++++++++++++++++ php/remove.php | 107 ++++++++++++++++++++++++++++ php/test.php | 11 +++ php/touch.php | 99 ++++++++++++++++++++++++++ 8 files changed, 646 insertions(+) create mode 100755 php/config-sample.php create mode 100755 php/create.php create mode 100755 php/example.com create mode 100755 php/init.php create mode 100755 php/move.php create mode 100755 php/remove.php create mode 100755 php/test.php create mode 100755 php/touch.php diff --git a/php/config-sample.php b/php/config-sample.php new file mode 100755 index 00000000..a2582b92 --- /dev/null +++ b/php/config-sample.php @@ -0,0 +1,39 @@ + diff --git a/php/create.php b/php/create.php new file mode 100755 index 00000000..42fccd25 --- /dev/null +++ b/php/create.php @@ -0,0 +1,158 @@ + /dev/null"; +$result = system($command); + +//Error check +if ($result != '') { + die("\nError encountered while extracting latest wordpress in directory " . $domain['rootdir'] . "\n"); +} + +$command = "mv " . $domain['htdocs'] . "/wordpress/* " . $domain['htdocs'] . "/"; +echo "\n COMMAND :: $command \n"; +$result = system($command); + +//Error check +if ($result != '') { + die("\nError encountered while moving latest wordpress in directory " . $domain['rootdir'] . "\n" . $result); +} + +/** + * MySQL Creation + */ + +$command = "mysql -h " . $local_env['mysql_host'] . " -u " . $local_env['mysql_user'] . " -p" . $local_env['mysql_pass'] . " -e 'create database `'" . $domain['name'] . "'` '"; +$result = system($command); + +/* + * Create wp-config.php + */ +$wp_config_sample = $domain['htdocs'] . "/wp-config-sample.php"; + +$command = "sed s/database_name_here/{$domain['name']}/ $wp_config_sample | sed s/username_here/{$local_env['mysql_user']}/ | sed s/password_here/{$local_env['mysql_pass']}/ > {$domain['htdocs']}/wp-config.php"; + +$result = system($command); + +/** + * Chown + */ +$command = "chown -R " . $local_env['nginx_user'] . ":" . $local_env['nginx_group'] . " " . $domain['rootdir']; +echo "\n COMMAND :: $command \n"; +$result = system($command); + +//Error check +if ($result != '') { + die("\nError encountered while charging owner of " . $domain['rootdir'] . "\n" . $result); +} + + +/** + * ALL SEENS WELL - Restart nginx + */ +echo "\n Relaoding nginx configuration...\n\n"; +system('service nginx reload'); + +/** + * THE END + */ +//just echo URL for new domain like http://$domain +//user will click it and verify if its working fine! ;-) + +echo $domain['name'] . " Successfully created\n\n"; + +?> diff --git a/php/example.com b/php/example.com new file mode 100755 index 00000000..92244579 --- /dev/null +++ b/php/example.com @@ -0,0 +1,22 @@ +server{ + server_name www.example.com example.com; + + 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; + + ## PHP with FATSCGI + location ~ \.php$ { + include /etc/nginx/fastcgi_params; + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + } + + #root dir + location / { + autoindex on; + try_files $uri $uri/ /index.php; + } +} diff --git a/php/init.php b/php/init.php new file mode 100755 index 00000000..28346bde --- /dev/null +++ b/php/init.php @@ -0,0 +1,54 @@ + diff --git a/php/move.php b/php/move.php new file mode 100755 index 00000000..78590706 --- /dev/null +++ b/php/move.php @@ -0,0 +1,156 @@ + $domain + */ +function move_domain($usr_domain) { + global $local_env, $remote_env; + + if(trim($usr_domain) == ''){ + echo "\n CURRENT DOMAIN IS SKIPPED\n"; + return; + } + + /* + * Set domain environment values + */ + $domain['name'] = $usr_domain; + $domain['conf'] = $local_env['nginx_dir_sites_avilable'] . '/' . $domain['name']; + $domain['rootdir'] = $local_env['webroot'] . '/' . $domain['name']; + $domain['htdocs'] = $domain['rootdir'] . '/' . $local_env['htdocs'] ; + $domain['logs'] = $domain['rootdir'] . '/' . $local_env['logs'] ; + + /** + * Check if domain config file already exists + */ + if (file_exists($domain['conf'])) { + echo "\nConfiguration files for domain '" . $domain['name'] . "'already exists :: " . $domain['conf']; + echo "\nDo you want to overwrite previous configuration? [Y/N] (default=Y)"; + + if (in_array(strtolower(fgets(STDIN)), array('n', 'no'))) { + die("\nYou choose to terminate this script! Bye-Bye!!! \n"); + } + } + + /** + * At this point - either domain config file doesn't exist or user showed interest in overwriting it + * In either case... + * Create nginx conf for $domain in /etc/nginx/sites-available/$domain + * TODO :: Provide options to add supercache and/or w3total cache rules + */ + /** + * Create config file + */ + $nginx_conf = file_get_contents($local_env['default_conf']); + $nginx_conf = str_replace($local_env['default_domain'], $domain['name'], $nginx_conf); + file_put_contents($domain['conf'], $nginx_conf); + +//Error Check - if config file is created successfully or not + if (!file_exists($domain['conf'])) { + die("\nError encounterd while creating " . $domain['conf']); + } + + /** + * Linking config file + */ + echo "\nCreating Symbolic Link..\n"; + $command = "sudo ln -s " . $domain['conf'] . " " . $local_env['nginx_dir_sites_enabled']; + $result = system($command); + +//Error check - if linking config file succeed + if ($result != '') { + die("\nError encountered while creating script. Please check if file '" . $domain['conf'] . "'is created or not!\n"); + } + +//Go Ahead. +// echo "Nginx configuration for '" . $domain['name'] . "' is created successfully"; + + /** + * Create webroot dirs for new domain + */ +//create dirs + $result = system("mkdir " . $domain['rootdir']); + $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"); + +//Error check + if ($result != '') { + die("\nError encountered while creating websites directories & files for " . $domain['name'] . "\n"); + } + + /** + * moving wordpress in new webroot dir + */ +//export remote db + $command = "rsync --exclude '*.iso' -avz {$remote_env['ssh_user']}@{$remote_env['host']}:{$remote_env['webroot']}/{$domain['name']}/htdocs/* {$domain['htdocs']}/"; + $result = system($command); + + + /** + * MySQL Moving + */ + $wp_config = get_defines($domain['htdocs'] . '/wp-config.php'); + + $command = "mysqldump -u {$wp_config['DB_USER']} -p{$wp_config['DB_PASSWORD']} -h {$remote_env['host']} --databases '{$wp_config['DB_NAME']}' > {$domain['rootdir']}/{$domain['name']}.sql"; +// echo "\n" . $command . "\n"; + $result = system($command); + + $command = "mysql -h {$local_env['mysql_host']} -u {$local_env['mysql_user']} -p{$local_env['mysql_pass']} < {$domain['rootdir']}/{$domain['name']}.sql"; +// echo "\n\n" . $command . "\n"; + $result = system($command); + + /* + * Create wp-config.php + */ + //this may not be needed as we already have wp-config.php present for remote WordPress + //@TODO we need to replace DB_HOST though + + + /** + * Chown + */ + $command = "chown -R " . $local_env['nginx_user'] . ":" . $local_env['nginx_group'] . " " . $domain['rootdir']; + echo "\n COMMAND :: $command \n"; + $result = system($command); + +//Error check + if ($result != '') { + die("\nError encountered while chaging owner of " . $domain['rootdir'] . "\n" . $result); + } +} +?> \ No newline at end of file diff --git a/php/remove.php b/php/remove.php new file mode 100755 index 00000000..25c64788 --- /dev/null +++ b/php/remove.php @@ -0,0 +1,107 @@ + \ No newline at end of file diff --git a/php/test.php b/php/test.php new file mode 100755 index 00000000..a83076cf --- /dev/null +++ b/php/test.php @@ -0,0 +1,11 @@ + diff --git a/php/touch.php b/php/touch.php new file mode 100755 index 00000000..1587dd02 --- /dev/null +++ b/php/touch.php @@ -0,0 +1,99 @@ + \ No newline at end of file From d2f26ad1c1f7076be7924fcf12006af860c580c8 Mon Sep 17 00:00:00 2001 From: Rahul Bansal Date: Tue, 9 Oct 2012 18:04:23 +0530 Subject: [PATCH 04/10] readme.update --- README.md | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1f926ccb..52720162 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,43 @@ -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 + + + -=== Notes: From ac6fe869930518e3c59bad95a494aedfec3e4369 Mon Sep 17 00:00:00 2001 From: Rahul Bansal Date: Tue, 9 Oct 2012 18:11:46 +0530 Subject: [PATCH 05/10] readme.update --- README.md | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 52720162..ea9635d7 100644 --- a/README.md +++ b/README.md @@ -11,31 +11,49 @@ This is work in PROGRESS. This will break things on your end most likely! ### engine Commands: -`engine site` site-specific commands +`engine site` #site-specific commands + `engine system` system-wide commands + `engine config` configuration commands -## engine site +### engine site `engine site create [--with-wordpress]` + `engine site read --active` + `engine site update ` + `engine site delete ` -## engine system +### 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 `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` + From 88e3a50254240f7f83f2645dcd8e3709d8a80790 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 9 Oct 2012 20:42:36 +0530 Subject: [PATCH 06/10] Install Nginx --- setup/install-nginx.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 setup/install-nginx.sh 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 :(" From eb0bb20496dd756423e6c6fa7b08a6ad32712d56 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 9 Oct 2012 20:42:49 +0530 Subject: [PATCH 07/10] Install PHP --- setup/install-php5.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 setup/install-php5.sh 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 :(" + From 693ea5d07dd197fb6dc2810d4fd1df71beaf17ab Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 9 Oct 2012 20:43:02 +0530 Subject: [PATCH 08/10] Install MySQL --- setup/install-mysql.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 setup/install-mysql.sh 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 :(" + From e72a24a194fa0ea2ea9fb4fb2ce858182bc47c1d Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 9 Oct 2012 20:43:17 +0530 Subject: [PATCH 09/10] Install Postfix --- setup/install-postfix.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 setup/install-postfix.sh 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 :(" + From 33c5e89aece0462c341a59d03065b44c75192ff4 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 9 Oct 2012 20:44:35 +0530 Subject: [PATCH 10/10] Pre-checks to prevent screw ups --- setup/pre-checks.sh | 65 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 setup/pre-checks.sh 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 +