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

Commit

Permalink
New: Add assets install devcontrol action
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroamador committed Jan 24, 2020
1 parent a646e76 commit d8a0e85
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/data
/docker-compose.yml
69 changes: 69 additions & 0 deletions devcontrol/actions/assets-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

set -eu

# @description Install item assets
#
# @example
# assets-install
#
# @arg $1 Task: "brief", "help" or "exec"
#
# @exitcode The result of the assets installation
#
# @stdout "Not implemented" message if the requested task is not implemented
#
function assets-install() {

# Init
local briefMessage
local helpMessage

briefMessage="Install assets"
helpMessage=$(cat <<EOF
Install nginx product assets:
* Create the "data/usr/share/nginx/html" directory with all permissions (777)
* Create the network "platform_products"
EOF
)

# Task choosing
case $1 in
brief)
showBriefMessage "${FUNCNAME[0]}" "$briefMessage"
;;
help)
showHelpMessage "${FUNCNAME[0]}" "$helpMessage"
;;
exec)
# Create network
if [ "$(docker network ls -f name='platform_products' -q)" == "" ]; then
echo -n "- Creating docker network 'platform_products' ..."
docker network create platform_products
echo "[OK]"
else
echo "The 'platform_services' docker network already exists, skipping"
fi
# Create directories
for directory in data data/usr data/usr/share data/usr/share/nginx data/usr/share/nginx/html; do
if [ ! -d ${directory} ]; then
echo -n "- Creating '${directory}' directory..."
mkdir ${directory}
echo "[OK]"
echo -n "- Setting '${directory}' permissions..."
chmod 777 ${directory}
echo "[OK]"
else
echo "The '${directory}' directory already exists, skipping"
fi
done
;;
*)
showNotImplemtedMessage "$1" "${FUNCNAME[0]}"
return 1
esac
}

# Main
assets-install "$@"

0 comments on commit d8a0e85

Please sign in to comment.