Skip to content
This repository has been archived by the owner on Aug 10, 2020. It is now read-only.

Commit

Permalink
Merge pull request #26 from mbtamuli/add_update_command
Browse files Browse the repository at this point in the history
Add update command
  • Loading branch information
mbtamuli authored Jan 24, 2018
2 parents 9840b63 + a0c5829 commit f56f3eb
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 6 deletions.
54 changes: 52 additions & 2 deletions scripts/ee4
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ PROJECT_NAME="ee4"
EE_INSTALL_DIR="/opt/$PROJECT_NAME"
ETC_HOSTS=/etc/hosts
LOCALHOST_IP="127.0.0.1"
WEBROOT="/var/www"

# runs the given command as root (detects if we are root already)
runAsRoot() {
Expand Down Expand Up @@ -43,7 +42,9 @@ help () {

singleWordPress() {
echo "Installing WordPress site $SITE_NAME"
mkdir -p "$WEBROOT" > /dev/null 2>&1
if ! [[ -d "$WEBROOT" ]]; then
runAsRoot mkdir -p "$WEBROOT" > /dev/null 2>&1
fi

###
# Setup site configuration
Expand Down Expand Up @@ -195,13 +196,40 @@ fail_trap() {
exit $result
}

initEE4() {
if ! [[ -d ~/.ee4 ]]; then
mkdir ~/.ee4
fi

if [[ $# -eq 0 ]]; then
read -p "Where would you like to create your sites(default: ~/Documents/Sites): "
WEBROOT="${REPLY:-~/Documents/Sites}"
elif [[ $# -eq 1 ]]; then
WEBROOT="$1"
fi

echo "WEBROOT=$WEBROOT" > ~/.ee4/config
}

updateEE4() {
REPO_URL="${1:-https://github.com/EasyEngine/docker-compose-wordpress}"
VERSION="${2:-master}"

echo "git pull -b "$VERSION" "$REPO_URL""

pushd "$EE_INSTALL_DIR" > /dev/null 2>&1
git pull "$REPO_URL" "$VERSION"
popd > /dev/null 2>&1
}

# Execution

#Stop execution on any error
trap "fail_trap" EXIT
set -e

[[ -f ~/.ee4/config ]] && source ~/.ee4/config || initEE4

# Parsing input arguments (if any)
export INPUT_ARGUMENTS="${@}"
set -u
Expand Down Expand Up @@ -254,6 +282,14 @@ while [[ $# -gt 0 ]]; do
exit 0
fi
;;
'init')
shift
if [[ $# -ne 0 ]]; then
initEE4 $1
else
initEE4
fi
;;
'restart')
shift
if [[ $# -ne 0 ]]; then
Expand All @@ -264,6 +300,20 @@ while [[ $# -gt 0 ]]; do
exit 0
fi
;;
'update')
shift
if [[ $# -eq 0 ]]; then
updateEE4
exit 0
elif [[ $# -eq 1 ]]; then
#statements
updateEE4 $1 master
exit 0
elif [[ $# -eq 2 ]]; then
updateEE4 $1 $2
exit 0
fi
;;
'wp')
shift
if [[ $# -ne 0 ]]; then
Expand Down
9 changes: 5 additions & 4 deletions scripts/setup
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env bash

PROJECT_NAME="ee4"
REPO_URL="https://github.com/EasyEngine/docker-compose-wordpress"
VERSION="master"
REPO_URL="${REPO_URL:-https://github.com/EasyEngine/docker-compose-wordpress}"
VERSION="${VERSION:-master}"


# runs the given command as root (detects if we are root already)
runAsRoot() {
Expand Down Expand Up @@ -62,9 +63,9 @@ cloneRepo() {

# installScript installs the main script.
installScript() {
EE_INSTALL_DIR="/opt/$PROJECT_NAME"
EE_INSTALL_DIR="${EE_INSTALL_DIR:-/opt/$PROJECT_NAME}"
EE_SCRIPT="scripts/ee4"
EE_SCRIPT_INSTALL_PATH="/usr/local/bin/ee4"
EE_SCRIPT_INSTALL_PATH="${EE_SCRIPT_INSTALL_PATH:-/usr/local/bin/ee4}"

rm -rf "$EE_INSTALL_DIR"
echo "Preparing to install into $EE_INSTALL_DIR"
Expand Down

0 comments on commit f56f3eb

Please sign in to comment.