Browse Source

ee site created

old-stable
Mitesh Shah 11 years ago
parent
commit
5f199ccc14
  1. 7
      .travis.yml
  2. 93
      bin/easyengine
  3. 27
      src/lib/ee_lib_git.sh
  4. 15
      src/lib/ee_lib_git_commit.sh
  5. 23
      src/lib/ee_lib_git_init.sh
  6. 4
      src/lib/ee_lib_permissions.sh

7
.travis.yml

@ -56,3 +56,10 @@ script:
- sudo bash ee info php
- sudo bash ee info mysql
- sudo bash ee info
- sudo bash ee site create html.com
- sudo bash ee site create html2.com --html
- sudo bash ee site info html.com
- sudo bash ee site show html.com
- sudo bash ee site list
- sudo bash ee site list available

93
bin/easyengine

@ -68,13 +68,13 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then
ee_lib_service php5-fpm restart
# Initialize Git
ee_lib_git_init /etc/php5/
ee_lib_git /etc/php5/ "Initialize Git"
else
# Restart NGINX/MySQL/Postfix
ee_lib_service $EE_THIRD restart
# Initialize Git
ee_lib_git_init /etc/$EE_THIRD/
ee_lib_git /etc/$EE_THIRD/ "Initialize Git"
fi
fi
@ -111,7 +111,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then
ee_lib_service nginx php5-fpm mysql restart
# Initialize Git
ee_lib_git_init /etc/nginx/ /etc/php5/ /etc/mysql/ /etc/postfix
ee_lib_git /etc/nginx/ /etc/php5/ /etc/mysql/ /etc/postfix "Initialize Git"
# Install Adminer/phpMyAdmin/WP-CLI/Utils
ee_ven_install_adminer
@ -174,6 +174,93 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then
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
# EasyEngine site
elif [ "$EE_FIRST" = "site" ]; then
if [ "$EE_SECOND" = "list" ]; then
if [ "$EE_THIRD" = "available" ];then
ee_lib_echo "List of sites-available websites:"
ls /etc/nginx/sites-available/ \
|| ee_lib_error "Unable to display list of sites-available websites, exit status = " $?
else
e_lib_echo "List of sites-enabled websites:"
ls /etc/nginx/sites-available/ \
|| ee_lib_error "Unable to display list of sites-enabled websites, exit status = " $?
fi
elif [ "$EE_SECOND" = "info" ] || [ "$EE_SECOND" = "show" ]; then
# Check the website name is empty or not
EE_DOMAIN_CHECK=$EE_THIRD
ee_lib_check_domain
if [ "$EE_SECOND" = "info" ]; then
# Display information about website
ee_mod_site_info
elif [ "$EE_SECOND" = "show" ]; then
# Check the website exist
ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \
|| ee_lib_error "The $EE_DOMAIN is not found in /etc/nginx/sites-available, exit status = " $?
# Display NGINX configuration for $EE_DOMAIN
if [ $? -eq 0 ]; then
ee_lib_echo "Display NGINX configuration for $EE_DOMAIN"
cat /etc/nginx/sites-available/$EE_DOMAIN \
|| ee_lib_error "Unable to display NGINX configuration for $EE_DOMAIN, exit status = " $?
fi
fi
elif [ "$EE_SECOND" = "create" ]; then
# Configure variables
EE_DOMAIN_CHECK=$EE_THIRD
EE_SITE_CREATE_OPTION=$EE_FOURTH
EE_SITE_CACHE_OPTION=$EE_FIFTH
# Auto switch options
if [ "$EE_SITE_CREATE_OPTION" = "--basic" ] || [ "$EE_SITE_CREATE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpfc" ]; then
if [ "$EE_SITE_CACHE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdirectory" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdomain" ]; then
EE_SITE_CREATE_OPTION=$EE_FIFTH
EE_SITE_CACHE_OPTION=$EE_FOURTH
else
EE_SITE_CREATE_OPTION=--wp
EE_SITE_CACHE_OPTION=$EE_FOURTH
fi
fi
# WordPresss subdirectory variables
if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdirectory" ]; then
EE_NETWORK_ACTIVATE="--network"
fi
# WordPress sub-domain variables
if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then
EE_NETWORK_ACTIVATE="--network"
EE_WP_SUBDOMAIN="--subdomains"
fi
# Use default whenever possible
if [ "$EE_SITE_CREATE_OPTION" = "" ]; then
EE_SITE_CREATE_OPTION=--html
fi
# For WordPress sites if $EE_SITE_CACHE_OPTION is empty then used --basic as a $EE_SITE_CACHE_OPTION
if [ "$EE_SITE_CACHE_OPTION" = "" ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then
EE_SITE_CACHE_OPTION=--basic
fi
# Lets create HTML website
if [ "$EE_SITE_CREATE_OPTION" = "--html" ]; then
# Configure variable
EE_NGINX_CONF=html/basic.conf
echo -e "EE_DOMAIN_CHECK = $EE_DOMAIN_CHECK \nEE_SITE_CREATE_OPTION = $EE_SITE_CREATE_OPTION \nEE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION \nEE_NETWORK_ACTIVATE = $EE_NETWORK_ACTIVATE \nEE_WP_SUBDOMAIN = $EE_WP_SUBDOMAIN \nEE_NGINX_CONF = $EE_NGINX_CONF" &>> $EE_COMMAND_LOG
# Setup HTML website
ee_lib_check_domain
ee_mod_setup_domain
# Adjust permission
ee_lib_permissions
# Git commit
ee_lib_git /etc/nginx/ "$EE_DOMAIN created with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options"
# Display Success Message
ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN"
fi
fi
fi
}

27
src/lib/ee_lib_git.sh

@ -0,0 +1,27 @@
# Initialize Git
function ee_lib_git()
{
for ee_git_dir in $@; do
if [ $ee_git_dir != ${@: -1} ]; then
# Change directory
cd $ee_git_dir || ee_lib_error "Unable to change directory $ee_git_dir, exit status = " $?
# Check .git
if [ ! -d .git ]; then
ee_lib_echo "Initialize Git on ${ee_git_dir}..."
git init &>> $EE_COMMAND_LOG \
|| ee_lib_error "Unable to initialize Git on $ee_git_dir, exit status = " $?
fi
# Check for untracked files
if [ $(git status -s | wc -l) -ne 0 ]; then
# Add files in Git version control
ee_lib_echo "Committing changes inside $EE_GIT_DIR, please wait..."
git add --all && git commit -am ${@: -1} &>> $EE_COMMAND_LOG \
|| ee_lib_error "Unable to Git commit on $ee_git_dir, exit status = " $?
fi
fi
done
}

15
src/lib/ee_lib_git_commit.sh

@ -1,15 +0,0 @@
# Record changes to the repository
function ee_lib_git_commit()
{
cd $EE_GIT_DIR \
|| ee_lib_error "Unable to change directory $EE_GIT_DIR, exit status = " $?
if [ $(git status -s | wc -l) -ne 0 ]; then
ee_lib_echo "Committing changes inside $EE_GIT_DIR, please wait..."
# Add newly created files && commit it
git add --all && git commit -am "$EE_GIT_MESSAGE" &>> $EE_COMMAND_LOG \
|| ee_lib_error "Unable to Git commit on $EE_GIT_DIR, exit status = " $?
fi
}

23
src/lib/ee_lib_git_init.sh

@ -1,23 +0,0 @@
# Initialize Git
function ee_lib_git_init()
{
for ee_git_dir in $@; do
# Change directory
cd $ee_git_dir || ee_lib_error "Unable to change directory $ee_git_dir, exit status = " $?
# Check .git
if [ ! -d .git ]; then
ee_lib_echo "Initialize Git on ${ee_git_dir}..."
git init &>> $EE_COMMAND_LOG \
|| ee_lib_error "Unable to initialize Git on $ee_git_dir, exit status = " $?
fi
# Check for untracked files
if [ $(git status -s | wc -l) -ne 0 ]; then
# Add files in Git version control
git add --all && git commit -am "Initialize Git on $ee_git_dir" &>> $EE_COMMAND_LOG \
|| ee_lib_error "Unable to Git commit on $ee_git_dir, exit status = " $?
fi
done
}

4
src/lib/ee_lib_permissions.sh

@ -1,8 +1,8 @@
# Set ownership of /var/www/$EE_DOMAIN to www-data:www-data
# Adjust permission
function ee_lib_permissions()
{
ee_lib_echo "Changing ownership of /var/www/$EE_DOMAIN..."
ee_lib_echo "Changing ownership of /var/www/$EE_DOMAIN, please wait..."
chown -R $EE_PHP_USER:$EE_PHP_USER /var/www/$EE_DOMAIN/ \
|| ee_lib_error "Unable to change ownership for $EE_DOMAIN, exit status = " $?
}

Loading…
Cancel
Save