Skip to content

Commit

Permalink
feat(docker): add helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
efraa committed Feb 28, 2022
1 parent 44bf2c1 commit 09b76de
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docker/helpers/check-if-installed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Validate that there is no project installation in the current directory
function check_if_installed() {
PROJECT_ENV="fonoster/operator/.env"

if [[ -f $PROJECT_ENV ]]; then
error "You already have a project installed in this directory. Please, remove the current installation first as this may cause issues."
fi
}
20 changes: 20 additions & 0 deletions docker/helpers/check-ports.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Validate the required ports are available for the application
function check_ports() {
for port in "$@"; do
[ -z "$port" ] && error "Port '$port' is not a valid port"

PORT_USED="$(netstat -lnt | awk '{print $4}' | grep -E ":$port$")"

if [ -n "$PORT_USED" ]; then
warning "Port '$port' is already in use by another process, please stop the process and try again."

echo -e "$PORT_USED"

warning "Another option is run the container with the '-e HTTPS_PORT' option to specify a different port."

error "Unable to continue. Exiting..."
fi
done
}

0 comments on commit 09b76de

Please sign in to comment.