Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/sh
set -e

command_exists() {
command -v "$@" > /dev/null 2>&1
}

# check if the current user is root
if [ "$(id -u)" != "0" ]; then
echo "Error: you must be root to execute this script" >&2
Expand All @@ -19,6 +23,13 @@ if [ -f /.dockerenv ]; then
exit 1
fi


# check if lsof is installed
if ! command_exists lsof
then
apt install -y lsof
fi

# check if something is running on port 80
if lsof -i :80 -sTCP:LISTEN >/dev/null; then
echo "Error: something is already running on port 80" >&2
Expand All @@ -31,10 +42,6 @@ if lsof -i :443 -sTCP:LISTEN >/dev/null; then
exit 1
fi

command_exists() {
command -v "$@" > /dev/null 2>&1
}

if command_exists docker; then
echo "Docker already installed"
else
Expand All @@ -49,7 +56,7 @@ sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
URIs: https://download.docker.com/linux/$(. /etc/os-release && echo "${ID:-ubuntu}")
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
Expand Down