Skip to content

Commit

Permalink
Port checkup
Browse files Browse the repository at this point in the history
  • Loading branch information
tmachyshyn committed Feb 16, 2024
1 parent 19de042 commit 43c896d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,22 @@ function isIpAddress() {
echo false
}

function isPortInUse() {
local port="$1"

if [ -z "$port" ]; then
echo false
return
fi

if (echo >"/dev/tcp/localhost/$port") &>/dev/null ; then
echo true
return
fi

echo false
}

function isEmailValidated() {
local emailAddress="$1"

Expand Down Expand Up @@ -368,6 +384,13 @@ function checkFixSystemRequirements() {
printExitError "Missing libraries: ${missingLibs[@]}. Please install them and try again."
;;
esac

# Check port
local isPortInUse=$(isPortInUse "${data[httpPort]}")

if [ "$isPortInUse" = true ]; then
printExitError "The required port \"${data[httpPort]}\" is already in use. Free up the port and try again."
fi
}

function getBackupDirectory() {
Expand Down

0 comments on commit 43c896d

Please sign in to comment.